From 697541ea2c50ba97fc4b4e31e9e7c4d82be51899 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 28 Sep 2013 08:55:45 +0200 Subject: Fix copy constructor of SmTreeItem Seems the copy constructor of SmTreeItem was botched. After copying a rootItem, some children wouldn't show up. I guess it has something to do with the QHash of the parents. Replace it with an explictit deep copy function where needed. --- archivemodel.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'archivemodel.cpp') diff --git a/archivemodel.cpp b/archivemodel.cpp index 75f6509..b4a1e2b 100644 --- a/archivemodel.cpp +++ b/archivemodel.cpp @@ -976,11 +976,25 @@ ArchiveCollector::ArchiveCollector(int numFields, int order, QObject *parent) : SmTreeItem *ArchiveCollector::rootItem(){ mAccessMx.lock(); - SmTreeItem *retval = new SmTreeItem(*mRootItem); + SmTreeItem *retval = copyRecursive(mRootItem, 0); mAccessMx.unlock(); return retval; } +SmTreeItem *ArchiveCollector::copyRecursive(SmTreeItem *item, SmTreeItem *parent){ + SmTreeItem *newItem = new SmTreeItem(*item); + newItem->setParent(parent); + if(parent){ + parent->appendChild(newItem); + } + if(item->childCount()){ + for(int i = 0; i < item->childCount(); ++i){ + copyRecursive(item->child(i), newItem); + } + } + return newItem; +} + void ArchiveCollector::setCancelled(bool cancel){ QMutexLocker l(&mCancelledMx); mCancelled = cancel; -- cgit v1.2.3-70-g09d2