Issue #77 Rename

This commit is contained in:
Mat Sutcliffe
2020-08-24 17:48:55 +01:00
parent 936e869c94
commit 802576eda9
30 changed files with 95 additions and 91 deletions

View File

@@ -395,7 +395,7 @@ namespace BlackMisc
// run in page thread
//! \todo KB 2018-01 is this OK or should it go to CValuePage::setValuesFromCache?
if (CThreadUtils::isCurrentThreadObjectThread(this->m_page)) { queue->setQueuedValueFromCache(key); }
if (CThreadUtils::isInThisThread(this->m_page)) { queue->setQueuedValueFromCache(key); }
else
{
QPointer<QObject> myself(queue);

View File

@@ -14,7 +14,7 @@ namespace BlackMisc
{
void CDigestSignal::inputSignal()
{
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
// call in correct thread
const QPointer<CDigestSignal> myself(this);

View File

@@ -62,7 +62,7 @@ namespace BlackMisc
Q_UNUSED(event)
if (m_timerId >= 0)
{
BLACK_AUDIT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Try to kill timer from another thread");
BLACK_AUDIT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "Try to kill timer from another thread");
this->killTimer(m_timerId);
}
m_timerId = -1;

View File

@@ -1340,7 +1340,7 @@ namespace BlackMisc
{
//! \fixme KB 20170701 noticed the "cache" is not threadsafe. However, there has never be an issue so far. Added thread assert.
Q_ASSERT_X(!relativeFileName.isEmpty(), Q_FUNC_INFO, "missing filename");
Q_ASSERT_X(CThreadUtils::isCurrentThreadApplicationThread(), Q_FUNC_INFO, "not thread safe");
Q_ASSERT_X(CThreadUtils::thisIsMainThread(), Q_FUNC_INFO, "not thread safe");
fullFilePath = CFileUtils::appendFilePaths(CDirectoryUtils::imagesDirectory(), relativeFileName);
if (!getResourceFileCache().contains(relativeFileName))

View File

@@ -443,7 +443,7 @@ namespace BlackMisc
static CCentralMultiSimulatorModelCachesProvider &modelCachesInstance()
{
static CCentralMultiSimulatorModelCachesProvider c("Central model caches provider");
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(&c), Q_FUNC_INFO, "Wrong thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(&c), Q_FUNC_INFO, "Wrong thread");
return c;
}
@@ -496,7 +496,7 @@ namespace BlackMisc
static CCentralMultiSimulatorModelSetCachesProvider &modelCachesInstance()
{
static CCentralMultiSimulatorModelSetCachesProvider c("Central model sets provider");
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(&c), Q_FUNC_INFO, "Wrong thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(&c), Q_FUNC_INFO, "Wrong thread");
return c;
}

View File

@@ -19,12 +19,12 @@
namespace BlackMisc
{
bool CThreadUtils::isCurrentThreadObjectThread(const QObject *toBeTested)
bool CThreadUtils::isInThisThread(const QObject *toBeTested)
{
return QThread::currentThread() == toBeTested->thread();
}
bool CThreadUtils::isCurrentThreadApplicationThread()
bool CThreadUtils::thisIsMainThread()
{
return qApp && QThread::currentThread() == qApp->thread();
}

View File

@@ -27,10 +27,14 @@ namespace BlackMisc
CThreadUtils() = delete;
//! Is the current thread the object's thread?
static bool isCurrentThreadObjectThread(const QObject *toBeTested);
//! \deprecated
//! \todo Refactor to inline method
static bool isInThisThread(const QObject *toBeTested);
//! Is the current thread the application thread?
static bool isCurrentThreadApplicationThread();
//! \deprecated
//! \todo Refactor to inline method
static bool thisIsMainThread();
//! Info about current thread, for debug messages
static QString currentThreadInfo();

View File

@@ -163,7 +163,7 @@ namespace BlackMisc
if (hasStarted()) { return; }
// avoid message "QObject: Cannot create children for a parent that is in a different thread"
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(m_owner), Q_FUNC_INFO, "Needs to be started in owner thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(m_owner), Q_FUNC_INFO, "Needs to be started in owner thread");
emit this->aboutToStart();
setStarted();
auto *thread = new CRegularThread(m_owner);
@@ -203,7 +203,7 @@ namespace BlackMisc
if (this->thread() == m_owner->thread()) { return; }
// called by own thread, will deadlock, return
if (CThreadUtils::isCurrentThreadObjectThread(this)) { return; }
if (CThreadUtils::isInThisThread(this)) { return; }
QThread *workerThread = thread(); // must be before quit()
this->quit();
@@ -224,7 +224,7 @@ namespace BlackMisc
void CContinuousWorker::startUpdating(int updateTimeSecs)
{
Q_ASSERT_X(this->hasStarted(), Q_FUNC_INFO, "Worker not yet started");
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
// shift in correct thread
QPointer<CContinuousWorker> myself(this);
@@ -254,7 +254,7 @@ namespace BlackMisc
if (!m_updateTimer.isActive()) { return; }
// avoid "Timers cannot be stopped from another thread"
if (CThreadUtils::isCurrentThreadObjectThread(&m_updateTimer))
if (CThreadUtils::isInThisThread(&m_updateTimer))
{
m_updateTimer.stop();
}