Fixed task object leaks

This commit is contained in:
Slava Monich 2015-07-06 18:11:03 +03:00
parent dfe56dcfc1
commit cc6729f440

View file

@ -427,6 +427,7 @@ void BooksShelf::CopyTask::performTask()
class BooksShelf::DeleteTask : public BooksTask class BooksShelf::DeleteTask : public BooksTask
{ {
Q_OBJECT
public: public:
DeleteTask(BooksBook* aBook); DeleteTask(BooksBook* aBook);
~DeleteTask(); ~DeleteTask();
@ -556,6 +557,7 @@ void BooksShelf::onLoadTaskDone()
{ {
HASSERT(iLoadTask); HASSERT(iLoadTask);
HASSERT(iLoadTask == sender()); HASSERT(iLoadTask == sender());
iLoadTask->release(this);
iLoadTask = NULL; iLoadTask = NULL;
Q_EMIT loadingChanged(); Q_EMIT loadingChanged();
} }
@ -1025,7 +1027,12 @@ void BooksShelf::onCopyTaskDone()
void BooksShelf::onDeleteTaskDone() void BooksShelf::onDeleteTaskDone()
{ {
HVERIFY(iDeleteTasks.removeOne((DeleteTask*)sender())); DeleteTask* task = qobject_cast<DeleteTask*>(sender());
HASSERT(task);
if (task) {
task->release(this);
HVERIFY(iDeleteTasks.removeOne(task));
}
} }
QHash<int,QByteArray> BooksShelf::roleNames() const QHash<int,QByteArray> BooksShelf::roleNames() const