mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 13:36:48 +08:00
Guard QTimer::singleShot
This commit is contained in:
committed by
Roland Winklmeier
parent
3ecb7b1f94
commit
3f4cb7529c
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "digestsignal.h"
|
||||
#include "threadutils.h"
|
||||
#include <QPointer>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -17,7 +18,12 @@ namespace BlackMisc
|
||||
if (!CThreadUtils::isCurrentThreadObjectThread(this))
|
||||
{
|
||||
// call in correct thread
|
||||
QTimer::singleShot(0, this, &CDigestSignal::inputSignal);
|
||||
const QPointer<CDigestSignal> myself(this);
|
||||
QTimer::singleShot(0, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
this->inputSignal();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,7 +39,7 @@ namespace BlackMisc
|
||||
{
|
||||
m_timer.stop();
|
||||
m_inputsCount = 0;
|
||||
emit digestSignal();
|
||||
emit this->digestSignal();
|
||||
}
|
||||
|
||||
void CDigestSignal::init(int maxDelayMs)
|
||||
@@ -42,5 +48,4 @@ namespace BlackMisc
|
||||
m_timer.setSingleShot(true);
|
||||
m_timer.setInterval(maxDelayMs);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user