diff --git a/app/src/BooksTask.cpp b/app/src/BooksTask.cpp index fc99edf..8b120f1 100644 --- a/app/src/BooksTask.cpp +++ b/app/src/BooksTask.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Jolla Ltd. + * Copyright (C) 2015-2017 Jolla Ltd. * Contact: Slava Monich * * You may use this file under the terms of the BSD license as follows: @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * * Neither the name of Nemo Mobile nor the names of its contributors + * * Neither the name of Jolla Ltd nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. * @@ -40,8 +40,9 @@ BooksTask::BooksTask() : iAboutToQuit(false), - iReleased(false), + iSubmitted(false), iStarted(false), + iReleased(false), iDone(false) { setAutoDelete(false); @@ -53,20 +54,22 @@ BooksTask::BooksTask() : BooksTask::~BooksTask() { HASSERT(iReleased); - if (iStarted) wait(); + if (iSubmitted) wait(); } void BooksTask::release(QObject* aHandler) { disconnect(aHandler); iReleased = true; - if (!iStarted || iDone) { + if (!iSubmitted || iDone) { delete this; } } void BooksTask::run() { + HASSERT(!iStarted); + iStarted = true; performTask(); Q_EMIT runFinished(); } diff --git a/app/src/BooksTask.h b/app/src/BooksTask.h index ab11621..92f499d 100644 --- a/app/src/BooksTask.h +++ b/app/src/BooksTask.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Jolla Ltd. + * Copyright (C) 2015-2017 Jolla Ltd. * Contact: Slava Monich * * You may use this file under the terms of the BSD license as follows: @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * * Neither the name of Nemo Mobile nor the names of its contributors + * * Neither the name of Jolla Ltd nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. * @@ -50,10 +50,11 @@ protected: public: virtual ~BooksTask(); + bool isStarted() const; void release(QObject* aHandler); protected: - bool isCanceled() const { return iReleased || iAboutToQuit; } + bool isCanceled() const; virtual void run(); virtual void performTask() = 0; @@ -68,9 +69,15 @@ private Q_SLOTS: private: bool iAboutToQuit; - bool iReleased; + bool iSubmitted; bool iStarted; + bool iReleased; bool iDone; }; +inline bool BooksTask::isStarted() const + { return iStarted; } +inline bool BooksTask::isCanceled() const + { return iReleased || iAboutToQuit; } + #endif // BOOKS_TASK_H diff --git a/app/src/BooksTaskQueue.cpp b/app/src/BooksTaskQueue.cpp index 53fb279..0a7569f 100644 --- a/app/src/BooksTaskQueue.cpp +++ b/app/src/BooksTaskQueue.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Jolla Ltd. + * Copyright (C) 2015-2017 Jolla Ltd. * Contact: Slava Monich * * You may use this file under the terms of the BSD license as follows: @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * * Neither the name of Nemo Mobile nor the names of its contributors + * * Neither the name of Jolla Ltd nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. * @@ -103,8 +103,8 @@ BooksTaskQueue::~BooksTaskQueue() void BooksTaskQueue::submit(BooksTask* aTask) { - HASSERT(!aTask->iStarted); - aTask->iStarted = true; + HASSERT(!aTask->iSubmitted); + aTask->iSubmitted = true; iPool->start(aTask); }