refs #833, use isShuttingDown in readers

(a bit stricter than this->isAbandoned)
This commit is contained in:
Klaus Basan
2016-12-15 01:25:58 +01:00
parent 0beb7faf06
commit 5107d55115
7 changed files with 28 additions and 14 deletions

View File

@@ -7,8 +7,9 @@
* contained in the LICENSE file.
*/
#include "blackmisc/network/networkutils.h"
#include "blackcore/threadedreader.h"
#include "blackcore/application.h"
#include "blackmisc/network/networkutils.h"
#include "blackmisc/threadutils.h"
#include <QCoreApplication>
@@ -77,6 +78,7 @@ namespace BlackCore
void CThreadedReader::gracefulShutdown()
{
// if not in main thread stop, otherwise it makes no sense to abandon
this->m_shutdown = true;
if (!CThreadUtils::isCurrentThreadObjectThread(this))
{
this->abandonAndWait();
@@ -86,7 +88,7 @@ namespace BlackCore
void CThreadedReader::startReader()
{
Q_ASSERT(m_initialTime > 0);
QTimer::singleShot(m_initialTime, this, [=] { this->doWork(); });
QTimer::singleShot(m_initialTime, this, [ = ] { this->doWork(); });
}
void CThreadedReader::pauseReader()
@@ -94,6 +96,14 @@ namespace BlackCore
QTimer::singleShot(0, m_updateTimer, &QTimer::stop);
}
bool CThreadedReader::isShuttingDown() const
{
if (this->m_shutdown) { return true; }
if (this->isAbandoned()) { return true; }
if (!sApp) { return true; } // sApp object is gone, whole system shutdown
return false;
}
bool CThreadedReader::didContentChange(const QString &content, int startPosition)
{
uint oldHash = 0;