From 9bef6854ca9853db6fc2452acb9a072714cb6699 Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Mon, 6 Jun 2016 15:47:11 +0100 Subject: [PATCH] Caches: rename "get" to "getThreadLocal" and rename "getCopy" to get. --- src/blackcore/contextaudioimpl.cpp | 2 +- src/blackcore/contextownaircraftimpl.cpp | 2 +- src/blackcore/contextsimulatorimpl.cpp | 2 +- src/blackcore/corefacade.cpp | 2 +- src/blackcore/db/icaodatareader.cpp | 16 ++++++------- src/blackcore/db/modeldatareader.cpp | 16 ++++++------- src/blackcore/inputmanager.cpp | 2 +- src/blackcore/networkvatlib.cpp | 2 +- src/blackcore/setupreader.cpp | 10 ++++---- src/blackcore/vatsimdatafilereader.cpp | 6 ++--- src/blackcore/vatsimstatusfilereader.cpp | 6 ++--- .../components/audiosetupcomponent.cpp | 2 +- .../components/dbdebugdatabasesetup.cpp | 2 +- .../components/dbownmodelscomponent.cpp | 2 +- .../components/dbownmodelsetcomponent.cpp | 4 ++-- .../distributorpreferencescomponent.cpp | 6 ++--- src/blackgui/components/logincomponent.cpp | 4 ++-- .../components/settingshotkeycomponent.cpp | 8 +++---- .../settingsnetworkserverscomponent.cpp | 4 ++-- .../components/settingssimulatorcomponent.cpp | 4 ++-- src/blackgui/dockwidget.cpp | 6 ++--- src/blackgui/editors/form.cpp | 2 +- src/blackgui/editors/ownmodelsetform.cpp | 4 ++-- src/blackmisc/simulation/data/modelcaches.cpp | 24 +++++++++---------- src/blackmisc/simulation/data/modelcaches.h | 4 ++-- .../simulation/fscommon/vpilotrulesreader.cpp | 6 ++--- src/blackmisc/valuecache.h | 4 ++-- .../simulator/xplane/simulatorxplane.cpp | 6 ++--- .../simulatorxplaneconfigwindow.cpp | 4 ++-- src/swiftlauncher/swiftlauncher.cpp | 4 ++-- 30 files changed, 83 insertions(+), 83 deletions(-) diff --git a/src/blackcore/contextaudioimpl.cpp b/src/blackcore/contextaudioimpl.cpp index d72f65afd..577111974 100644 --- a/src/blackcore/contextaudioimpl.cpp +++ b/src/blackcore/contextaudioimpl.cpp @@ -419,7 +419,7 @@ namespace BlackCore Q_ASSERT(this->m_voice); if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << notification; } - bool play = !considerSettings || m_audioSettings.get().getNotificationFlag(notification); + bool play = !considerSettings || m_audioSettings.getThreadLocal().getNotificationFlag(notification); if (play) { CSoundGenerator::playNotificationSound(90, notification); diff --git a/src/blackcore/contextownaircraftimpl.cpp b/src/blackcore/contextownaircraftimpl.cpp index fc79d63c7..7a783c8b1 100644 --- a/src/blackcore/contextownaircraftimpl.cpp +++ b/src/blackcore/contextownaircraftimpl.cpp @@ -110,7 +110,7 @@ namespace BlackCore CAltitude(312, CAltitude::MeanSeaLevel, CLengthUnit::ft()) ); this->m_ownAircraft.setSituation(situation); - this->m_ownAircraft.setPilot(this->m_currentNetworkServer.get().getUser()); + this->m_ownAircraft.setPilot(this->m_currentNetworkServer.getThreadLocal().getUser()); // from simulator, if available this->m_ownAircraft.setCallsign(CCallsign("SWIFT")); // would come from settings diff --git a/src/blackcore/contextsimulatorimpl.cpp b/src/blackcore/contextsimulatorimpl.cpp index ceadfa8ea..a13d54ee9 100644 --- a/src/blackcore/contextsimulatorimpl.cpp +++ b/src/blackcore/contextsimulatorimpl.cpp @@ -576,7 +576,7 @@ namespace BlackCore { stopSimulatorListeners(); - auto enabledSimulators = m_enabledSimulators.get(); + auto enabledSimulators = m_enabledSimulators.getThreadLocal(); auto allSimulators = m_plugins->getAvailableSimulatorPlugins(); for (const CSimulatorPluginInfo& s: allSimulators) { diff --git a/src/blackcore/corefacade.cpp b/src/blackcore/corefacade.cpp index f0604806b..dab061e82 100644 --- a/src/blackcore/corefacade.cpp +++ b/src/blackcore/corefacade.cpp @@ -66,7 +66,7 @@ namespace BlackCore } else { - dbusAddress = m_dbusServerAddress.get(); + dbusAddress = m_dbusServerAddress.getThreadLocal(); } // DBus diff --git a/src/blackcore/db/icaodatareader.cpp b/src/blackcore/db/icaodatareader.cpp index bf5b7b5d6..bfad70095 100644 --- a/src/blackcore/db/icaodatareader.cpp +++ b/src/blackcore/db/icaodatareader.cpp @@ -47,7 +47,7 @@ namespace BlackCore CAircraftIcaoCodeList CIcaoDataReader::getAircraftIcaoCodes() const { - return m_aircraftIcaoCache.getCopy(); + return m_aircraftIcaoCache.get(); } CAircraftIcaoCode CIcaoDataReader::getAircraftIcaoCodeForDesignator(const QString &designator) const @@ -62,7 +62,7 @@ namespace BlackCore CAirlineIcaoCodeList CIcaoDataReader::getAirlineIcaoCodes() const { - return m_airlineIcaoCache.getCopy(); + return m_airlineIcaoCache.get(); } CAircraftIcaoCode CIcaoDataReader::smartAircraftIcaoSelector(const CAircraftIcaoCode &icaoPattern) const @@ -73,7 +73,7 @@ namespace BlackCore CCountryList CIcaoDataReader::getCountries() const { - return m_countryCache.getCopy(); + return m_countryCache.get(); } CCountry CIcaoDataReader::getCountryForIsoCode(const QString &isoCode) const @@ -201,7 +201,7 @@ namespace BlackCore void CIcaoDataReader::updateReaderUrl(const CUrl &url) { - const CUrl current = this->m_readerUrlCache.getCopy(); + const CUrl current = this->m_readerUrlCache.get(); if (current == url) { return; } const CStatusMessage m = this->m_readerUrlCache.set(url); if (m.isFailure()) @@ -420,9 +420,9 @@ namespace BlackCore { switch (entity) { - case CEntityFlags::AircraftIcaoEntity: return this->m_aircraftIcaoCache.getCopy().size(); - case CEntityFlags::AirlineIcaoEntity: return this->m_airlineIcaoCache.getCopy().size(); - case CEntityFlags::CountryEntity: return this->m_countryCache.getCopy().size(); + case CEntityFlags::AircraftIcaoEntity: return this->m_aircraftIcaoCache.get().size(); + case CEntityFlags::AirlineIcaoEntity: return this->m_airlineIcaoCache.get().size(); + case CEntityFlags::CountryEntity: return this->m_countryCache.get().size(); default: return 0; } } @@ -430,7 +430,7 @@ namespace BlackCore bool CIcaoDataReader::hasChangedUrl(CEntityFlags::Entity entity) const { Q_UNUSED(entity); - return CDatabaseReader::isChangedUrl(this->m_readerUrlCache.getCopy(), this->getBaseUrl()); + return CDatabaseReader::isChangedUrl(this->m_readerUrlCache.get(), this->getBaseUrl()); } CUrl CIcaoDataReader::getAircraftIcaoUrl(bool shared) const diff --git a/src/blackcore/db/modeldatareader.cpp b/src/blackcore/db/modeldatareader.cpp index fbf3d3541..dfdf52ca5 100644 --- a/src/blackcore/db/modeldatareader.cpp +++ b/src/blackcore/db/modeldatareader.cpp @@ -47,7 +47,7 @@ namespace BlackCore CLiveryList CModelDataReader::getLiveries() const { - return this->m_liveryCache.getCopy(); + return this->m_liveryCache.get(); } CLivery CModelDataReader::getLiveryForCombinedCode(const QString &combinedCode) const @@ -79,12 +79,12 @@ namespace BlackCore CDistributorList CModelDataReader::getDistributors() const { - return m_distributorCache.getCopy(); + return m_distributorCache.get(); } CAircraftModelList CModelDataReader::getModels() const { - return m_modelCache.getCopy(); + return m_modelCache.get(); } CAircraftModel CModelDataReader::getModelForModelString(const QString &modelString) const @@ -231,7 +231,7 @@ namespace BlackCore void CModelDataReader::updateReaderUrl(const CUrl &url) { - const CUrl current = this->m_readerUrlCache.getCopy(); + const CUrl current = this->m_readerUrlCache.get(); if (current == url) { return; } const CStatusMessage m = this->m_readerUrlCache.set(url); if (m.isFailure()) @@ -489,9 +489,9 @@ namespace BlackCore { switch (entity) { - case CEntityFlags::LiveryEntity: return this->m_liveryCache.getCopy().size(); - case CEntityFlags::ModelEntity: return this->m_modelCache.getCopy().size(); - case CEntityFlags::DistributorEntity: return this->m_distributorCache.getCopy().size(); + case CEntityFlags::LiveryEntity: return this->m_liveryCache.get().size(); + case CEntityFlags::ModelEntity: return this->m_modelCache.get().size(); + case CEntityFlags::DistributorEntity: return this->m_distributorCache.get().size(); default: return 0; } } @@ -499,7 +499,7 @@ namespace BlackCore bool CModelDataReader::hasChangedUrl(CEntityFlags::Entity entity) const { Q_UNUSED(entity); - return CDatabaseReader::isChangedUrl(this->m_readerUrlCache.getCopy(), this->getBaseUrl()); + return CDatabaseReader::isChangedUrl(this->m_readerUrlCache.get(), this->getBaseUrl()); } const CUrl &CModelDataReader::getBaseUrl() diff --git a/src/blackcore/inputmanager.cpp b/src/blackcore/inputmanager.cpp index 9683d9d73..2a8278e15 100644 --- a/src/blackcore/inputmanager.cpp +++ b/src/blackcore/inputmanager.cpp @@ -71,7 +71,7 @@ namespace BlackCore void CInputManager::ps_changeHotkeySettings() { m_configuredActions.clear(); - for (CActionHotkey actionHotkey : m_actionHotkeys.get()) + for (CActionHotkey actionHotkey : m_actionHotkeys.getThreadLocal()) { CHotkeyCombination combination = actionHotkey.getCombination(); if (combination.isEmpty()) continue; diff --git a/src/blackcore/networkvatlib.cpp b/src/blackcore/networkvatlib.cpp index c490e9367..3b17052a9 100644 --- a/src/blackcore/networkvatlib.cpp +++ b/src/blackcore/networkvatlib.cpp @@ -75,7 +75,7 @@ namespace BlackCore : INetwork(parent), COwnAircraftAware(ownAircraft), m_loginMode(LoginNormal), m_status(vatStatusIdle), - m_fsdTextCodec(QTextCodec::codecForName(m_fsdTextCodecSetting.get().toLocal8Bit())), + m_fsdTextCodec(QTextCodec::codecForName(m_fsdTextCodecSetting.getThreadLocal().toLocal8Bit())), m_tokenBucket(10, CTime(5, CTimeUnit::s()), 1) { connect(this, &CNetworkVatlib::terminate, this, &INetwork::terminateConnection, Qt::QueuedConnection); diff --git a/src/blackcore/setupreader.cpp b/src/blackcore/setupreader.cpp index d0af731a9..28a44a6ca 100644 --- a/src/blackcore/setupreader.cpp +++ b/src/blackcore/setupreader.cpp @@ -62,7 +62,7 @@ namespace BlackCore } m_setup.synchronize(); // make sure it is loaded - CGlobalSetup cachedSetup = m_setup.getCopy(); + CGlobalSetup cachedSetup = m_setup.get(); const bool cacheAvailable = cachedSetup.wasLoaded(); msgs.push_back(cacheAvailable ? CStatusMessage(this, CStatusMessage::SeverityInfo , "Cached setup syncronized and contains data") : @@ -281,7 +281,7 @@ namespace BlackCore } else { - const CGlobalSetup currentSetup = m_setup.getCopy(); + const CGlobalSetup currentSetup = m_setup.get(); CGlobalSetup loadedSetup; loadedSetup.convertFromJson(Json::jsonObjectFromString(setupJson)); loadedSetup.markAsLoaded(true); @@ -410,12 +410,12 @@ namespace BlackCore CGlobalSetup CSetupReader::getSetup() const { - return m_setup.getCopy(); + return m_setup.get(); } CUpdateInfo CSetupReader::getUpdateInfo() const { - return m_updateInfo.getCopy(); + return m_updateInfo.get(); } CStatusMessageList CSetupReader::manageSetupAvailability(bool webRead, bool localRead) @@ -440,7 +440,7 @@ namespace BlackCore } else { - bool cacheAvailable = this->m_setup.get().wasLoaded(); + bool cacheAvailable = this->m_setup.getThreadLocal().wasLoaded(); available = cacheAvailable && this->m_bootstrapMode != Explicit; } diff --git a/src/blackcore/vatsimdatafilereader.cpp b/src/blackcore/vatsimdatafilereader.cpp index 35f8e31a5..4aa9ac12b 100644 --- a/src/blackcore/vatsimdatafilereader.cpp +++ b/src/blackcore/vatsimdatafilereader.cpp @@ -86,12 +86,12 @@ namespace BlackCore CServerList CVatsimDataFileReader::getVoiceServers() const { - return this->m_lastGoodSetup.getCopy().getVoiceServers(); + return this->m_lastGoodSetup.get().getVoiceServers(); } CServerList CVatsimDataFileReader::getFsdServers() const { - return this->m_lastGoodSetup.getCopy().getFsdServers(); + return this->m_lastGoodSetup.get().getFsdServers(); } CUserList CVatsimDataFileReader::getPilotsForCallsigns(const CCallsignSet &callsigns) @@ -379,7 +379,7 @@ namespace BlackCore this->m_aircraft = aircraft; this->m_atcStations = atcStations; this->m_voiceCapabilities = voiceCapabilities; - CVatsimSetup vs(this->m_lastGoodSetup.get()); + CVatsimSetup vs(this->m_lastGoodSetup.getThreadLocal()); vs.setVoiceServers(voiceServers); vs.setFsdServers(fsdServers); vs.setUtcTimestamp(updateTimestampFromFile); diff --git a/src/blackcore/vatsimstatusfilereader.cpp b/src/blackcore/vatsimstatusfilereader.cpp index 51a00ca52..ad9cad82e 100644 --- a/src/blackcore/vatsimstatusfilereader.cpp +++ b/src/blackcore/vatsimstatusfilereader.cpp @@ -53,12 +53,12 @@ namespace BlackCore CUrlList CVatsimStatusFileReader::getMetarFileUrls() const { - return this->m_lastGoodSetup.getCopy().getMetarFileUrls(); + return this->m_lastGoodSetup.get().getMetarFileUrls(); } CUrlList CVatsimStatusFileReader::getDataFileUrls() const { - return this->m_lastGoodSetup.getCopy().getDataFileUrls(); + return this->m_lastGoodSetup.get().getDataFileUrls(); } void CVatsimStatusFileReader::cleanup() @@ -148,7 +148,7 @@ namespace BlackCore // this part needs to be synchronized { // cache itself is thread safe - CVatsimSetup vs(this->m_lastGoodSetup.getCopy()); + CVatsimSetup vs(this->m_lastGoodSetup.get()); vs.setDataFileUrls(dataFiles); vs.setMetarFileUrls(metarFiles); vs.setServerFileUrls(serverFiles); diff --git a/src/blackgui/components/audiosetupcomponent.cpp b/src/blackgui/components/audiosetupcomponent.cpp index 2bfefe62c..04708dcda 100644 --- a/src/blackgui/components/audiosetupcomponent.cpp +++ b/src/blackgui/components/audiosetupcomponent.cpp @@ -75,7 +75,7 @@ namespace BlackGui void CAudioSetupComponent::ps_reloadSettings() { - CSettingsAudio as(m_audioSettings.get()); + CSettingsAudio as(m_audioSettings.getThreadLocal()); this->ui->cb_SetupAudioPlayNotificationSounds->setChecked(true); this->ui->cb_SetupAudioNotificationTextMessage->setChecked(as.getNotificationFlag(CNotificationSounds::NotificationTextMessagePrivate)); this->ui->cb_SetupAudioNotificationVoiceRoom->setChecked(as.getNotificationFlag(CNotificationSounds::NotificationVoiceRoomJoined)); diff --git a/src/blackgui/components/dbdebugdatabasesetup.cpp b/src/blackgui/components/dbdebugdatabasesetup.cpp index 79a87ce3b..5beb9e135 100644 --- a/src/blackgui/components/dbdebugdatabasesetup.cpp +++ b/src/blackgui/components/dbdebugdatabasesetup.cpp @@ -43,7 +43,7 @@ namespace BlackGui void CDbDebugDatabaseSetup::ps_debugChanged(bool set) { - CGlobalSetup gs(m_setup.get()); + CGlobalSetup gs(m_setup.getThreadLocal()); gs.setServerDebugFlag(set); m_setup.set(gs); } diff --git a/src/blackgui/components/dbownmodelscomponent.cpp b/src/blackgui/components/dbownmodelscomponent.cpp index 474e7bcfb..023827522 100644 --- a/src/blackgui/components/dbownmodelscomponent.cpp +++ b/src/blackgui/components/dbownmodelscomponent.cpp @@ -48,7 +48,7 @@ namespace BlackGui // should be single simulator or no simulator (default) this->m_simulatorSelection.synchronize(); - const CSimulatorInfo simulator(this->m_simulatorSelection.getCopy()); + const CSimulatorInfo simulator(this->m_simulatorSelection.get()); const bool s = this->initModelLoader(!simulator.isSingleSimulator() ? CSimulatorInfo(CSimulatorInfo::FSX) : simulator); if (s) { diff --git a/src/blackgui/components/dbownmodelsetcomponent.cpp b/src/blackgui/components/dbownmodelsetcomponent.cpp index b232b59fa..8b7e438be 100644 --- a/src/blackgui/components/dbownmodelsetcomponent.cpp +++ b/src/blackgui/components/dbownmodelsetcomponent.cpp @@ -278,7 +278,7 @@ namespace BlackGui void CDbOwnModelSetComponent::ps_distributorPreferencesChanged() { - const CDistributorListPreferences preferences = this->m_distributorPreferences.get(); + const CDistributorListPreferences preferences = this->m_distributorPreferences.getThreadLocal(); const CSimulatorInfo simuulator = preferences.getLastUpdatedSimulator(); if (simuulator.isSingleSimulator()) { @@ -316,7 +316,7 @@ namespace BlackGui { CAircraftModelList modelSet = this->m_modelSetLoader.getAircraftModels(simulator); if (modelSet.isEmpty()) { return; } - const CDistributorListPreferences preferences = this->m_distributorPreferences.get(); + const CDistributorListPreferences preferences = this->m_distributorPreferences.getThreadLocal(); const CDistributorList distributors = preferences.getDistributors(simulator); if (distributors.isEmpty()) { return; } modelSet.updateDistributorOrder(distributors); diff --git a/src/blackgui/components/distributorpreferencescomponent.cpp b/src/blackgui/components/distributorpreferencescomponent.cpp index 13a8e3a6b..32c811b43 100644 --- a/src/blackgui/components/distributorpreferencescomponent.cpp +++ b/src/blackgui/components/distributorpreferencescomponent.cpp @@ -74,7 +74,7 @@ namespace BlackGui { // changed somewhere else const CSimulatorInfo sim(ui->comp_SimulatorSelector->getValue()); - const CDistributorList distributors = this->m_distributorPreferences.get().getDistributors(sim); + const CDistributorList distributors = this->m_distributorPreferences.getThreadLocal().getDistributors(sim); this->updateContainerMaybeAsync(distributors); } @@ -128,7 +128,7 @@ namespace BlackGui { const CDistributorList distributors(ui->tvp_Distributors->container()); const CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue(); - CDistributorListPreferences preferences = this->m_distributorPreferences.get(); + CDistributorListPreferences preferences = this->m_distributorPreferences.getThreadLocal(); preferences.setDistributors(distributors, simulator); const CStatusMessage m = this->m_distributorPreferences.setAndSave(preferences); CLogMessage::preformatted(m); @@ -137,7 +137,7 @@ namespace BlackGui void CDistributorPreferencesComponent::ps_simulatorChanged(const CSimulatorInfo &simulator) { Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Expect single simulator"); - const CDistributorList distributors(this->m_distributorPreferences.get().getDistributors(simulator)); + const CDistributorList distributors(this->m_distributorPreferences.getThreadLocal().getDistributors(simulator)); ui->tvp_Distributors->updateContainerMaybeAsync(distributors); } diff --git a/src/blackgui/components/logincomponent.cpp b/src/blackgui/components/logincomponent.cpp index 69b5ece44..fea84b6c9 100644 --- a/src/blackgui/components/logincomponent.cpp +++ b/src/blackgui/components/logincomponent.cpp @@ -129,7 +129,7 @@ namespace BlackGui ps_validateAircraftValues(); ps_validateVatsimValues(); ps_onWebServiceDataRead(CEntityFlags::VatsimDataFile, CEntityFlags::ReadFinished, -1); - CServerList otherServers(this->m_otherTrafficNetworkServers.get()); + CServerList otherServers(this->m_otherTrafficNetworkServers.getThreadLocal()); // add a testserver when no servers can be loaded if (otherServers.isEmpty() && (sGui->isRunningInDeveloperEnvironment() || CBuildConfig::isBetaTest())) @@ -470,7 +470,7 @@ namespace BlackGui void CLoginComponent::ps_reloadSettings() { - CServerList otherServers(this->m_otherTrafficNetworkServers.get()); + CServerList otherServers(this->m_otherTrafficNetworkServers.getThreadLocal()); this->ui->cbp_OtherServers->setServers(otherServers); } diff --git a/src/blackgui/components/settingshotkeycomponent.cpp b/src/blackgui/components/settingshotkeycomponent.cpp index 2ee0c4442..bc556bd27 100644 --- a/src/blackgui/components/settingshotkeycomponent.cpp +++ b/src/blackgui/components/settingshotkeycomponent.cpp @@ -106,28 +106,28 @@ namespace BlackGui void CSettingsHotkeyComponent::addHotkeytoSettings(const CActionHotkey &actionHotkey) { - CActionHotkeyList actionHotkeyList(m_actionHotkeys.get()); + CActionHotkeyList actionHotkeyList(m_actionHotkeys.getThreadLocal()); actionHotkeyList.push_back(actionHotkey); m_actionHotkeys.set(actionHotkeyList); } void CSettingsHotkeyComponent::updateHotkeyInSettings(const CActionHotkey &oldValue, const CActionHotkey &newValue) { - CActionHotkeyList actionHotkeyList(m_actionHotkeys.get()); + CActionHotkeyList actionHotkeyList(m_actionHotkeys.getThreadLocal()); actionHotkeyList.replace(oldValue, newValue); m_actionHotkeys.set(actionHotkeyList); } void CSettingsHotkeyComponent::removeHotkeyFromSettings(const CActionHotkey &actionHotkey) { - CActionHotkeyList actionHotkeyList(m_actionHotkeys.get()); + CActionHotkeyList actionHotkeyList(m_actionHotkeys.getThreadLocal()); actionHotkeyList.remove(actionHotkey); m_actionHotkeys.set(actionHotkeyList); } bool CSettingsHotkeyComponent::checkAndConfirmConflicts(const CActionHotkey &actionHotkey, const CActionHotkeyList &ignore) { - auto configuredHotkeys = m_actionHotkeys.get(); + auto configuredHotkeys = m_actionHotkeys.getThreadLocal(); CActionHotkeyList conflicts = configuredHotkeys.findSupersetsOf(actionHotkey); conflicts.push_back(configuredHotkeys.findSubsetsOf(actionHotkey)); conflicts.removeIfIn(ignore); diff --git a/src/blackgui/components/settingsnetworkserverscomponent.cpp b/src/blackgui/components/settingsnetworkserverscomponent.cpp index b44c94630..96b89c63a 100644 --- a/src/blackgui/components/settingsnetworkserverscomponent.cpp +++ b/src/blackgui/components/settingsnetworkserverscomponent.cpp @@ -58,7 +58,7 @@ namespace BlackGui void CSettingsNetworkServersComponent::ps_reloadSettings() { - CServerList serverList(m_trafficNetworkServers.getCopy()); + CServerList serverList(m_trafficNetworkServers.get()); // add swift test servers in case we have no servers: // this is debug/bootstrap feature we can continue to test when something goes wrong @@ -81,7 +81,7 @@ namespace BlackGui CStatusMessageList msgs = server.validate(); if (!msgs.isEmpty()) { msgs.addCategories(this); } - CServerList serverList(m_trafficNetworkServers.get()); + CServerList serverList(m_trafficNetworkServers.getThreadLocal()); QObject *sender = QObject::sender(); CStatusMessage msg; bool changed = false; diff --git a/src/blackgui/components/settingssimulatorcomponent.cpp b/src/blackgui/components/settingssimulatorcomponent.cpp index a6fc90de2..93e35b870 100644 --- a/src/blackgui/components/settingssimulatorcomponent.cpp +++ b/src/blackgui/components/settingssimulatorcomponent.cpp @@ -150,7 +150,7 @@ namespace BlackGui return; } - auto e = m_enabledSimulators.get(); + auto e = m_enabledSimulators.getThreadLocal(); if (enabled && !e.contains(selected->getIdentifier())) { e << selected->getIdentifier(); @@ -301,7 +301,7 @@ namespace BlackGui void CSettingsSimulatorComponent::ps_reloadPluginConfig() { // list all available simulators - auto enabledSimulators = m_enabledSimulators.get(); + auto enabledSimulators = m_enabledSimulators.getThreadLocal(); for (const auto &p : getAvailablePlugins()) { ui->ps_EnabledSimulators->setEnabled(p.getIdentifier(), enabledSimulators.contains(p.getIdentifier())); diff --git a/src/blackgui/dockwidget.cpp b/src/blackgui/dockwidget.cpp index ab9ebdc2f..66b7f8098 100644 --- a/src/blackgui/dockwidget.cpp +++ b/src/blackgui/dockwidget.cpp @@ -536,7 +536,7 @@ namespace BlackGui void CDockWidget::initSettings() { const QString name(this->getNameForSettings()); - CSettingsDockWidgets all = this->m_settings.getCopy(); + CSettingsDockWidgets all = this->m_settings.get(); if (all.contains(name)) { return; } all.getByNameOrInitToDefault(name); this->m_settings.set(all); @@ -551,7 +551,7 @@ namespace BlackGui CSettingsDockWidget CDockWidget::getSettings() const { - const CSettingsDockWidgets all = this->m_settings.getCopy(); + const CSettingsDockWidgets all = this->m_settings.get(); const QString name(this->getNameForSettings()); const CSettingsDockWidget s = all.value(name); return s; @@ -561,7 +561,7 @@ namespace BlackGui { const CSettingsDockWidget current = getSettings(); if (current == settings) { return; } - CSettingsDockWidgets all = this->m_settings.getCopy(); + CSettingsDockWidgets all = this->m_settings.get(); const QString name(this->getNameForSettings()); all.insert(name, settings); const CStatusMessage m = this->m_settings.set(all); // saved when shutdown diff --git a/src/blackgui/editors/form.cpp b/src/blackgui/editors/form.cpp index 40f0363ff..88d095a99 100644 --- a/src/blackgui/editors/form.cpp +++ b/src/blackgui/editors/form.cpp @@ -23,7 +23,7 @@ namespace BlackGui const BlackMisc::Network::CAuthenticatedUser &CForm::getSwiftDbUser() const { - return this->m_swiftDbUser.get(); + return this->m_swiftDbUser.getThreadLocal(); } void CForm::ps_userChanged() diff --git a/src/blackgui/editors/ownmodelsetform.cpp b/src/blackgui/editors/ownmodelsetform.cpp index f4b11a9ce..c0f41887d 100644 --- a/src/blackgui/editors/ownmodelsetform.cpp +++ b/src/blackgui/editors/ownmodelsetform.cpp @@ -89,7 +89,7 @@ namespace BlackGui { Q_ASSERT_X(sGui && sGui->hasWebDataServices(), Q_FUNC_INFO, "Missing web data services"); Q_ASSERT_X(this->m_simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator"); - const CDistributorListPreferences prefs(this->m_distributorPreferences.getCopy()); + const CDistributorListPreferences prefs(this->m_distributorPreferences.get()); const CDistributorList distributors(prefs.getDistributors(this->m_simulator)); if (!distributors.isEmpty()) { return distributors; } @@ -115,7 +115,7 @@ namespace BlackGui bool COwnModelSetForm::hasDIstributorPreferences() const { - const CDistributorListPreferences prefs(this->m_distributorPreferences.getCopy()); + const CDistributorListPreferences prefs(this->m_distributorPreferences.get()); return !prefs.getDistributors(this->m_simulator).isEmpty(); } } // ns diff --git a/src/blackmisc/simulation/data/modelcaches.cpp b/src/blackmisc/simulation/data/modelcaches.cpp index 57fe77ae5..28c84d8cb 100644 --- a/src/blackmisc/simulation/data/modelcaches.cpp +++ b/src/blackmisc/simulation/data/modelcaches.cpp @@ -65,7 +65,7 @@ namespace BlackMisc CModelCaches::CModelCaches(QObject *parent) : IMultiSimulatorModelCaches(parent) { this->m_currentSimulator.synchronize(); - const CSimulatorInfo sim(this->m_currentSimulator.getCopy()); + const CSimulatorInfo sim(this->m_currentSimulator.get()); this->syncronizeCacheImpl(sim); const QString simStr(sim.toQString(true)); CLogMessage(this).info("Initialized model caches to %1") << simStr; @@ -76,10 +76,10 @@ namespace BlackMisc Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator"); switch (simulator.getSimulator()) { - case CSimulatorInfo::FS9: return this->m_modelCacheFs9.getCopy(); - case CSimulatorInfo::FSX: return this->m_modelCacheFsx.getCopy(); - case CSimulatorInfo::P3D: return this->m_modelCacheP3D.getCopy(); - case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.getCopy(); + case CSimulatorInfo::FS9: return this->m_modelCacheFs9.get(); + case CSimulatorInfo::FSX: return this->m_modelCacheFsx.get(); + case CSimulatorInfo::P3D: return this->m_modelCacheP3D.get(); + case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.get(); default: Q_ASSERT_X(false, Q_FUNC_INFO, "wrong simulator"); return CAircraftModelList(); @@ -132,7 +132,7 @@ namespace BlackMisc CStatusMessage CModelCaches::setCurrentSimulator(const CSimulatorInfo &simulator) { static const CStatusMessage sameSimMsg = CStatusMessage(this).info("Same simulator"); - const CSimulatorInfo s = this->m_currentSimulator.getCopy(); + const CSimulatorInfo s = this->m_currentSimulator.get(); if (s == simulator) { return sameSimMsg; } const BlackMisc::CStatusMessage m = this->m_currentSimulator.set(simulator); this->syncronizeCache(simulator); @@ -157,7 +157,7 @@ namespace BlackMisc CModelSetCaches::CModelSetCaches(QObject *parent) : IMultiSimulatorModelCaches(parent) { this->m_currentSimulator.synchronize(); - const CSimulatorInfo sim(this->m_currentSimulator.getCopy()); + const CSimulatorInfo sim(this->m_currentSimulator.get()); this->syncronizeCacheImpl(sim); const QString simStr(sim.toQString(true)); CLogMessage(this).info("Initialized model set caches to %1") << simStr; @@ -168,10 +168,10 @@ namespace BlackMisc Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator"); switch (simulator.getSimulator()) { - case CSimulatorInfo::FS9: return this->m_modelCacheFs9.getCopy(); - case CSimulatorInfo::FSX: return this->m_modelCacheFsx.getCopy(); - case CSimulatorInfo::P3D: return this->m_modelCacheP3D.getCopy(); - case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.getCopy(); + case CSimulatorInfo::FS9: return this->m_modelCacheFs9.get(); + case CSimulatorInfo::FSX: return this->m_modelCacheFsx.get(); + case CSimulatorInfo::P3D: return this->m_modelCacheP3D.get(); + case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.get(); default: Q_ASSERT_X(false, Q_FUNC_INFO, "wrong simulator"); return CAircraftModelList(); @@ -226,7 +226,7 @@ namespace BlackMisc CStatusMessage CModelSetCaches::setCurrentSimulator(const CSimulatorInfo &simulator) { static const CStatusMessage sameSimMsg = CStatusMessage(this).info("Same simulator"); - const CSimulatorInfo s = this->m_currentSimulator.getCopy(); + const CSimulatorInfo s = this->m_currentSimulator.get(); if (s == simulator) { return sameSimMsg; } const BlackMisc::CStatusMessage m = this->m_currentSimulator.set(simulator); this->syncronizeCache(simulator); diff --git a/src/blackmisc/simulation/data/modelcaches.h b/src/blackmisc/simulation/data/modelcaches.h index f64eb4bde..6b8edfe79 100644 --- a/src/blackmisc/simulation/data/modelcaches.h +++ b/src/blackmisc/simulation/data/modelcaches.h @@ -236,7 +236,7 @@ namespace BlackMisc virtual BlackMisc::CStatusMessage setCachedModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override; virtual QDateTime getCacheTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator) const override; virtual void syncronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) override; - virtual BlackMisc::Simulation::CSimulatorInfo getCurrentSimulator() const override { return this->m_currentSimulator.getCopy(); } + virtual BlackMisc::Simulation::CSimulatorInfo getCurrentSimulator() const override { return this->m_currentSimulator.get(); } virtual BlackMisc::CStatusMessage setCurrentSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) override; //! @} @@ -267,7 +267,7 @@ namespace BlackMisc virtual BlackMisc::CStatusMessage setCachedModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override; virtual QDateTime getCacheTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator) const override; virtual void syncronizeCache(const BlackMisc::Simulation::CSimulatorInfo &simulator) override; - virtual BlackMisc::Simulation::CSimulatorInfo getCurrentSimulator() const override { return this->m_currentSimulator.getCopy(); } + virtual BlackMisc::Simulation::CSimulatorInfo getCurrentSimulator() const override { return this->m_currentSimulator.get(); } virtual BlackMisc::CStatusMessage setCurrentSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) override; //! @} diff --git a/src/blackmisc/simulation/fscommon/vpilotrulesreader.cpp b/src/blackmisc/simulation/fscommon/vpilotrulesreader.cpp index c49353e12..ed7beded5 100644 --- a/src/blackmisc/simulation/fscommon/vpilotrulesreader.cpp +++ b/src/blackmisc/simulation/fscommon/vpilotrulesreader.cpp @@ -90,13 +90,13 @@ namespace BlackMisc int CVPilotRulesReader::getModelsCount() const { - return this->m_cachedVPilotModels.get().size(); + return this->m_cachedVPilotModels.getThreadLocal().size(); } CAircraftModelList CVPilotRulesReader::getAsModels() { // already cached? - CAircraftModelList vPilotModels(this->m_cachedVPilotModels.getCopy()); + CAircraftModelList vPilotModels(this->m_cachedVPilotModels.get()); if (!vPilotModels.isEmpty() || m_rules.isEmpty()) { return vPilotModels; } // important: that can take a while and should normally @@ -109,7 +109,7 @@ namespace BlackMisc CAircraftModelList CVPilotRulesReader::getAsModelsFromCache() const { - return this->m_cachedVPilotModels.getCopy(); + return this->m_cachedVPilotModels.get(); } int CVPilotRulesReader::countRulesLoaded() const diff --git a/src/blackmisc/valuecache.h b/src/blackmisc/valuecache.h index 646d025b7..70f7cb6b8 100644 --- a/src/blackmisc/valuecache.h +++ b/src/blackmisc/valuecache.h @@ -333,11 +333,11 @@ namespace BlackMisc {} //! Read the current value. - const T &get() const { static const T empty {}; return *(isValid() ? static_cast(getVariant().data()) : &empty); } + const T &getThreadLocal() const { static const T empty {}; return *(isValid() ? static_cast(getVariant().data()) : &empty); } //! Get a copy of the current value. //! \threadsafe - T getCopy() const { return isValid() ? getVariantCopy().template value() : T{}; } + T get() const { return isValid() ? getVariantCopy().template value() : T{}; } //! Write a new value. Must be called from the thread in which the owner lives. CStatusMessage set(const T &value, qint64 timestamp = 0) { return m_page.setValue(m_element, CVariant::from(value), timestamp); } diff --git a/src/plugins/simulator/xplane/simulatorxplane.cpp b/src/plugins/simulator/xplane/simulatorxplane.cpp index 9006eae6c..5ade94298 100644 --- a/src/plugins/simulator/xplane/simulatorxplane.cpp +++ b/src/plugins/simulator/xplane/simulatorxplane.cpp @@ -656,8 +656,8 @@ namespace BlackSimPlugin } else { - CLogMessage(this).debug() << "Starting XBus on" << m_xbusServerSetting.get(); - m_conn = CSimulatorXPlane::connectionFromString(m_xbusServerSetting.get()); + CLogMessage(this).debug() << "Starting XBus on" << m_xbusServerSetting.getThreadLocal(); + m_conn = CSimulatorXPlane::connectionFromString(m_xbusServerSetting.getThreadLocal()); m_watcher = new QDBusServiceWatcher(xbusServiceName(), m_conn, QDBusServiceWatcher::WatchForRegistration, this); connect(m_watcher, &QDBusServiceWatcher::serviceRegistered, this, &CSimulatorXPlaneListener::ps_serviceRegistered); } @@ -674,7 +674,7 @@ namespace BlackSimPlugin bool CSimulatorXPlaneListener::isXBusRunning() const { - QDBusConnection conn = CSimulatorXPlane::connectionFromString(m_xbusServerSetting.get()); + QDBusConnection conn = CSimulatorXPlane::connectionFromString(m_xbusServerSetting.getThreadLocal()); CXBusServiceProxy *service = new CXBusServiceProxy(conn); CXBusTrafficProxy *traffic = new CXBusTrafficProxy(conn); diff --git a/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp b/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp index 12db10c12..d629a35ce 100644 --- a/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp +++ b/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp @@ -54,7 +54,7 @@ namespace BlackSimPlugin connect(ui->bb_OkCancel, &QDialogButtonBox::accepted, this, &CSimulatorXPlaneConfigWindow::close); connect(ui->bb_OkCancel, &QDialogButtonBox::rejected, this, &CSimulatorXPlaneConfigWindow::close); - ui->cp_XBusServer->setCurrentText(m_xbusServerSetting.get()); + ui->cp_XBusServer->setCurrentText(m_xbusServerSetting.getThreadLocal()); if (xBusAvailable()) connect(ui->pb_InstallXBus, &QPushButton::clicked, this, &CSimulatorXPlaneConfigWindow::ps_installXBus); @@ -74,7 +74,7 @@ namespace BlackSimPlugin void CSimulatorXPlaneConfigWindow::ps_storeSettings() { - if (ui->cp_XBusServer->currentText() != m_xbusServerSetting.get()) + if (ui->cp_XBusServer->currentText() != m_xbusServerSetting.getThreadLocal()) { m_xbusServerSetting.set(ui->cp_XBusServer->currentText()); } diff --git a/src/swiftlauncher/swiftlauncher.cpp b/src/swiftlauncher/swiftlauncher.cpp index c157678ac..24ba57ec8 100644 --- a/src/swiftlauncher/swiftlauncher.cpp +++ b/src/swiftlauncher/swiftlauncher.cpp @@ -54,7 +54,7 @@ CSwiftLauncher::CSwiftLauncher(QWidget *parent) : this->ui->le_DBusServerPort->setValidator(new QIntValidator(0, 65535, this)); // default from settings - const QString dbus(this->m_dbusServerAddress.get()); + const QString dbus(this->m_dbusServerAddress.getThreadLocal()); this->setDefault(dbus); } @@ -307,7 +307,7 @@ void CSwiftLauncher::ps_loadedUpdateInfo(bool success) return; } - const CUpdateInfo updateInfo(this->m_updateInfo.get()); + const CUpdateInfo updateInfo(this->m_updateInfo.getThreadLocal()); const QString latestVersion(updateInfo.getLatestVersion()) ; // need to get this from somewhere CFailoverUrlList downloadUrls(updateInfo.getDownloadUrls()); bool newVersionAvailable = CVersion::isNewerVersion(latestVersion) && !downloadUrls.isEmpty();