From c7593a30472ce336c5e5ecd864c046ad50e1e3f2 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Fri, 22 Mar 2013 20:57:18 +0100 Subject: [PATCH] Stop suppressing signals in Group dtor. That way we emit entry/group removed signals. Move cleanupParent() call to the bottom so we maintain the group tree structure for objects that connect to those signals. --- src/core/Group.cpp | 6 ++---- tests/TestGroup.cpp | 8 ++++---- tests/TestGroupModel.cpp | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/core/Group.cpp b/src/core/Group.cpp index 763c5c0f..3c2fec75 100644 --- a/src/core/Group.cpp +++ b/src/core/Group.cpp @@ -36,19 +36,15 @@ Group::Group() Group::~Group() { - cleanupParent(); - this->blockSignals(true); // Destroy entries and children manually so DeletedObjects can be added // to database. QList entries = m_entries; Q_FOREACH (Entry* entry, entries) { - entry->blockSignals(true); delete entry; } QList children = m_children; Q_FOREACH (Group* group, children) { - group->blockSignals(true); delete group; } @@ -58,6 +54,8 @@ Group::~Group() delGroup.uuid = m_uuid; m_db->addDeletedObject(delGroup); } + + cleanupParent(); } Group* Group::createRecycleBin() diff --git a/tests/TestGroup.cpp b/tests/TestGroup.cpp index eab686e6..f32e943b 100644 --- a/tests/TestGroup.cpp +++ b/tests/TestGroup.cpp @@ -262,8 +262,8 @@ void TestGroup::testDeleteSignals() delete groupChild; QVERIFY(groupRoot->children().isEmpty()); - QCOMPARE(spyAboutToRemove.count(), 1); - QCOMPARE(spyRemoved.count(), 1); + QCOMPARE(spyAboutToRemove.count(), 2); + QCOMPARE(spyRemoved.count(), 2); delete db; @@ -289,8 +289,8 @@ void TestGroup::testDeleteSignals() QSignalSpy spyEntryRemoved2(group2, SIGNAL(entryRemoved(Entry*))); delete group2; - QCOMPARE(spyEntryAboutToRemove2.count(), 0); - QCOMPARE(spyEntryRemoved2.count(), 0); + QCOMPARE(spyEntryAboutToRemove2.count(), 1); + QCOMPARE(spyEntryRemoved2.count(), 1); delete db2; } diff --git a/tests/TestGroupModel.cpp b/tests/TestGroupModel.cpp index 12a806a7..453aa145 100644 --- a/tests/TestGroupModel.cpp +++ b/tests/TestGroupModel.cpp @@ -135,8 +135,8 @@ void TestGroupModel::test() delete group12; QCOMPARE(spyAboutToAdd.count(), 1); QCOMPARE(spyAdded.count(), 1); - QCOMPARE(spyAboutToRemove.count(), 1); - QCOMPARE(spyRemoved.count(), 1); + QCOMPARE(spyAboutToRemove.count(), 2); + QCOMPARE(spyRemoved.count(), 2); QCOMPARE(spyAboutToMove.count(), 3); QCOMPARE(spyMoved.count(), 3); QVERIFY(!index12.isValid());