mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 15:25:35 +08:00
refs #833, use isShuttingDown in readers
(a bit stricter than this->isAbandoned)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user