diff options
author | Arno <am@disconnect.de> | 2013-06-28 13:47:08 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2013-06-28 13:47:08 +0200 |
commit | 04d9dcbe2139109e00d07488f6e45d0353a676e2 (patch) | |
tree | 3f56c92a31fce83991de3eb4073d7f751fa35b21 /archivemodel.cpp | |
parent | 4fd07f5957b20dc229c4aa76e9132d4d8e2567ef (diff) | |
download | SheMov-04d9dcbe2139109e00d07488f6e45d0353a676e2.tar.gz SheMov-04d9dcbe2139109e00d07488f6e45d0353a676e2.tar.bz2 SheMov-04d9dcbe2139109e00d07488f6e45d0353a676e2.zip |
Implement destructor for ArchiveModel, get rid of 2 signals
We need a destructor for ArchiveModel, because we have to stop the
collectors first. Otherwise there will be random crashes all over the
place on exit when the Threads are destroyed while they're still
running.
Also, get rid of the signals collectorDone and collectorAboutToBeDone.
The latter was unused, and the former can be replaced with
QAbstractItemModel::modelReset.
Diffstat (limited to 'archivemodel.cpp')
-rw-r--r-- | archivemodel.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/archivemodel.cpp b/archivemodel.cpp index 208bed8..14757af 100644 --- a/archivemodel.cpp +++ b/archivemodel.cpp @@ -36,6 +36,16 @@ ArchiveModel::ArchiveModel(const QStringList &headers, QObject *parent) : SmTree refresh(); } +ArchiveModel::~ArchiveModel(){ + /* We need this, otherwise there are random + * crashes when we exit and a collector is + * still runnning */ + foreach(ArchiveCollector *c, mCollectors){ + c->cancel(); + c->wait(); + } +} + const QStringList ArchiveModel::availableOrders() const { QStringList retval = mAvailableOrders.keys(); qSort(retval); @@ -220,7 +230,6 @@ void ArchiveModel::setOrder(int order) { SmTreeItem *rootItem = readCache(mOrder); if(rootItem){ setRoot(rootItem); - emit collectorDone(); } } @@ -245,9 +254,7 @@ void ArchiveModel::collectorFinished(QObject *thread){ SmTreeItem *rootCopy = t->rootItem(); int sortOrder = t->sortOrder(); if(sortOrder == mOrder){ - emit collectorAboutToBeDone(); setRoot(rootCopy); - emit collectorDone(); } writeCache(sortOrder, rootCopy); QString sortOrderName = mAvailableOrders.key(sortOrder); |