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

@@ -738,7 +738,7 @@ namespace BlackCore
bool CAfvClient::setInputVolumeDb(double valueDb)
{
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
// call in background thread of AFVClient to avoid lock issues
QPointer<CAfvClient> myself(this);
@@ -986,7 +986,7 @@ namespace BlackCore
this->stopAudio();
this->disconnectFrom();
this->quitAndWait();
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Needs to be back in current thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "Needs to be back in current thread");
}
void CAfvClient::initialize()
@@ -1398,7 +1398,7 @@ namespace BlackCore
bool CAfvClient::setOutputVolumeDb(double valueDb)
{
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
// call in background thread of AFVClient to avoid lock issues
QPointer<CAfvClient> myself(this);

View File

@@ -219,7 +219,7 @@ namespace BlackCore
void CAirspaceAnalyzer::analyzeAirspace()
{
Q_ASSERT_X(!CThreadUtils::isCurrentThreadApplicationThread(), Q_FUNC_INFO, "Expect to run in background thread");
Q_ASSERT_X(!CThreadUtils::thisIsMainThread(), Q_FUNC_INFO, "Expect to run in background thread");
Q_ASSERT_X(thread() != qApp->thread(), Q_FUNC_INFO, "Expect to run in background thread affinity");
bool restricted, enabled;

View File

@@ -562,7 +562,7 @@ namespace BlackCore
void CAirspaceMonitor::onReceivedAtcBookings(const CAtcStationList &bookedStations)
{
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
Q_ASSERT(CThreadUtils::isInThisThread(this));
if (bookedStations.isEmpty())
{
m_atcStationsBooked.clear();
@@ -592,7 +592,7 @@ namespace BlackCore
void CAirspaceMonitor::onReceivedVatsimDataFile()
{
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
Q_ASSERT(CThreadUtils::isInThisThread(this));
if (!sApp || sApp->isShuttingDown() || !sApp->getWebDataServices()) { return; }
CClientList clients(this->getClients()); // copy
bool changed = false;
@@ -731,7 +731,7 @@ namespace BlackCore
void CAirspaceMonitor::onAtcPositionUpdate(const CCallsign &callsign, const CFrequency &frequency, const CCoordinateGeodetic &position, const BlackMisc::PhysicalQuantities::CLength &range)
{
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "wrong thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "wrong thread");
if (!this->isConnectedAndNotShuttingDown()) { return; }
const CAtcStationList stationsWithCallsign = m_atcStationsOnline.findByCallsign(callsign);
@@ -780,7 +780,7 @@ namespace BlackCore
void CAirspaceMonitor::onAtcControllerDisconnected(const CCallsign &callsign)
{
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
Q_ASSERT(CThreadUtils::isInThisThread(this));
if (!this->isConnectedAndNotShuttingDown()) { return; }
this->removeClient(callsign);
@@ -798,7 +798,7 @@ namespace BlackCore
void CAirspaceMonitor::onAtisReceived(const CCallsign &callsign, const CInformationMessage &atisMessage)
{
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
Q_ASSERT(CThreadUtils::isInThisThread(this));
if (!this->isConnectedAndNotShuttingDown() || callsign.isEmpty()) return;
const bool changedAtis = m_atcStationsOnline.updateIfMessageChanged(atisMessage, callsign, true);
@@ -811,7 +811,7 @@ namespace BlackCore
void CAirspaceMonitor::onAtisLogoffTimeReceived(const CCallsign &callsign, const QString &zuluTime)
{
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
Q_ASSERT(CThreadUtils::isInThisThread(this));
if (!this->isConnectedAndNotShuttingDown()) { return; }
if (zuluTime.length() == 4)
@@ -837,7 +837,7 @@ namespace BlackCore
// ES sends FsInn packets for callsigns such as ACCGER1, which are hard to distinguish
// 1) checking if they are already in the list checks again ATC position which is safe
// 2) the ATC alike callsign check is guessing
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "not in main thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "not in main thread");
if (!callsign.isValid()) { return; } // aircraft OBS, other invalid callsigns
if (!this->isConnectedAndNotShuttingDown()) { return; }
@@ -899,7 +899,7 @@ namespace BlackCore
void CAirspaceMonitor::onIcaoCodesReceived(const CCallsign &callsign, const QString &aircraftIcaoDesignator, const QString &airlineIcaoDesignator, const QString &livery)
{
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "not in main thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "not in main thread");
if (!this->isConnectedAndNotShuttingDown()) { return; }
if (CBuildConfig::isLocalDeveloperDebugBuild()) { BLACK_VERIFY_X(callsign.isValid(), Q_FUNC_INFO, "invalid callsign"); }
if (!callsign.isValid()) { return; }
@@ -1217,7 +1217,7 @@ namespace BlackCore
void CAirspaceMonitor::onAircraftUpdateReceived(const CAircraftSituation &situation, const CTransponder &transponder)
{
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Called in different thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "Called in different thread");
if (!this->isConnectedAndNotShuttingDown()) { return; }
const CCallsign callsign(situation.getCallsign());
@@ -1267,7 +1267,7 @@ namespace BlackCore
void CAirspaceMonitor::onAircraftInterimUpdateReceived(const CAircraftSituation &situation)
{
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Called in different thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "Called in different thread");
if (!this->isConnectedAndNotShuttingDown()) { return; }
const CCallsign callsign(situation.getCallsign());
@@ -1329,7 +1329,7 @@ namespace BlackCore
void CAirspaceMonitor::onPilotDisconnected(const CCallsign &callsign)
{
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
Q_ASSERT(CThreadUtils::isInThisThread(this));
// in case of inconsistencies I always remove here
this->removeFromAircraftCachesAndLogs(callsign);
@@ -1340,7 +1340,7 @@ namespace BlackCore
void CAirspaceMonitor::onFrequencyReceived(const CCallsign &callsign, const CFrequency &frequency)
{
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
Q_ASSERT(CThreadUtils::isInThisThread(this));
// update
const CPropertyIndexVariantMap vm({CSimulatedAircraft::IndexCom1System, CComSystem::IndexActiveFrequency}, CVariant::from(frequency));
@@ -1350,7 +1350,7 @@ namespace BlackCore
void CAirspaceMonitor::onRevBAircraftConfigReceived(const CCallsign &callsign, const QString &config, qint64 currentOffsetMs)
{
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
Q_ASSERT(CThreadUtils::isInThisThread(this));
BLACK_AUDIT_X(!callsign.isEmpty(), Q_FUNC_INFO, "Need callsign");
if (callsign.isEmpty()) { return; }
@@ -1410,7 +1410,7 @@ namespace BlackCore
void CAirspaceMonitor::onAircraftConfigReceived(const CCallsign &callsign, const QJsonObject &jsonObject, qint64 currentOffsetMs)
{
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
Q_ASSERT(CThreadUtils::isInThisThread(this));
BLACK_AUDIT_X(!callsign.isEmpty(), Q_FUNC_INFO, "Need callsign");
if (callsign.isEmpty()) { return; }

View File

@@ -1769,7 +1769,7 @@ namespace BlackCore
{
// should be now in QAM thread
if (!sApp || sApp->isShuttingDown()) { return; }
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(sApp->m_accessManager), Q_FUNC_INFO, "Wrong thread, must be QAM thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(sApp->m_accessManager), Q_FUNC_INFO, "Wrong thread, must be QAM thread");
this->httpRequestImpl(request, logId, callback, progress, maxRedirects, getPostOrDeleteRequest);
});
}
@@ -1782,7 +1782,7 @@ namespace BlackCore
{
// should be now in QAM thread
if (!sApp || sApp->isShuttingDown()) { return; }
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(sApp->m_accessManager), Q_FUNC_INFO, "Wrong thread, must be QAM thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(sApp->m_accessManager), Q_FUNC_INFO, "Wrong thread, must be QAM thread");
const QNetworkAccessManager::NetworkAccessibility accessibility = m_accessManager->networkAccessible();
m_networkWatchDog->setNetworkAccessibility(accessibility);
});
@@ -1805,13 +1805,13 @@ namespace BlackCore
QWriteLocker locker(&m_accessManagerLock);
Q_ASSERT_X(m_accessManager->thread() == qApp->thread(), Q_FUNC_INFO, "Network manager supposed to be in main thread");
if (!CThreadUtils::isCurrentThreadObjectThread(m_accessManager))
if (!CThreadUtils::isInThisThread(m_accessManager))
{
this->httpRequestImplInQAMThread(request, logId, callback, progress, maxRedirects, getPostOrDeleteRequest);
return nullptr; // not yet started, will be called again in QAM thread
}
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(m_accessManager), Q_FUNC_INFO, "Network manager thread mismatch");
Q_ASSERT_X(CThreadUtils::isInThisThread(m_accessManager), Q_FUNC_INFO, "Network manager thread mismatch");
QNetworkRequest copiedRequest = CNetworkUtils::getSwiftNetworkRequest(request, this->getApplicationNameAndVersion());
// If URL is one of the shared URLs, add swift client SSL certificate to request

View File

@@ -217,7 +217,7 @@ namespace BlackCore
if (m_voiceClient)
{
m_voiceClient->gracefulShutdown();
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(m_voiceClient), Q_FUNC_INFO, "Needs to be back in current thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(m_voiceClient), Q_FUNC_INFO, "Needs to be back in current thread");
m_voiceClient->deleteLater();
m_voiceClient = nullptr;
#ifdef Q_OS_WIN

View File

@@ -461,7 +461,7 @@ namespace BlackCore
Q_ASSERT(this->getIContextApplication());
Q_ASSERT(this->getIContextApplication()->isUsingImplementingObject());
Q_ASSERT(!simulatorPluginInfo.isUnspecified());
Q_ASSERT(CThreadUtils::isCurrentThreadApplicationThread()); // only run in main thread
Q_ASSERT(CThreadUtils::thisIsMainThread()); // only run in main thread
// Is a plugin already loaded?
if (!m_simulatorPlugin.first.isUnspecified())

View File

@@ -619,7 +619,7 @@ namespace BlackCore
const bool overrideNewerOnly = true;
entities = this->maskBySupportedEntities(entities);
if (inBackground || !CThreadUtils::isCurrentThreadObjectThread(this))
if (inBackground || !CThreadUtils::isInThisThread(this))
{
const bool s = this->readFromJsonFilesInBackground(CDirectoryUtils::staticDbFilesDirectory(), entities, overrideNewerOnly);
return s ?

View File

@@ -234,7 +234,7 @@ namespace BlackCore
if (m_disableNetworkCheck) { return; } // ignore with disabled check
// shift to thread
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
QPointer<CNetworkWatchdog> myself(this);
QTimer::singleShot(0, this, [ = ]
@@ -315,7 +315,7 @@ namespace BlackCore
nw->close();
if (!sApp || sApp->isShuttingDown()) { return; }
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Wrong thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "Wrong thread");
m_lastClientPingSuccess = ok;
{

View File

@@ -225,7 +225,7 @@ namespace BlackCore
void CFSDClient::connectToServer()
{
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
QMetaObject::invokeMethod(this, [ = ]
{
@@ -265,7 +265,7 @@ namespace BlackCore
void CFSDClient::disconnectFromServer()
{
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
QMetaObject::invokeMethod(this, [ = ]
{
@@ -441,7 +441,7 @@ namespace BlackCore
void CFSDClient::sendClientQuery(ClientQueryType queryType, const CCallsign &receiver, const QStringList &queryData)
{
if (queryType == ClientQueryType::Unknown) { return; }
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
QMetaObject::invokeMethod(this, [ = ]
{
@@ -514,7 +514,7 @@ namespace BlackCore
void CFSDClient::sendTextMessages(const CTextMessageList &messages)
{
if (messages.isEmpty()) { return; }
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
QMetaObject::invokeMethod(this, [ = ]
{
@@ -565,7 +565,7 @@ namespace BlackCore
void CFSDClient::sendTextMessage(TextMessageGroups receiverGroup, const QString &message)
{
if (message.isEmpty()) { return; }
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
QMetaObject::invokeMethod(this, [ = ]
{
@@ -614,7 +614,7 @@ namespace BlackCore
void CFSDClient::sendFlightPlan(const CFlightPlan &flightPlan)
{
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
QMetaObject::invokeMethod(this, [ = ]
{
@@ -671,7 +671,7 @@ namespace BlackCore
void CFSDClient::sendPlaneInfoRequest(const CCallsign &receiver)
{
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
QMetaObject::invokeMethod(this, [ = ]
{
@@ -687,7 +687,7 @@ namespace BlackCore
void CFSDClient::sendPlaneInfoRequestFsinn(const CCallsign &callsign)
{
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
QMetaObject::invokeMethod(this, [ = ]
{

View File

@@ -343,7 +343,7 @@ namespace BlackCore
void ISimulator::safeKillTimer()
{
if (m_timerId < 0) { return; }
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;
}
@@ -816,7 +816,7 @@ namespace BlackCore
// when changing back from restricted->unrestricted an one time update is required
if (!snapshot.isRestricted() && !snapshot.isRestrictionChanged()) { return; }
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Needs to run in object thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "Needs to run in object thread");
Q_ASSERT_X(snapshot.generatingThreadName() != QThread::currentThread()->objectName(), Q_FUNC_INFO, "Expect snapshot from background thread");
// restricted snapshot values?
@@ -1464,7 +1464,7 @@ namespace BlackCore
void ISimulatorListener::start()
{
if (m_isRunning) { return; }
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
// call in correct thread
QPointer<ISimulatorListener> myself(this);
@@ -1479,7 +1479,7 @@ namespace BlackCore
void ISimulatorListener::stop()
{
if (!m_isRunning) { return; }
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
// call in correct thread
QPointer<ISimulatorListener> myself(this);
@@ -1494,7 +1494,7 @@ namespace BlackCore
void ISimulatorListener::check()
{
if (!m_isRunning) { return; }
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
// call in correct thread
QPointer<ISimulatorListener> myself(this);

View File

@@ -167,7 +167,7 @@ namespace BlackCore
if (!this->isEnabled()) { return false; }
// MS 2019-02-23 isAbandoned() check only makes sense when called by worker thread (T541)
if (CThreadUtils::isCurrentThreadObjectThread(this) && this->isAbandoned()) { return false; }
if (CThreadUtils::isInThisThread(this) && this->isAbandoned()) { return false; }
if (!m_unitTest && (!sApp || sApp->isShuttingDown())) { return false; }
return true;

View File

@@ -1012,7 +1012,7 @@ namespace BlackCore
void CWebDataServices::initReaders(CWebReaderFlags::WebReader readersNeeded, CEntityFlags::Entity entities)
{
Q_ASSERT_X(CThreadUtils::isCurrentThreadApplicationThread(), Q_FUNC_INFO, "shall run in main application thread");
Q_ASSERT_X(CThreadUtils::thisIsMainThread(), Q_FUNC_INFO, "shall run in main application thread");
//
// ---- "metadata" reader, 1 will trigger read directly during init
@@ -1173,7 +1173,7 @@ namespace BlackCore
{
// run in correct thread
if (m_shuttingDown) { return; }
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
const QPointer<CWebDataServices> myself(this);
QTimer::singleShot(0, this, [ = ]
@@ -1215,7 +1215,7 @@ namespace BlackCore
{
// run in correct thread
if (m_shuttingDown) { return; }
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
const QPointer<CWebDataServices> myself(this);
QTimer::singleShot(0, this, [ = ]
@@ -1582,7 +1582,7 @@ namespace BlackCore
if (m_icaoDataReader)
{
// force update to background reading if reader is already in another thread
bool ib = inBackground || !CThreadUtils::isCurrentThreadObjectThread(m_icaoDataReader);
bool ib = inBackground || !CThreadUtils::isInThisThread(m_icaoDataReader);
if (ib)
{
CLogMessage(this).info(u"Reading from disk in background: %1") << m_icaoDataReader->getSupportedEntitiesAsString();
@@ -1600,7 +1600,7 @@ namespace BlackCore
if (m_modelDataReader)
{
// force update to background reading if reader is already in another thread
bool ib = inBackground || !CThreadUtils::isCurrentThreadObjectThread(m_modelDataReader);
bool ib = inBackground || !CThreadUtils::isInThisThread(m_modelDataReader);
if (ib)
{
CLogMessage(this).info(u"Reading from disk in background: %1") << m_modelDataReader->getSupportedEntitiesAsString();
@@ -1618,7 +1618,7 @@ namespace BlackCore
if (m_airportDataReader)
{
// force update to background reading if reader is already in another thread
bool ib = inBackground || !CThreadUtils::isCurrentThreadObjectThread(m_airportDataReader);
bool ib = inBackground || !CThreadUtils::isInThisThread(m_airportDataReader);
if (ib)
{
CLogMessage(this).info(u"Reading from disk in background: %1") << m_airportDataReader->getSupportedEntitiesAsString();

View File

@@ -1384,7 +1384,7 @@ namespace BlackGui
// changing widget style is slow, so I try to prevent setting it when nothing changed
const QString widgetStyle = m_guiSettings.get().getWidgetStyle();
const QString currentWidgetStyle(this->getWidgetStyle());
Q_ASSERT_X(CThreadUtils::isCurrentThreadApplicationThread(), Q_FUNC_INFO, "Wrong thread");
Q_ASSERT_X(CThreadUtils::thisIsMainThread(), Q_FUNC_INFO, "Wrong thread");
if (!stringCompare(widgetStyle, currentWidgetStyle, Qt::CaseInsensitive))
{
const QStringList availableStyles = QStyleFactory::keys();

View File

@@ -92,7 +92,7 @@ namespace BlackGui
m_pendingIds.clear();
if (m_timerId != -1)
{
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;
@@ -106,7 +106,7 @@ namespace BlackGui
m_delayMs = delay;
if (m_timerId != -1)
{
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 = this->startTimer(m_delayMs);

View File

@@ -41,7 +41,7 @@ namespace BlackGui
void CAircraftCategoryTreeModel::updateContainer(const CAircraftCategoryList &categories)
{
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Wrong thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "Wrong thread");
this->clear();
if (categories.isEmpty()) { return; }

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();
}

View File

@@ -501,7 +501,7 @@ namespace BlackSimPlugin
if (this->isShuttingDownOrDisconnected()) { return false; }
// entry checks
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "thread");
Q_ASSERT_X(!newRemoteAircraft.getCallsign().isEmpty(), Q_FUNC_INFO, "empty callsign");
Q_ASSERT_X(newRemoteAircraft.hasModelString(), Q_FUNC_INFO, "missing model string");
@@ -557,7 +557,7 @@ namespace BlackSimPlugin
if (this->isShuttingDownOrDisconnected()) { return false; }
// only remove from sim
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "wrong thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "wrong thread");
if (callsign.isEmpty()) { return false; } // can happen if an object is not an aircraft
// really remove from simulator
@@ -622,7 +622,7 @@ namespace BlackSimPlugin
void CSimulatorFlightgear::updateRemoteAircraft()
{
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "thread");
const int remoteAircraftNo = this->getAircraftInRangeCount();
if (remoteAircraftNo < 1) { return; }
@@ -1042,7 +1042,7 @@ namespace BlackSimPlugin
void CSimulatorFlightgearListener::checkConnection()
{
if (this->isShuttingDown()) { return; }
Q_ASSERT_X(!CThreadUtils::isCurrentThreadApplicationThread(), Q_FUNC_INFO, "Expect to run in background");
Q_ASSERT_X(!CThreadUtils::thisIsMainThread(), Q_FUNC_INFO, "Expect to run in background");
QString dbusAddress = m_fgSswiftBusServerSetting.getThreadLocal();
if (CDBusServer::isSessionOrSystemAddress(dbusAddress))

View File

@@ -515,7 +515,7 @@ namespace BlackSimPlugin
if (this->isShuttingDownOrDisconnected()) { return; }
if (weatherGrid.isEmpty()) { return; }
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
BLACK_VERIFY_X(!CBuildConfig::isLocalDeveloperDebugBuild(), Q_FUNC_INFO, "Wrong thread");
QPointer<CSimulatorFs9> myself(this);

View File

@@ -73,7 +73,7 @@ namespace BlackSimPlugin
bool CFsuipc::open(bool force)
{
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Open not threadsafe");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "Open not threadsafe");
DWORD dwResult;
m_lastErrorMessage = "";
m_lastErrorIndex = 0;
@@ -119,7 +119,7 @@ namespace BlackSimPlugin
void CFsuipc::close()
{
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Open not threadsafe");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "Open not threadsafe");
if (m_opened)
{
CLogMessage(this).info(u"Closing FSUIPC: %1") << m_fsuipcVersion;
@@ -150,7 +150,7 @@ namespace BlackSimPlugin
bool CFsuipc::write(const CSimulatedAircraft &aircraft)
{
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Open not threadsafe");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "Open not threadsafe");
if (!this->isOpened()) { return false; }
quint16 com1ActiveRaw = static_cast<quint16>(aircraft.getCom1System().getFrequencyActive().value(CFrequencyUnit::MHz()) * 100);
@@ -180,7 +180,7 @@ namespace BlackSimPlugin
bool CFsuipc::write(const CTransponder &xpdr)
{
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Open not threadsafe");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "Open not threadsafe");
if (!this->isOpened()) { return false; }
// should be the same as writing via SimConnect data area
@@ -196,7 +196,7 @@ namespace BlackSimPlugin
bool CFsuipc::write(const CWeatherGrid &weatherGrid)
{
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Open not threadsafe");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "Open not threadsafe");
if (!this->isOpened()) { return false; }
if (weatherGrid.isEmpty()) { return false; }
@@ -333,7 +333,7 @@ namespace BlackSimPlugin
bool CFsuipc::setSimulatorTime(int hour, int minute)
{
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Open not threadsafe");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "Open not threadsafe");
if (!this->isOpened()) { return false; }
// should be the same as writing via SimConnect data area
@@ -355,7 +355,7 @@ namespace BlackSimPlugin
bool CFsuipc::read(CSimulatedAircraft &aircraft, bool cockpit, bool situation, bool aircraftParts)
{
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "Open not threadsafe");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "Open not threadsafe");
DWORD dwResult = 0;
char localFsTimeRaw[3];
char modelNameRaw[256];

View File

@@ -1513,7 +1513,7 @@ namespace BlackSimPlugin
const bool probe = newRemoteAircraft.isTerrainProbe();
// entry checks
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "thread");
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "empty callsign");
Q_ASSERT_X(newRemoteAircraft.hasModelString(), Q_FUNC_INFO, "missing model string");
@@ -1701,7 +1701,7 @@ namespace BlackSimPlugin
{
if (coordinate.isNull()) { return false; }
if (!this->isUsingFsxTerrainProbe()) { return false; }
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "thread");
// static const QString modelString("OrcaWhale");
// static const QString modelString("Water Drop"); // not working on P3Dx86/FSX, no requests on that id possible
@@ -1745,7 +1745,7 @@ namespace BlackSimPlugin
bool CSimulatorFsxCommon::physicallyRemoveRemoteAircraft(const CCallsign &callsign)
{
// only remove from sim
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "wrong thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "wrong thread");
if (callsign.isEmpty()) { return false; } // can happen if an object is not an aircraft
// clean up anyway
@@ -1939,7 +1939,7 @@ namespace BlackSimPlugin
void CSimulatorFsxCommon::updateRemoteAircraft()
{
static_assert(sizeof(DataDefinitionRemoteAircraftPartsWithoutLights) == sizeof(double) * 10, "DataDefinitionRemoteAircraftPartsWithoutLights has an incorrect size.");
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "thread");
// Freeze interpolation while paused
if (this->isPaused() && m_pausedSimFreezesInterpolation) { return; }
@@ -2395,7 +2395,7 @@ namespace BlackSimPlugin
if (this->isShuttingDownOrDisconnected()) { return; }
if (weatherGrid.isEmpty()) { return; }
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
BLACK_VERIFY_X(!CBuildConfig::isLocalDeveloperDebugBuild(), Q_FUNC_INFO, "Wrong thread");
QPointer<CSimulatorFsxCommon> myself(this);
@@ -2841,7 +2841,7 @@ namespace BlackSimPlugin
void CSimulatorFsxCommonListener::checkConnection()
{
Q_ASSERT_X(!CThreadUtils::isCurrentThreadApplicationThread(), Q_FUNC_INFO, "Expect to run in background");
Q_ASSERT_X(!CThreadUtils::thisIsMainThread(), Q_FUNC_INFO, "Expect to run in background");
// check before we access the sim. connection
if (this->isShuttingDown() || this->thread()->isInterruptionRequested())

View File

@@ -108,7 +108,7 @@ namespace BlackSimPlugin
if (this->isShuttingDown()) { return false; }
if (!this->isConnected()) { return false; }
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "thread");
const bool hasHeight = reference.hasMSLGeodeticHeight();
const double latDeg = reference.latitude().value(CAngleUnit::deg());
const double lngDeg = reference.longitude().value(CAngleUnit::deg());

View File

@@ -765,7 +765,7 @@ namespace BlackSimPlugin
if (this->isShuttingDownOrDisconnected()) { return false; }
// entry checks
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "thread");
Q_ASSERT_X(!newRemoteAircraft.getCallsign().isEmpty(), Q_FUNC_INFO, "empty callsign");
Q_ASSERT_X(newRemoteAircraft.hasModelString(), Q_FUNC_INFO, "missing model string");
@@ -823,7 +823,7 @@ namespace BlackSimPlugin
if (this->isShuttingDownOrDisconnected()) { return false; }
// only remove from sim
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "wrong thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "wrong thread");
if (callsign.isEmpty()) { return false; } // can happen if an object is not an aircraft
// really remove from simulator
@@ -901,7 +901,7 @@ namespace BlackSimPlugin
if (weatherGrid.isEmpty()) { return; }
if (!this->isWeatherActivated()) { return; }
if (!CThreadUtils::isCurrentThreadObjectThread(this))
if (!CThreadUtils::isInThisThread(this))
{
BLACK_VERIFY_X(!CBuildConfig::isLocalDeveloperDebugBuild(), Q_FUNC_INFO, "Wrong thread");
@@ -1003,7 +1003,7 @@ namespace BlackSimPlugin
void CSimulatorXPlane::updateRemoteAircraft()
{
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "thread");
Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "thread");
const int remoteAircraftNo = this->getAircraftInRangeCount();
if (remoteAircraftNo < 1) { return; }
@@ -1467,7 +1467,7 @@ namespace BlackSimPlugin
void CSimulatorXPlaneListener::checkConnection()
{
if (this->isShuttingDown()) { return; }
Q_ASSERT_X(!CThreadUtils::isCurrentThreadApplicationThread(), Q_FUNC_INFO, "Expect to run in background");
Q_ASSERT_X(!CThreadUtils::thisIsMainThread(), Q_FUNC_INFO, "Expect to run in background");
QElapsedTimer t; t.start();
QString via;

View File

@@ -112,7 +112,7 @@ void SwiftGuiStd::performGracefulShutdown()
if (!m_init) { return; }
m_init = false;
Q_ASSERT_X(CThreadUtils::isCurrentThreadApplicationThread(), Q_FUNC_INFO, "Should shutdown in main thread");
Q_ASSERT_X(CThreadUtils::thisIsMainThread(), Q_FUNC_INFO, "Should shutdown in main thread");
// shut down all timers
this->stopAllTimers(true);
@@ -519,7 +519,7 @@ void SwiftGuiStd::checkDbDataLoaded()
{
if (!sGui || sGui->isShuttingDown()) { return; }
Q_ASSERT_X(sGui->hasWebDataServices(), Q_FUNC_INFO, "Missing web services");
Q_ASSERT_X(CThreadUtils::isCurrentThreadApplicationThread(), Q_FUNC_INFO, "Wrong thread, needs to run in main thread");
Q_ASSERT_X(CThreadUtils::thisIsMainThread(), Q_FUNC_INFO, "Wrong thread, needs to run in main thread");
const CEntityFlags::Entity loadEntities = sGui->getWebDataServices()->getSynchronizedEntitiesWithNewerSharedFileOrEmpty(!m_dbDataLoading);
if (loadEntities == CEntityFlags::NoEntity)
{