BLACK_AUDIT_X for killTimer, trace Qt killTimer warnings in "our" code

This commit is contained in:
Klaus Basan
2020-01-27 15:13:14 +01:00
committed by Mat Sutcliffe
parent 4ca3a925ce
commit 481833b003
3 changed files with 24 additions and 5 deletions

View File

@@ -314,6 +314,7 @@ namespace BlackCore
void ISimulator::safeKillTimer() void ISimulator::safeKillTimer()
{ {
if (m_timerId < 0) { return; } if (m_timerId < 0) { return; }
BLACK_AUDIT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Try to kill timer from another thread");
this->killTimer(m_timerId); this->killTimer(m_timerId);
m_timerId = -1; m_timerId = -1;
} }

View File

@@ -10,6 +10,8 @@
#include "loadindicator.h" #include "loadindicator.h"
#include "guiapplication.h" #include "guiapplication.h"
#include "blackmisc/verify.h"
#include "blackmisc/threadutils.h"
#include <QColor> #include <QColor>
#include <QPainter> #include <QPainter>
@@ -18,6 +20,8 @@
#include <QSizePolicy> #include <QSizePolicy>
#include <QtGlobal> #include <QtGlobal>
using namespace BlackMisc;
namespace BlackGui namespace BlackGui
{ {
CLoadIndicator::CLoadIndicator(int width, int height, QWidget *parent) CLoadIndicator::CLoadIndicator(int width, int height, QWidget *parent)
@@ -86,7 +90,11 @@ namespace BlackGui
if (!m_pendingIds.isEmpty()) { return; } if (!m_pendingIds.isEmpty()) { return; }
} }
m_pendingIds.clear(); m_pendingIds.clear();
if (m_timerId != -1) { killTimer(m_timerId); } if (m_timerId != -1)
{
BLACK_AUDIT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Try to kill timer from another thread");
this->killTimer(m_timerId);
}
m_timerId = -1; m_timerId = -1;
this->hide(); this->hide();
this->setEnabled(false); this->setEnabled(false);
@@ -96,7 +104,11 @@ namespace BlackGui
void CLoadIndicator::setAnimationDelay(int delay) void CLoadIndicator::setAnimationDelay(int delay)
{ {
m_delayMs = delay; m_delayMs = delay;
if (m_timerId != -1) { this->killTimer(m_timerId); } if (m_timerId != -1)
{
BLACK_AUDIT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Try to kill timer from another thread");
this->killTimer(m_timerId);
}
m_timerId = this->startTimer(m_delayMs); m_timerId = this->startTimer(m_delayMs);
} }
@@ -118,14 +130,14 @@ namespace BlackGui
void CLoadIndicator::timerEvent(QTimerEvent *event) void CLoadIndicator::timerEvent(QTimerEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event)
m_angle = (m_angle + 30) % 360; m_angle = (m_angle + 30) % 360;
this->update(); this->update();
} }
void CLoadIndicator::paintEvent(QPaintEvent *event) void CLoadIndicator::paintEvent(QPaintEvent *event)
{ {
Q_UNUSED(event); Q_UNUSED(event)
QPainter p(this); QPainter p(this);
this->paint(p); this->paint(p);
} }

View File

@@ -7,6 +7,8 @@
*/ */
#include "blackmisc/filedeleter.h" #include "blackmisc/filedeleter.h"
#include "blackmisc/threadutils.h"
#include "blackmisc/verify.h"
#include <QFile> #include <QFile>
#include <QtGlobal> #include <QtGlobal>
@@ -58,7 +60,11 @@ namespace BlackMisc
void CTimedFileDeleter::timerEvent(QTimerEvent *event) void CTimedFileDeleter::timerEvent(QTimerEvent *event)
{ {
Q_UNUSED(event) Q_UNUSED(event)
if (m_timerId > 0) { this->killTimer(m_timerId); } if (m_timerId >= 0)
{
BLACK_AUDIT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Try to kill timer from another thread");
this->killTimer(m_timerId);
}
m_timerId = -1; m_timerId = -1;
m_fileDeleter.deleteFiles(); m_fileDeleter.deleteFiles();
this->deleteLater(); this->deleteLater();