mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
[Worker] Stop timer in correct thread
This commit is contained in:
committed by
Mat Sutcliffe
parent
5718f95819
commit
1da66ce6e9
@@ -237,6 +237,27 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
void CContinuousWorker::stopUpdateTimer()
|
||||
{
|
||||
if (!m_updateTimer.isActive()) { return; }
|
||||
|
||||
// avoid "Timers cannot be stopped from another thread"
|
||||
if (CThreadUtils::isCurrentThreadObjectThread(&m_updateTimer))
|
||||
{
|
||||
m_updateTimer.stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
QPointer<CContinuousWorker> myself(this);
|
||||
QTimer::singleShot(0, &m_updateTimer, [ = ]
|
||||
{
|
||||
// stop timer in timer thread
|
||||
if (!myself) { return; }
|
||||
m_updateTimer.stop();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void CContinuousWorker::finish()
|
||||
{
|
||||
this->setFinished();
|
||||
|
||||
Reference in New Issue
Block a user