diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5f1a4933f..a05612905 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,7 @@ env: jobs: preBuild: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository }} outputs: version: ${{ steps.version.outputs.value }} @@ -168,7 +168,7 @@ jobs: python3 scripts/run_static_analysis.py --clang-tidy --build-path build --changed-files-ci buildLinux: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 needs: [preBuild, checks] env: BACKTRACE_SYMBOL_TOKEN: ${{ secrets.BACKTRACE_SYMBOL_TOKEN }} @@ -274,7 +274,7 @@ jobs: path: ${{ github.workspace }}/xswiftbus-* buildWin64: - runs-on: windows-2022 + runs-on: windows-2025-vs2026 needs: [preBuild, checks] env: BACKTRACE_SYMBOL_TOKEN: ${{ secrets.BACKTRACE_SYMBOL_TOKEN }} @@ -345,11 +345,10 @@ jobs: ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }} ARTIFACTORY_TOKEN: ${{ secrets.ARTIFACTORY_TOKEN }} run: | - conan profile detect conan remote disable conancenter conan remote add swift https://artifactory.swift-project.org/artifactory/api/conan/conan-local conan remote login swift "$ARTIFACTORY_USER" --password "$ARTIFACTORY_TOKEN" - conan install . --output-folder=build_conan --deployer=full_deploy -pr=ci/profile_win + conan install . --output-folder=build_conan --deployer=full_deploy -pr:h=ci/profile_win -pr:b=ci/profile_win - name: Create Vatsim key file if: ${{ env.do_vatsim_key == 'true' }} run: | @@ -388,7 +387,7 @@ jobs: path: ${{ github.workspace }}/xswiftbus-* buildMacOS: - runs-on: macos-15 + runs-on: macos-26 needs: [preBuild, checks] env: BACKTRACE_SYMBOL_TOKEN: ${{ secrets.BACKTRACE_SYMBOL_TOKEN }} @@ -426,6 +425,9 @@ jobs: EOF env: BITROCK_LICENSE: ${{ secrets.BITROCK_LICENSE }} + - uses: actions/setup-python@v6 + with: + python-version: '3.13' - name: Install dependencies run: | pip3 install requests conan @@ -452,14 +454,13 @@ jobs: run: | # Empty presets to avoid autogenerated config from Conan echo "{\"version\": 6}" > CMakeUserPresets.json - conan profile detect conan remote disable conancenter conan remote add swift https://artifactory.swift-project.org/artifactory/api/conan/conan-local conan remote login swift "$ARTIFACTORY_USER" --password "$ARTIFACTORY_TOKEN" - conan install . --output-folder=build_conan --deployer=full_deploy -pr=ci/profile_mac - conan install . --output-folder=build_conan_arm --deployer=full_deploy -pr=ci/profile_mac_arm + conan install . --output-folder=build_conan --deployer=full_deploy -pr:h=ci/profile_mac -pr:b=ci/profile_mac_arm + conan install . --output-folder=build_conan_arm --deployer=full_deploy -pr:h=ci/profile_mac_arm -pr:b=ci/profile_mac_arm # https://doc.qt.io/qt-6/macos-issues.html#d-bus-and-macos - conan install --requires=dbus/1.15.8 --output-folder build_conan_dbus_shared --deployer=full_deploy -o "dbus/*:shared=True" -o "dbus/*:message_bus=True" -pr=ci/profile_mac + conan install --requires=dbus/1.15.8 --output-folder build_conan_dbus_shared --deployer=full_deploy -o "dbus/*:shared=True" -o "dbus/*:message_bus=True" -pr:h=ci/profile_mac -pr:b=ci/profile_mac_arm - name: Create Vatsim key file if: ${{ env.do_vatsim_key == 'true' }} run: | @@ -496,7 +497,7 @@ jobs: path: ${{ github.workspace }}/xswiftbus-* postBuild: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 needs: [preBuild, checks, buildLinux, buildWin64, buildMacOS] steps: @@ -522,7 +523,7 @@ jobs: name: xswiftbus-thin-* release: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 needs: [preBuild, postBuild] if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} outputs: @@ -560,10 +561,10 @@ jobs: xswiftbus-fat-allos-${{ needs.preBuild.outputs.version }}.zip swiftsymbols-allos-${{ needs.preBuild.outputs.version }}:swiftsymbols - name: Publish doxygen - uses: actions/deploy-pages@v4 + uses: actions/deploy-pages@v5 notify: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 needs: [preBuild, checks, buildLinux, buildWin64, buildMacOS, postBuild, release] if: always() @@ -600,7 +601,7 @@ jobs: CHECK_RUNS: ${{ join(fromJson(steps.checkruns.outputs.data).check_runs.*.id, ' ') }} TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Prepare Discord release message - uses: octokit/request-action@v2.x + uses: octokit/request-action@v3.x if: ${{ needs.release.result == 'success' }} id: release env: diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c5ac4a2d..3a1a1deff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ get_version_number() configure_target_platform() # CMake config -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) diff --git a/ci/profile_linux b/ci/profile_linux index 7e5f94f0d..5600431b4 100644 --- a/ci/profile_linux +++ b/ci/profile_linux @@ -5,7 +5,7 @@ arch=x86_64 build_type=RelWithDebInfo compiler=gcc -compiler.cppstd=gnu17 +compiler.cppstd=gnu20 compiler.libcxx=libstdc++11 compiler.version=11 os=Linux diff --git a/ci/profile_mac b/ci/profile_mac index 1df818604..1bac3fbd3 100644 --- a/ci/profile_mac +++ b/ci/profile_mac @@ -5,7 +5,9 @@ arch=x86_64 build_type=RelWithDebInfo compiler=apple-clang -compiler.cppstd=gnu17 +compiler.cppstd=gnu20 compiler.libcxx=libc++ -compiler.version=15 +compiler.version=21 os=Macos +# Minimum Deploy Version +os.version=13.0 diff --git a/ci/profile_mac_arm b/ci/profile_mac_arm index 81c44db69..657f7cf5a 100644 --- a/ci/profile_mac_arm +++ b/ci/profile_mac_arm @@ -5,7 +5,9 @@ arch=armv8 build_type=RelWithDebInfo compiler=apple-clang -compiler.cppstd=gnu17 +compiler.cppstd=gnu20 compiler.libcxx=libc++ -compiler.version=15 +compiler.version=21 os=Macos +# Minimum Deploy Version +os.version=13.0 diff --git a/ci/profile_win b/ci/profile_win index 737e181f7..39f7b9a13 100644 --- a/ci/profile_win +++ b/ci/profile_win @@ -5,9 +5,9 @@ arch=x86_64 build_type=RelWithDebInfo compiler=msvc -compiler.cppstd=17 +compiler.cppstd=20 compiler.runtime=dynamic -compiler.version=194 +compiler.version=195 os=Windows # Force Ninja generator diff --git a/src/core/afv/clients/afvclient.cpp b/src/core/afv/clients/afvclient.cpp index 535cddd8e..1d85623f2 100644 --- a/src/core/afv/clients/afvclient.cpp +++ b/src/core/afv/clients/afvclient.cpp @@ -53,7 +53,7 @@ namespace swift::core::afv::clients connect(m_voiceServerTimer, &QTimer::timeout, this, &CAfvClient::onTimerUpdate); // deferred init - use swift::misc:: singleShot to call in correct thread, "myself" NOT needed - swift::misc::singleShot(1000, this, [=] { this->deferredInit(); }); + swift::misc::singleShot(1000, this, [=, this] { this->deferredInit(); }); } QString CAfvClient::getCallsign() const @@ -120,7 +120,7 @@ namespace swift::core::afv::clients { // Method needs to be executed in the context thread QPointer myself(this); - QMetaObject::invokeMethod(sApp->getIContextSimulator(), [=]() { + QMetaObject::invokeMethod(sApp->getIContextSimulator(), [=, this]() { if (myself) { this->fetchSimulatorSettings(); } }); return; @@ -140,7 +140,7 @@ namespace swift::core::afv::clients { // Method needs to be executed in the object thread since it will create new QObject children QPointer myself(this); - QMetaObject::invokeMethod(this, [=]() { + QMetaObject::invokeMethod(this, [=, this]() { if (myself) { connectTo(cid, password, callsign, client); } }); return; @@ -154,7 +154,7 @@ namespace swift::core::afv::clients if (!this->isConnected() && m_retryConnectAttempt == 0) { // check if connect simply did NOT receive an answer - QTimer::singleShot(20 * 1000, this, [=] { + QTimer::singleShot(20 * 1000, this, [=, this] { if (!myself) { return; } if (m_retryConnectAttempt > 0) { return; } // already handled @@ -171,7 +171,7 @@ namespace swift::core::afv::clients m_connection->connectTo( cid, password, callsign, client, { // this is the callback when the connection has been established - this, [=](bool authenticated) { + this, [=, this](bool authenticated) { if (!myself) { return; } // cppcheck-suppress knownConditionTrueFalse // HF stations aliased @@ -208,7 +208,7 @@ namespace swift::core::afv::clients { // Method needs to be executed in the object thread since it will create new QObject children QPointer myself(this); - QMetaObject::invokeMethod(this, [=]() { + QMetaObject::invokeMethod(this, [=, this]() { if (myself) { disconnectFrom(stop); } }); return; @@ -272,7 +272,7 @@ namespace swift::core::afv::clients { // Method needs to be executed in the object thread since it will create new QObject children QPointer myself(this); - QMetaObject::invokeMethod(this, [=]() { + QMetaObject::invokeMethod(this, [=, this]() { if (myself) { startAudio(inputDevice, outputDevice); } }); return; @@ -363,7 +363,7 @@ namespace swift::core::afv::clients { // Method needs to be executed in the object thread since it will create new QObject children QPointer myself(this); - QMetaObject::invokeMethod(this, [=]() { + QMetaObject::invokeMethod(this, [=, this]() { if (myself) stopAudio(); }); return; @@ -1076,7 +1076,7 @@ namespace swift::core::afv::clients if (this->isConnected()) { this->disconnectFrom(false); } QPointer myself(this); - QTimer::singleShot(5 * 1000, this, [=] { + QTimer::singleShot(5 * 1000, this, [=, this] { if (!myself) { return; } const QString reason = QStringLiteral("Heartbeat failed %1 times").arg(failures); this->retryConnectTo(un, pw, cs, client, reason); @@ -1284,7 +1284,7 @@ namespace swift::core::afv::clients } QPointer myself(this); - QTimer::singleShot(delayMs, this, [=] { + QTimer::singleShot(delayMs, this, [=, this] { if (!myself) { return; } if (myself->isConnected()) { return; } this->connectTo(cid, password, callsign, client); diff --git a/src/core/afv/connection/apiserverconnection.cpp b/src/core/afv/connection/apiserverconnection.cpp index 74f9f56c7..d244326fa 100644 --- a/src/core/afv/connection/apiserverconnection.cpp +++ b/src/core/afv/connection/apiserverconnection.cpp @@ -60,7 +60,7 @@ namespace swift::core::afv::connection // posted in QAM thread, reply is nullptr if called from another thread sApp->postToNetwork(request, CApplication::NoLogRequestId, QJsonDocument(obj).toJson(), - { this, [=](QNetworkReply *nwReply) { + { this, [=, this](QNetworkReply *nwReply) { // called in "this" thread const QScopedPointer reply(nwReply); if (!myself || isShuttingDown()) // cppcheck-suppress knownConditionTrueFalse @@ -161,7 +161,7 @@ namespace swift::core::afv::connection // posted in QAM thread, reply is nullptr if called from another thread sApp->getFromNetwork(request, - { this, [=, &receivedData](QNetworkReply *nwReply) { + { this, [=, &receivedData, this](QNetworkReply *nwReply) { const QScopedPointer reply(nwReply); // called in "this" thread @@ -187,7 +187,7 @@ namespace swift::core::afv::connection // posted in QAM thread, reply is nullptr if called from another thread sApp->postToNetwork(request, CApplication::NoLogRequestId, data, - { this, [=, &receivedData](QNetworkReply *nwReply) { + { this, [=, &receivedData, this](QNetworkReply *nwReply) { const QScopedPointer reply(nwReply); // called in "this" thread @@ -217,7 +217,7 @@ namespace swift::core::afv::connection // posted in QAM thread, reply is nullptr if called from another thread sApp->postToNetwork(request, CApplication::NoLogRequestId, json.toJson(), - { this, [=](QNetworkReply *nwReply) { + { this, [=, this](QNetworkReply *nwReply) { // called in "this" thread const QScopedPointer reply(nwReply); if (isShuttingDown()) { return; } @@ -241,7 +241,7 @@ namespace swift::core::afv::connection // posted in QAM thread sApp->deleteResourceFromNetwork(request, CApplication::NoLogRequestId, - { this, [=](QNetworkReply *nwReply) { + { this, [=, this](QNetworkReply *nwReply) { // called in "this" thread const QScopedPointer reply( nwReply); @@ -260,7 +260,7 @@ namespace swift::core::afv::connection { QPointer myself(this); this->connectTo(m_username, m_password, m_client, m_networkVersion, - { this, [=](bool authenticated) { + { this, [=, this](bool authenticated) { if (!myself) { return; } // cppcheck-suppress knownConditionTrueFalse CLogMessage(this).info(u"API server authenticated '%1': %2") << m_username << boolToYesNo(authenticated); diff --git a/src/core/afv/connection/clientconnection.cpp b/src/core/afv/connection/clientconnection.cpp index 2c6509636..fa32a81d8 100644 --- a/src/core/afv/connection/clientconnection.cpp +++ b/src/core/afv/connection/clientconnection.cpp @@ -48,7 +48,7 @@ namespace swift::core::afv::connection m_apiServerConnection->connectTo( userName, password, client, m_networkVersion, { // callback called when connected - this, [=](bool authenticated) { + this, [=, this](bool authenticated) { // callback when connection has been established if (!myself) { return; } // cppcheck-suppress knownConditionTrueFalse diff --git a/src/core/airspacemonitor.cpp b/src/core/airspacemonitor.cpp index 5dd2134a9..34337fa85 100644 --- a/src/core/airspacemonitor.cpp +++ b/src/core/airspacemonitor.cpp @@ -126,7 +126,7 @@ namespace swift::core { // thread safe update of m_network const QPointer myself(this); - QTimer::singleShot(0, m_fsdClient, [=] { + QTimer::singleShot(0, m_fsdClient, [=, this] { if (!myself) { return; } if (m_fsdClient) { @@ -579,7 +579,7 @@ namespace swift::core } const QPointer myself(this); - QTimer::singleShot(MMCheckAgainMs, this, [=]() { + QTimer::singleShot(MMCheckAgainMs, this, [=, this]() { if (!myself || !sApp || sApp->isShuttingDown()) { return; } if (!this->isAircraftInRange(callsign)) { @@ -656,7 +656,7 @@ namespace swift::core // if the queries now yield a result all will be fine // otherwise we need to check again const QPointer myself(this); - QTimer::singleShot(MMVerifyMs, this, [=]() { + QTimer::singleShot(MMVerifyMs, this, [=, this]() { // makes sure we have ICAO data if (!myself || !sApp || sApp->isShuttingDown()) { return; } this->verifyReceivedIcaoData(callsign); @@ -1094,7 +1094,7 @@ namespace swift::core if (added) { const QPointer myself(this); - QTimer::singleShot(MMVerifyMs, this, [=]() { + QTimer::singleShot(MMVerifyMs, this, [=, this]() { // makes sure we have ICAO data if (!myself || !sApp || sApp->isShuttingDown()) { return; } this->verifyReceivedIcaoData(callsign); @@ -1124,7 +1124,7 @@ namespace swift::core QPointer myself(this); for (const CSimulatedAircraft &ac : aircraft) { - QTimer::singleShot(c++ * 25, this, [=] { + QTimer::singleShot(c++ * 25, this, [=, this] { if (!myself) { return; } myself->addNewAircraftInRange(ac); if (!readyForModelMatching) { return; } diff --git a/src/core/application.cpp b/src/core/application.cpp index f819c2d54..cc5e5d187 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -306,7 +306,7 @@ namespace swift::core if (this->isSet(m_cmdTestCrashpad)) { msgs.push_back(CLogMessage(this).info(u"About to simulate crash")); - QTimer::singleShot(10 * 1000, [=] { + QTimer::singleShot(10 * 1000, [=, this] { if (!sApp || sApp->isShuttingDown()) { return; } this->simulateCrash(); }); @@ -577,7 +577,7 @@ namespace swift::core if (!fi.dir().exists()) { return nullptr; } // function called with reply when done - CallbackSlot callbackSlot(this, [=](QNetworkReply *reply) { + CallbackSlot callbackSlot(this, [=, this](QNetworkReply *reply) { QScopedPointer nwReply(reply); CStatusMessage msg; if (reply->error() != QNetworkReply::NoError) @@ -1282,7 +1282,7 @@ namespace swift::core { // run in QAM thread if (this->isShuttingDown()) { return; } - QTimer::singleShot(0, m_accessManager, [=] { + QTimer::singleShot(0, m_accessManager, [=, this] { // should be now in QAM thread if (!sApp || sApp->isShuttingDown()) { return; } Q_ASSERT_X(CThreadUtils::isInThisThread(sApp->m_accessManager), Q_FUNC_INFO, @@ -1335,7 +1335,7 @@ namespace swift::core Q_ASSERT_X(callback.object(), Q_FUNC_INFO, "Need callback object (to determine thread)"); connect( reply, &QNetworkReply::finished, callback.object(), - [=] { + [=, this] { // Called when finished! // QNetworkRequest::FollowRedirectsAttribute would allow auto redirect, but we use our approach as // it gives us better control \fixme: Check again on Qt 5.9: Added redirects policy to diff --git a/src/core/context/contextapplication.cpp b/src/core/context/contextapplication.cpp index e59ef6c4b..63f60a30e 100644 --- a/src/core/context/contextapplication.cpp +++ b/src/core/context/contextapplication.cpp @@ -52,7 +52,7 @@ namespace swift::core::context QPointer myself(this); connect(CSettingsCache::instance(), &CSettingsCache::valuesChangedByLocal, this, - [=](const CValueCachePacket &settings) { + [=, this](const CValueCachePacket &settings) { if (!myself) { return; } this->changeSettings(settings, {}); }); @@ -65,7 +65,7 @@ namespace swift::core::context Q_ASSERT_X(sApp && sApp->getInputManager(), Q_FUNC_INFO, "Missing input manager"); bool s = connect(sApp->getInputManager(), &CInputManager::hotkeyActionRegistered, this, - [=](const QStringList &actions) { + [=, this](const QStringList &actions) { if (!myself) { return; } this->registerHotkeyActions(actions, {}); }); @@ -82,7 +82,7 @@ namespace swift::core::context s = connect( sApp->getInputManager(), &CInputManager::remoteActionFromLocal, this, - [=](const QString &action, bool argument) { + [=, this](const QString &action, bool argument) { if (!myself) { return; } this->callHotkeyActionRemotely(action, argument, {}); }, diff --git a/src/core/context/contextaudio.cpp b/src/core/context/contextaudio.cpp index ced5251da..67d167935 100644 --- a/src/core/context/contextaudio.cpp +++ b/src/core/context/contextaudio.cpp @@ -119,7 +119,7 @@ namespace swift::core::context // the whole context/facade system is not initialized when this code here is executed QPointer myself(this); - QTimer::singleShot(5000, this, [=] { + QTimer::singleShot(5000, this, [=, this] { if (!myself || !sApp || sApp->isShuttingDown()) { return; } const CSettings as = m_audioSettings.getThreadLocal(); @@ -453,7 +453,7 @@ namespace swift::core::context { // Play additional notification const QPointer myself(this); - QTimer::singleShot(ms, this, [=] { + QTimer::singleShot(ms, this, [=, this] { if (!sApp || sApp->isShuttingDown() || !myself) { return; } this->playNotification(CNotificationSounds::NotificationTextMessageSupervisor, true); }); diff --git a/src/core/context/contextsimulatorimpl.cpp b/src/core/context/contextsimulatorimpl.cpp index f2fc105c0..006d26457 100644 --- a/src/core/context/contextsimulatorimpl.cpp +++ b/src/core/context/contextsimulatorimpl.cpp @@ -72,7 +72,7 @@ namespace swift::core::context // deferred init of last model set, if no other data are set in meantime const QPointer myself(this); - QTimer::singleShot(2500ms, this, [=] { + QTimer::singleShot(2500ms, this, [=, this] { if (!myself) { return; } this->initByLastUsedModelSet(); m_aircraftMatcher.setSetup(m_matchingSettings.get()); @@ -538,7 +538,7 @@ namespace swift::core::context // Emit signal after this function completes completely decoupled QPointer myself(this); - QTimer::singleShot(25, this, [=] { + QTimer::singleShot(25, this, [=, this] { if (!myself || !sApp || sApp->isShuttingDown()) { return; } if (m_simulatorPlugin.second) { @@ -1061,7 +1061,7 @@ namespace swift::core::context m_simulatorPlugin.second->logicallyRemoveRemoteAircraft(callsign); aircraft.setModel(aircraft.getNetworkModel()); // like originally from network QPointer myself(this); - QTimer::singleShot(1000, this, [=] { + QTimer::singleShot(1000, this, [=, this] { if (!sApp || sApp->isShuttingDown() || !myself) { return; } this->xCtxAddedRemoteAircraftReadyForModelMatching(aircraft); }); @@ -1096,7 +1096,7 @@ namespace swift::core::context QPointer myself(this); for (const CCallsign &cs : callsigns) { - QTimer::singleShot(delayMs, this, [=] { + QTimer::singleShot(delayMs, this, [=, this] { if (!sApp || sApp->isShuttingDown() || !myself) { return; } this->doMatchingAgain(cs); }); @@ -1115,7 +1115,7 @@ namespace swift::core::context if (!this->isSimulatorAvailable()) { return false; } QPointer myself(this); - QTimer::singleShot(2500, this, [=] { + QTimer::singleShot(2500, this, [=, this] { if (!sApp || sApp->isShuttingDown() || !myself) { return; } const CSimulatedAircraft aircraft = this->getAircraftInRangeForCallsign(callsign); if (!aircraft.hasCallsign()) { return; } // no longer valid @@ -1136,7 +1136,7 @@ namespace swift::core::context if (m_logMatchingMessages) { const QPointer myself(this); - QTimer::singleShot(5000, this, [=] { + QTimer::singleShot(5000, this, [=, this] { if (!myself) { return; } if (m_aircraftMatcher.getModelSetCount() > MatchingLogMaxModelSetSize) { diff --git a/src/core/corefacade.cpp b/src/core/corefacade.cpp index ac3322c4f..0bbb65038 100644 --- a/src/core/corefacade.cpp +++ b/src/core/corefacade.cpp @@ -280,7 +280,7 @@ namespace swift::core // identifier is needed because own aircraft context also reports changed aircraft to // xCtxChangedOwnAircraftModel and we avoid roundtrips c = connect(this->getCContextSimulator(), &CContextSimulator::ownAircraftModelChanged, - this->getCContextOwnAircraft(), [=](const CAircraftModel &changedModel) { + this->getCContextOwnAircraft(), [=, this](const CAircraftModel &changedModel) { if (!this->getIContextOwnAircraft()) { return; } if (!this->getCContextSimulator()) { return; } this->getCContextOwnAircraft()->xCtxChangedSimulatorModel( diff --git a/src/core/db/airportdatareader.cpp b/src/core/db/airportdatareader.cpp index 0ee64c3ec..866c93768 100644 --- a/src/core/db/airportdatareader.cpp +++ b/src/core/db/airportdatareader.cpp @@ -47,7 +47,7 @@ namespace swift::core::db if (dir.isEmpty() || whatToRead == CEntityFlags::NoEntity) { return false; } QPointer myself(this); - QTimer::singleShot(0, this, [=]() { + QTimer::singleShot(0, this, [=, this]() { if (!myself) { return; } const CStatusMessageList msgs = this->readFromJsonFiles(dir, whatToRead, overrideNewerOnly); if (msgs.isFailure()) { CLogMessage::preformatted(msgs); } diff --git a/src/core/db/databasereader.cpp b/src/core/db/databasereader.cpp index bad212982..b03f9ef49 100644 --- a/src/core/db/databasereader.cpp +++ b/src/core/db/databasereader.cpp @@ -221,7 +221,7 @@ namespace swift::core::db if (validInCacheEntities != CEntityFlags::NoEntity) { QPointer myself(this); - QTimer::singleShot(0, this, [=] { + QTimer::singleShot(0, this, [=, this] { if (!myself) { return; } if (!sApp || sApp->isShuttingDown()) { return; } emit this->dataRead(validInCacheEntities, CEntityFlags::ReadFinished, 0, {}); @@ -245,7 +245,7 @@ namespace swift::core::db if (entities == CEntityFlags::NoEntity) { return; } QPointer myself(this); - QTimer::singleShot(0, this, [=] { + QTimer::singleShot(0, this, [=, this] { if (!sApp || sApp->isShuttingDown() || !myself) { return; } this->read(entities, mode, newerThan); }); diff --git a/src/core/db/icaodatareader.cpp b/src/core/db/icaodatareader.cpp index d9faa78f6..7f35e7c5e 100644 --- a/src/core/db/icaodatareader.cpp +++ b/src/core/db/icaodatareader.cpp @@ -624,7 +624,7 @@ namespace swift::core::db if (dir.isEmpty() || whatToRead == CEntityFlags::NoEntity) { return false; } QPointer myself(this); - QTimer::singleShot(0, this, [=]() { + QTimer::singleShot(0, this, [=, this]() { if (!myself) { return; } const CStatusMessageList msgs = this->readFromJsonFiles(dir, whatToRead, overrideNewerOnly); if (msgs.isFailure()) { CLogMessage::preformatted(msgs); } diff --git a/src/core/db/modeldatareader.cpp b/src/core/db/modeldatareader.cpp index ec0af260e..cfa36edea 100644 --- a/src/core/db/modeldatareader.cpp +++ b/src/core/db/modeldatareader.cpp @@ -533,7 +533,7 @@ namespace swift::core::db if (dir.isEmpty() || whatToRead == CEntityFlags::NoEntity) { return false; } QPointer myself(this); - QTimer::singleShot(0, this, [=]() { + QTimer::singleShot(0, this, [=, this]() { if (!myself) { return; } const CStatusMessageList msgs = this->readFromJsonFiles(dir, whatToRead, overrideNewerOnly); if (msgs.isFailure()) { CLogMessage::preformatted(msgs); } diff --git a/src/core/fsd/fsdclient.cpp b/src/core/fsd/fsdclient.cpp index bc4bb8c6b..070d30c36 100644 --- a/src/core/fsd/fsdclient.cpp +++ b/src/core/fsd/fsdclient.cpp @@ -230,7 +230,7 @@ namespace swift::core::fsd { if (!CThreadUtils::isInThisThread(this)) { - QMetaObject::invokeMethod(this, [=] { + QMetaObject::invokeMethod(this, [=, this] { if (sApp && !sApp->isShuttingDown()) { connectToServer(); } }); return; @@ -250,7 +250,7 @@ namespace swift::core::fsd const qint64 timerMs = qRound(PendingConnectionTimeoutMs * 1.25); const QPointer myself(this); - QTimer::singleShot(timerMs, this, [=] { + QTimer::singleShot(timerMs, this, [=, this] { if (!myself || !sApp || sApp->isShuttingDown()) { return; } this->pendingTimeoutCheck(); }); @@ -264,7 +264,7 @@ namespace swift::core::fsd { if (!CThreadUtils::isInThisThread(this)) { - QMetaObject::invokeMethod(this, [=] { + QMetaObject::invokeMethod(this, [=, this] { if (sApp && !sApp->isShuttingDown()) { disconnectFromServer(); } }); return; @@ -493,7 +493,7 @@ namespace swift::core::fsd if (queryType == ClientQueryType::Unknown) { return; } if (!CThreadUtils::isInThisThread(this)) { - QMetaObject::invokeMethod(this, [=] { + QMetaObject::invokeMethod(this, [=, this] { if (sApp && !sApp->isShuttingDown()) { sendClientQuery(queryType, receiver, queryData); } }); return; @@ -569,7 +569,7 @@ namespace swift::core::fsd if (messages.isEmpty()) { return; } if (!CThreadUtils::isInThisThread(this)) { - QMetaObject::invokeMethod(this, [=] { + QMetaObject::invokeMethod(this, [=, this] { if (sApp && !sApp->isShuttingDown()) { sendTextMessages(messages); } }); return; @@ -621,7 +621,7 @@ namespace swift::core::fsd if (message.isEmpty()) { return; } if (!CThreadUtils::isInThisThread(this)) { - QMetaObject::invokeMethod(this, [=] { + QMetaObject::invokeMethod(this, [=, this] { if (sApp && !sApp->isShuttingDown()) { sendTextMessage(receiverGroup, message); } }); return; @@ -669,7 +669,7 @@ namespace swift::core::fsd { if (!CThreadUtils::isInThisThread(this)) { - QMetaObject::invokeMethod(this, [=] { + QMetaObject::invokeMethod(this, [=, this] { if (sApp && !sApp->isShuttingDown()) { sendFlightPlan(flightPlan); } }); return; @@ -719,7 +719,7 @@ namespace swift::core::fsd { if (!CThreadUtils::isInThisThread(this)) { - QMetaObject::invokeMethod(this, [=] { + QMetaObject::invokeMethod(this, [=, this] { if (sApp && !sApp->isShuttingDown()) { sendPlaneInfoRequest(receiver); } }); return; @@ -734,7 +734,7 @@ namespace swift::core::fsd { if (!CThreadUtils::isInThisThread(this)) { - QMetaObject::invokeMethod(this, [=] { + QMetaObject::invokeMethod(this, [=, this] { if (sApp && !sApp->isShuttingDown()) { sendPlaneInfoRequestFsinn(callsign); } }); return; @@ -1007,7 +1007,7 @@ namespace swift::core::fsd const QJsonObject jsonRequest { { "cid", cid }, { "password", password } }; sApp->postToNetwork(nwRequest, CApplication::NoLogRequestId, QJsonDocument(jsonRequest).toJson(), - { this, [=](QNetworkReply *nwReply) { + { this, [=, this](QNetworkReply *nwReply) { const QByteArray data = nwReply->readAll(); const QJsonObject json = QJsonDocument::fromJson(data).object(); @@ -1658,7 +1658,7 @@ namespace swift::core::fsd const quint16 port = rehostingSocket ? m_socket->peerPort() : static_cast(getServer().getPort()); // NOLINTEND(cppcoreguidelines-init-variables) - resolveLoadBalancing(host, [=](const QString &host) { + resolveLoadBalancing(host, [=, this](const QString &host) { socket->connectToHost(host, port); if (!rehostingSocket) { this->startPositionTimers(); } }); diff --git a/src/core/simulator.cpp b/src/core/simulator.cpp index 93f7f9292..09fc89131 100644 --- a/src/core/simulator.cpp +++ b/src/core/simulator.cpp @@ -823,7 +823,7 @@ namespace swift::core // decouple, follow up of signal can include unloading // simulator so this should happen strictly asynchronously (which is like forcing Qt::QueuedConnection) QPointer myself(this); - QTimer::singleShot(0, this, [=] { + QTimer::singleShot(0, this, [=, this] { if (!myself || !sApp || sApp->isShuttingDown()) { return; } // now simulating @@ -841,7 +841,7 @@ namespace swift::core void ISimulator::emitInterpolationSetupChanged() { QPointer myself(this); - QTimer::singleShot(5, this, [=] { + QTimer::singleShot(5, this, [=, this] { if (!myself) { return; } emit this->interpolationAndRenderingSetupChanged(); }); @@ -974,7 +974,7 @@ namespace swift::core this->logicallyRemoveRemoteAircraft(callsign); if (!this->isAircraftInRange(callsign)) { return false; } const QPointer myself(this); - QTimer::singleShot(2500, this, [=] { + QTimer::singleShot(2500, this, [=, this] { if (myself.isNull()) { return; } if (this->isShuttingDown()) { return; } if (!this->isAircraftInRange(callsign)) { return; } @@ -1002,7 +1002,7 @@ namespace swift::core // return this->changeRemoteAircraftEnabled(aircraft); const QPointer myself(this); - QTimer::singleShot(1000, this, [=] { + QTimer::singleShot(1000, this, [=, this] { if (!myself) { return; } if (this->isAircraftInRange(callsign)) { this->changeRemoteAircraftEnabled(aircraft); } }); @@ -1202,7 +1202,7 @@ namespace swift::core const int t = CMathUtils::randomInteger(4500, 5500); // makes sure not always using the same time difference const QPointer myself(this); - QTimer::singleShot(t, this, [=] { + QTimer::singleShot(t, this, [=, this] { if (!myself || myself->isShuttingDown()) { return; } this->displayLoggedSituationInSimulator(cs, stopLogging, times - 1); }); @@ -1233,7 +1233,7 @@ namespace swift::core { // we wait for the data connect(sApp->getWebDataServices(), &CWebDataServices::swiftDbModelMatchingEntitiesRead, this, - [=] { this->reverseLookupAndUpdateOwnAircraftModel(model); }); + [=, this] { this->reverseLookupAndUpdateOwnAircraftModel(model); }); } } } @@ -1275,7 +1275,7 @@ namespace swift::core { // call in correct thread QPointer myself(this); - QTimer::singleShot(0, this, [=] { + QTimer::singleShot(0, this, [=, this] { if (myself) { this->start(); } }); return; @@ -1292,7 +1292,7 @@ namespace swift::core { // call in correct thread QPointer myself(this); - QTimer::singleShot(0, this, [=] { + QTimer::singleShot(0, this, [=, this] { if (myself) { this->stop(); } }); return; @@ -1309,7 +1309,7 @@ namespace swift::core { // call in correct thread QPointer myself(this); - QTimer::singleShot(0, this, [=] { + QTimer::singleShot(0, this, [=, this] { if (myself) { this->check(); } }); return; diff --git a/src/core/threadedreaderperiodic.cpp b/src/core/threadedreaderperiodic.cpp index 581af82fa..ac02b5239 100644 --- a/src/core/threadedreaderperiodic.cpp +++ b/src/core/threadedreaderperiodic.cpp @@ -14,7 +14,7 @@ namespace swift::core void CThreadedReaderPeriodic::startReader() { Q_ASSERT_X(hasStarted(), Q_FUNC_INFO, "Thread was not started yet!"); - QTimer::singleShot(m_initialTime.load(), this, [=] { this->doWork(); }); + QTimer::singleShot(m_initialTime.load(), this, [=, this] { this->doWork(); }); } void CThreadedReaderPeriodic::setInitialAndPeriodicTime(std::chrono::milliseconds initialTime, diff --git a/src/core/webdataservices.cpp b/src/core/webdataservices.cpp index 7bee55cd9..610135aa9 100644 --- a/src/core/webdataservices.cpp +++ b/src/core/webdataservices.cpp @@ -1079,7 +1079,7 @@ namespace swift::core // run single shot in main loop, so readInBackgroundThread is not called before initReaders completes const QPointer myself(this); - QTimer::singleShot(0, this, [=]() { + QTimer::singleShot(0, this, [=, this]() { if (!myself || m_shuttingDown) { return; } if (!sApp || sApp->isShuttingDown()) { return; } m_vatsimStatusReader->readInBackgroundThread(); @@ -1098,7 +1098,7 @@ namespace swift::core // run single shot in main loop, so readInBackgroundThread is not called before initReaders completes const QPointer myself(this); - QTimer::singleShot(0, this, [=]() { + QTimer::singleShot(0, this, [=, this]() { if (!myself || m_shuttingDown) { return; } if (!sApp || sApp->isShuttingDown()) { return; } m_vatsimServerFileReader->readInBackgroundThread(); @@ -1198,7 +1198,7 @@ namespace swift::core if (!CThreadUtils::isInThisThread(this)) { const QPointer myself(this); - QTimer::singleShot(0, this, [=] { + QTimer::singleShot(0, this, [=, this] { if (!myself || m_shuttingDown) { return; } if (!sApp || sApp->isShuttingDown()) { return; } this->initDbInfoObjectReaderAndTriggerRead(); @@ -1225,7 +1225,7 @@ namespace swift::core m_dbInfoDataReader->start(QThread::LowPriority); const QPointer myself(this); - QTimer::singleShot(25, m_dbInfoDataReader, [=]() { + QTimer::singleShot(25, m_dbInfoDataReader, [=, this]() { if (!myself || m_shuttingDown) { return; } if (!sApp || sApp->isShuttingDown()) { return; } m_dbInfoDataReader->readInfoData(); // trigger read of info objects @@ -1240,7 +1240,7 @@ namespace swift::core if (!CThreadUtils::isInThisThread(this)) { const QPointer myself(this); - QTimer::singleShot(0, this, [=] { + QTimer::singleShot(0, this, [=, this] { if (!myself || m_shuttingDown) { return; } this->initSharedInfoObjectReaderAndTriggerRead(); }); @@ -1266,7 +1266,7 @@ namespace swift::core // and trigger read const QPointer myself(this); - QTimer::singleShot(0, m_sharedInfoDataReader, [=]() { + QTimer::singleShot(0, m_sharedInfoDataReader, [=, this]() { if (!myself || m_shuttingDown) { return; } m_sharedInfoDataReader->readInfoData(); }); @@ -1426,7 +1426,7 @@ namespace swift::core if (m_shuttingDown) { return; } if (entities == CEntityFlags::NoEntity) { return; } const QPointer myself(this); - QTimer::singleShot(0, [=]() // clazy:exclude=connect-3arg-lambda + QTimer::singleShot(0, [=, this]() // clazy:exclude=connect-3arg-lambda { if (!myself || m_shuttingDown) { return; } this->readInBackground(entities); // deferred diff --git a/src/gui/components/aircraftmodelstringcompleter.cpp b/src/gui/components/aircraftmodelstringcompleter.cpp index 9d3cdad5c..1d6b961a2 100644 --- a/src/gui/components/aircraftmodelstringcompleter.cpp +++ b/src/gui/components/aircraftmodelstringcompleter.cpp @@ -96,7 +96,7 @@ namespace swift::gui::components if (this->getSimulator() == simulator) { return false; } m_currentSimulator = simulator; QPointer myself(this); - QTimer::singleShot(100, this, [=] { + QTimer::singleShot(100, this, [=, this] { if (!myself) { return; } this->setCompleter(true); }); diff --git a/src/gui/components/aircraftmodelvalidationcomponent.cpp b/src/gui/components/aircraftmodelvalidationcomponent.cpp index dc6e26a60..3d9309abe 100644 --- a/src/gui/components/aircraftmodelvalidationcomponent.cpp +++ b/src/gui/components/aircraftmodelvalidationcomponent.cpp @@ -51,7 +51,7 @@ namespace swift::gui::components // 1st init when running in distributed environment QPointer myself(this); const qint64 lastResults = m_lastResults; - QTimer::singleShot(2500, this, [=] { + QTimer::singleShot(2500, this, [=, this] { if (!myself || !sGui || sGui->isShuttingDown()) { return; } if (m_lastResults > lastResults) { return; } // values received in meantime myself->requestLastResults(); diff --git a/src/gui/components/aircraftpartscomponent.cpp b/src/gui/components/aircraftpartscomponent.cpp index 5d35a03ba..b9577687b 100644 --- a/src/gui/components/aircraftpartscomponent.cpp +++ b/src/gui/components/aircraftpartscomponent.cpp @@ -132,7 +132,7 @@ namespace swift::gui::components // simple approach to update UI when parts are received const QPointer myself(this); - QTimer::singleShot(3000, this, [=] { + QTimer::singleShot(3000, this, [=, this] { if (!myself) { return; } ui->pb_CurrentParts->click(); ui->pb_RequestFromNetwork->setEnabled(true); diff --git a/src/gui/components/atcstationcomponent.cpp b/src/gui/components/atcstationcomponent.cpp index 9c27d777e..2253d457a 100644 --- a/src/gui/components/atcstationcomponent.cpp +++ b/src/gui/components/atcstationcomponent.cpp @@ -309,7 +309,7 @@ namespace swift::gui::components // here I know I am the selected widget, update, but keep GUI responsive (-> timer) const QPointer myself(this); - QTimer::singleShot(1000, this, [=] { + QTimer::singleShot(1000, this, [=, this] { if (!sApp || sApp->isShuttingDown() || !myself) { return; } this->update(); }); diff --git a/src/gui/components/audiodevicevolumesetupcomponent.cpp b/src/gui/components/audiodevicevolumesetupcomponent.cpp index 5f17c3658..2f070cfcb 100644 --- a/src/gui/components/audiodevicevolumesetupcomponent.cpp +++ b/src/gui/components/audiodevicevolumesetupcomponent.cpp @@ -102,7 +102,7 @@ namespace swift::gui::components // it takes a moment until the settings are sychronized // this is leading to undesired "save settings" messages and played sounds QPointer myself(this); - QTimer::singleShot(2000, this, [=] { + QTimer::singleShot(2000, this, [=, this] { if (!myself || !sGui || sGui->isShuttingDown()) { return; } this->init(); }); @@ -489,7 +489,7 @@ namespace swift::gui::components sGui->getCContextAudioBase()->setRxTx(rx1, tx1, rx2, tx2); QPointer myself(this); - QTimer::singleShot(25, this, [=] { + QTimer::singleShot(25, this, [=, this] { // in case UI values are not correct if (!myself) { return; } this->setRxTxCheckboxes(rx1, tx1, rx2, tx2); diff --git a/src/gui/components/audionotificationcomponent.cpp b/src/gui/components/audionotificationcomponent.cpp index 12ae5867a..15ded8fd3 100644 --- a/src/gui/components/audionotificationcomponent.cpp +++ b/src/gui/components/audionotificationcomponent.cpp @@ -36,7 +36,7 @@ namespace swift::gui::components // it takes a moment until the settings are sychronized // this is leading to undesired "save settings" messages and played sounds QPointer myself(this); - QTimer::singleShot(2500, this, [=] { + QTimer::singleShot(2500, this, [=, this] { if (!myself || !sGui || sGui->isShuttingDown()) { return; } this->init(); }); diff --git a/src/gui/components/autopublishcomponent.cpp b/src/gui/components/autopublishcomponent.cpp index b578c6f7d..3d49a4eef 100644 --- a/src/gui/components/autopublishcomponent.cpp +++ b/src/gui/components/autopublishcomponent.cpp @@ -110,7 +110,7 @@ namespace swift::gui::components if (success) { QPointer myself(this); - this->showOverlayMessagesWithConfirmation(msgs, true, "Clean up auto publish files?", [=] { + this->showOverlayMessagesWithConfirmation(msgs, true, "Clean up auto publish files?", [=, this] { if (!myself) { return; } const auto timeout = 5000ms; myself->deleteAllFiles(); diff --git a/src/gui/components/cockpitcomcomponent.cpp b/src/gui/components/cockpitcomcomponent.cpp index 64d359308..48c662a40 100644 --- a/src/gui/components/cockpitcomcomponent.cpp +++ b/src/gui/components/cockpitcomcomponent.cpp @@ -85,7 +85,7 @@ namespace swift::gui::components &CCockpitComComponent::onAtcStationsChanged, Qt::QueuedConnection); QPointer myself(this); - QTimer::singleShot(10 * 1000, this, [=] { + QTimer::singleShot(10 * 1000, this, [=, this] { if (!sGui || sGui->isShuttingDown() || !myself) { return; } const CSimulatedAircraft aircraft = sGui->getIContextOwnAircraft()->getOwnAircraft(); this->updateCockpitFromContext(aircraft, CIdentifier::fake()); diff --git a/src/gui/components/commandinput.cpp b/src/gui/components/commandinput.cpp index 56bbd722d..c9db6f0f2 100644 --- a/src/gui/components/commandinput.cpp +++ b/src/gui/components/commandinput.cpp @@ -27,7 +27,7 @@ namespace swift::gui::components if (this->placeholderText().isEmpty()) { this->setPlaceholderText(".dot commands"); } const QPointer myself(this); - QTimer::singleShot(5000, this, [=] { + QTimer::singleShot(5000, this, [=, this] { if (!myself) { return; } m_dsCommandTooltip.inputSignal(); }); diff --git a/src/gui/components/dbairlineicaoselectorbase.cpp b/src/gui/components/dbairlineicaoselectorbase.cpp index 7adf26d4e..661b96ff1 100644 --- a/src/gui/components/dbairlineicaoselectorbase.cpp +++ b/src/gui/components/dbairlineicaoselectorbase.cpp @@ -44,7 +44,7 @@ namespace swift::gui::components if (c > 0) { QPointer myself(this); - QTimer::singleShot(500, [=]() { + QTimer::singleShot(500, [=, this]() { if (!sGui || sGui->isShuttingDown()) { return; } if (!myself) { return; } this->onCodesRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFinished, c, {}); diff --git a/src/gui/components/dbdistributorcomponent.cpp b/src/gui/components/dbdistributorcomponent.cpp index 3c92f0d66..ef574b739 100644 --- a/src/gui/components/dbdistributorcomponent.cpp +++ b/src/gui/components/dbdistributorcomponent.cpp @@ -101,7 +101,7 @@ namespace swift::gui::components // deferred because filter must first work and update const QPointer myself(this); - QTimer::singleShot(2000, this, [=] { + QTimer::singleShot(2000, this, [=, this] { if (!myself || !sApp || sApp->isShuttingDown()) { return; } ui->tvp_Distributors->selectDbKeys(keys); }); diff --git a/src/gui/components/dbloaddatadialog.cpp b/src/gui/components/dbloaddatadialog.cpp index d87b3a0c5..dac8e119b 100644 --- a/src/gui/components/dbloaddatadialog.cpp +++ b/src/gui/components/dbloaddatadialog.cpp @@ -125,7 +125,7 @@ namespace swift::gui::components const bool defaultConsolidate = !ui->cb_AllModels->isChecked() && ui->cb_ModelSet->isChecked(); QPointer myself(this); - QTimer::singleShot(2000, this, [=] { + QTimer::singleShot(2000, this, [=, this] { if (!myself) { return; } ui->wi_Consolidate->setVisible(true); ui->wi_WorkStatus->setVisible(false); @@ -196,7 +196,7 @@ namespace swift::gui::components m_consolidating = false; QPointer myself(this); - QTimer::singleShot(2000, this, [=] { + QTimer::singleShot(2000, this, [=, this] { if (!myself) { return; } ui->pb_Loading->setMaximum(100); ui->wi_WorkStatus->setVisible(false); diff --git a/src/gui/components/dbloadoverviewcomponent.cpp b/src/gui/components/dbloadoverviewcomponent.cpp index 948f99cd5..2d7bbfb1b 100644 --- a/src/gui/components/dbloadoverviewcomponent.cpp +++ b/src/gui/components/dbloadoverviewcomponent.cpp @@ -76,7 +76,7 @@ namespace swift::gui::components connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbLoadOverviewComponent::dataLoaded); QPointer myself(this); - QTimer::singleShot(10 * 1000, this, [=] { + QTimer::singleShot(10 * 1000, this, [=, this] { if (!myself || !sGui || sGui->isShuttingDown()) { return; } this->loadInfoObjects(); this->adjustTextWidth(); diff --git a/src/gui/components/dbownmodelsetcomponent.cpp b/src/gui/components/dbownmodelsetcomponent.cpp index 1ed96968d..cc419a610 100644 --- a/src/gui/components/dbownmodelsetcomponent.cpp +++ b/src/gui/components/dbownmodelsetcomponent.cpp @@ -462,7 +462,7 @@ namespace swift::gui::components this->admitCache(simulator); // trigger loading QPointer myself(this); - QTimer::singleShot(1000, this, [=] { + QTimer::singleShot(1000, this, [=, this] { if (!sApp || sApp->isShuttingDown()) { return; } if (!myself) { return; } this->setSimulator(simulator); diff --git a/src/gui/components/distributorpreferencescomponent.cpp b/src/gui/components/distributorpreferencescomponent.cpp index e45c3ded0..50c29038b 100644 --- a/src/gui/components/distributorpreferencescomponent.cpp +++ b/src/gui/components/distributorpreferencescomponent.cpp @@ -145,7 +145,7 @@ namespace swift::gui::components void CDistributorPreferencesComponent::triggerDeferredSimulatorChange() { QPointer myself(this); - QTimer::singleShot(1000, this, [=] { + QTimer::singleShot(1000, this, [=, this] { if (!myself) { return; } if (!sApp || sApp->isShuttingDown()) { return; } const CSimulatorInfo sim = ui->comp_SimulatorSelector->getValue(); diff --git a/src/gui/components/downloadcomponent.cpp b/src/gui/components/downloadcomponent.cpp index ea4a7d8e9..1ade72c9c 100644 --- a/src/gui/components/downloadcomponent.cpp +++ b/src/gui/components/downloadcomponent.cpp @@ -47,7 +47,7 @@ namespace swift::gui::components connect(ui->tb_DialogDownloadDir, &QToolButton::pressed, this, &CDownloadComponent::selectDownloadDirectory); connect(ui->tb_ResetDownloadDir, &QToolButton::pressed, this, &CDownloadComponent::resetDownloadDir); connect(ui->tb_CancelDownload, &QToolButton::pressed, this, &CDownloadComponent::cancelOngoingDownloads); - connect(ui->pb_Download, &QPushButton::pressed, [=] { this->triggerDownloadingOfFiles(); }); + connect(ui->pb_Download, &QPushButton::pressed, [=, this] { this->triggerDownloadingOfFiles(); }); connect(ui->pb_OpenDownloadDir, &QPushButton::pressed, this, &CDownloadComponent::openDownloadDir); connect(ui->pb_Launch, &QPushButton::pressed, this, &CDownloadComponent::startDownloadedExecutable); } @@ -102,7 +102,7 @@ namespace swift::gui::components if (delayMs > 0) { const QPointer myself(this); - QTimer::singleShot(delayMs, this, [=] { + QTimer::singleShot(delayMs, this, [=, this] { if (!myself || !sGui || sGui->isShuttingDown()) { return; } this->triggerDownloadingOfFiles(); }); @@ -201,7 +201,7 @@ namespace swift::gui::components if (reply != QMessageBox::Yes) { const QPointer myself(this); - QTimer::singleShot(10, this, [=] { + QTimer::singleShot(10, this, [=, this] { if (!myself || !sGui || sGui->isShuttingDown()) { return; } this->downloadedFile(CStatusMessage(this).info(u"File was already downloaded")); }); @@ -255,7 +255,7 @@ namespace swift::gui::components void CDownloadComponent::lastFileDownloaded() { const QPointer myself(this); - QTimer::singleShot(0, this, [=] { + QTimer::singleShot(0, this, [=, this] { if (!myself || !sGui || sGui->isShuttingDown()) { return; } myself->ui->pb_Download->setEnabled(true); myself->ui->pb_Launch->setEnabled(true); diff --git a/src/gui/components/downloaddialog.cpp b/src/gui/components/downloaddialog.cpp index bec320e83..8c7cffaed 100644 --- a/src/gui/components/downloaddialog.cpp +++ b/src/gui/components/downloaddialog.cpp @@ -40,7 +40,7 @@ namespace swift::gui::components void CDownloadDialog::showAndStartDownloading() { const QPointer guard(this); - QTimer::singleShot(0, this, [=] { + QTimer::singleShot(0, this, [=, this] { if (guard.isNull()) { return; } ui->comp_Download->triggerDownloadingOfFiles(2500); }); diff --git a/src/gui/components/flightplancomponent.cpp b/src/gui/components/flightplancomponent.cpp index ada5fb9ec..aaf56bde7 100644 --- a/src/gui/components/flightplancomponent.cpp +++ b/src/gui/components/flightplancomponent.cpp @@ -205,7 +205,7 @@ namespace swift::gui::components // prefill some data derived from what was used last const QPointer myself(this); - QTimer::singleShot(2500, this, [=] { + QTimer::singleShot(2500, this, [=, this] { if (!sGui || sGui->isShuttingDown() || !myself) { return; } this->loadTemplateFromDisk(); @@ -754,7 +754,7 @@ namespace swift::gui::components const CAircraftIcaoCode icao = this->getAircraftIcaoCode(); if (!icao.isLoadedFromDb()) { return; } QPointer myself(this); - QTimer::singleShot(25, this, [=] { + QTimer::singleShot(25, this, [=, this] { if (!myself || !sGui || sGui->isShuttingDown()) { return; } updateWakeTurbulenceCategorySelector(icao.getWtc()); }); diff --git a/src/gui/components/infobarstatuscomponent.cpp b/src/gui/components/infobarstatuscomponent.cpp index 1aaa281d0..6ed2228f1 100644 --- a/src/gui/components/infobarstatuscomponent.cpp +++ b/src/gui/components/infobarstatuscomponent.cpp @@ -90,7 +90,7 @@ namespace swift::gui::components } QPointer myself(this); - QTimer::singleShot(5000, this, [=] { + QTimer::singleShot(5000, this, [=, this] { if (!sGui || sGui->isShuttingDown() || !myself) { return; } this->updateValues(); }); diff --git a/src/gui/components/initialdataloadcomponent.cpp b/src/gui/components/initialdataloadcomponent.cpp index 2fc7316e7..6a12681f3 100644 --- a/src/gui/components/initialdataloadcomponent.cpp +++ b/src/gui/components/initialdataloadcomponent.cpp @@ -25,7 +25,7 @@ namespace swift::gui::components void CInitialDataLoadWizardPage::initializePage() { Q_ASSERT_X(m_config, Q_FUNC_INFO, "Missing config"); - QTimer::singleShot(500, m_config, [=] { m_config->loadAllFromShared(); }); + QTimer::singleShot(500, m_config, [=, this] { m_config->loadAllFromShared(); }); } bool CInitialDataLoadWizardPage::validatePage() diff --git a/src/gui/components/installfsxterrainprobecomponent.cpp b/src/gui/components/installfsxterrainprobecomponent.cpp index 872311f77..65a10a573 100644 --- a/src/gui/components/installfsxterrainprobecomponent.cpp +++ b/src/gui/components/installfsxterrainprobecomponent.cpp @@ -41,7 +41,7 @@ namespace swift::gui::components &CInstallFsxTerrainProbeComponent::onSimulatorChanged); QPointer myself(this); - QTimer::singleShot(500, this, [=] { + QTimer::singleShot(500, this, [=, this] { if (!myself) { return; } this->onSimulatorChanged(ui->comp_SimulatorSelector->getValue()); }); diff --git a/src/gui/components/installxswiftbuscomponent.cpp b/src/gui/components/installxswiftbuscomponent.cpp index c6701a0d6..61642902c 100644 --- a/src/gui/components/installxswiftbuscomponent.cpp +++ b/src/gui/components/installxswiftbuscomponent.cpp @@ -254,7 +254,7 @@ namespace swift::gui::components { const CStatusMessage msg = CStatusMessage(this).info(u"Using existing file '%1'") << saveAsFile; const QPointer guard(this); - QTimer::singleShot(100, this, [=] { + QTimer::singleShot(100, this, [=, this] { if (guard.isNull()) { return; } this->downloadedXSwiftBusFile(msg); }); @@ -295,9 +295,9 @@ namespace swift::gui::components } static const QString confirm("Install in '%1'?"); - this->showOverlayMessagesWithConfirmation(status, false, confirm.arg(ui->le_XSwiftBusPluginDir->text()), [=] { - QTimer::singleShot(0, this, &CInstallXSwiftBusComponent::installXSwiftBus); - }); + this->showOverlayMessagesWithConfirmation( + status, false, confirm.arg(ui->le_XSwiftBusPluginDir->text()), + [=, this] { QTimer::singleShot(0, this, &CInstallXSwiftBusComponent::installXSwiftBus); }); } CRemoteFile CInstallXSwiftBusComponent::getRemoteFileSelected() const diff --git a/src/gui/components/interpolationlogdisplay.cpp b/src/gui/components/interpolationlogdisplay.cpp index c08c9a01c..d4184af34 100644 --- a/src/gui/components/interpolationlogdisplay.cpp +++ b/src/gui/components/interpolationlogdisplay.cpp @@ -541,7 +541,7 @@ namespace swift::gui::components { // it can take a while until we receive parts, so we init QPointer myself(this); - QTimer::singleShot(250, this, [=] { + QTimer::singleShot(250, this, [=, this] { if (!myself) { return; } if (m_callsign.isEmpty()) { return; } myself->onPartsAdded(m_callsign, CAircraftParts()); diff --git a/src/gui/components/interpolationsetupcomponent.cpp b/src/gui/components/interpolationsetupcomponent.cpp index 4b3adba96..5a4e0997d 100644 --- a/src/gui/components/interpolationsetupcomponent.cpp +++ b/src/gui/components/interpolationsetupcomponent.cpp @@ -51,13 +51,13 @@ namespace swift::gui::components ui->rb_Global->setChecked(true); QPointer myself(this); - QTimer::singleShot(1000, this, [=] { + QTimer::singleShot(1000, this, [=, this] { if (!sGui || sGui->isShuttingDown()) { return; } if (!myself) { return; } this->onModeChanged(); }); - QTimer::singleShot(30 * 1000, this, [=] { + QTimer::singleShot(30 * 1000, this, [=, this] { if (!sGui || sGui->isShuttingDown()) { return; } if (!myself) { return; } this->onSetupChanged(); @@ -140,7 +140,7 @@ namespace swift::gui::components CLogMessage(this).info(u"Set global setup: '%1'") << gs.toQString(true); const QPointer myself(this); - QTimer::singleShot(250, this, [=] { + QTimer::singleShot(250, this, [=, this] { if (!myself) { return; } this->reloadSetup(); }); @@ -165,7 +165,7 @@ namespace swift::gui::components if (!set) { return; } const QPointer myself(this); - QTimer::singleShot(250, this, [=] { + QTimer::singleShot(250, this, [=, this] { if (!myself) { return; } this->displaySetupsPerCallsign(); }); @@ -194,7 +194,7 @@ namespace swift::gui::components if (!set) { return; } const QPointer myself(this); - QTimer::singleShot(100, this, [=] { + QTimer::singleShot(100, this, [=, this] { if (!myself) { return; } this->displaySetupsPerCallsign(); }); diff --git a/src/gui/components/logincomponent.cpp b/src/gui/components/logincomponent.cpp index 6484f36be..990ed7619 100644 --- a/src/gui/components/logincomponent.cpp +++ b/src/gui/components/logincomponent.cpp @@ -128,7 +128,7 @@ namespace swift::gui::components this->updateUiConnectState(); QPointer myself(this); - QTimer::singleShot(5000, this, [=] { + QTimer::singleShot(5000, this, [=, this] { if (!myself) { return; } this->updateGui(); }); diff --git a/src/gui/components/mainkeypadareacomponent.cpp b/src/gui/components/mainkeypadareacomponent.cpp index 3480d389f..485c5fb41 100644 --- a/src/gui/components/mainkeypadareacomponent.cpp +++ b/src/gui/components/mainkeypadareacomponent.cpp @@ -73,7 +73,7 @@ namespace swift::gui::components connect(this, &CMainKeypadAreaComponent::commandEntered, sGui->getCoreFacade(), &CCoreFacade::parseCommandLine); QPointer myself(this); - QTimer::singleShot(5000, this, [=] { + QTimer::singleShot(5000, this, [=, this] { if (!myself || !sGui) { return; } this->update(); }); diff --git a/src/gui/components/modelmatcherlogenable.cpp b/src/gui/components/modelmatcherlogenable.cpp index 50c1e5363..92d081225 100644 --- a/src/gui/components/modelmatcherlogenable.cpp +++ b/src/gui/components/modelmatcherlogenable.cpp @@ -40,7 +40,7 @@ namespace swift::gui::components } QPointer myself(this); - QTimer::singleShot(5000, this, [=] { + QTimer::singleShot(5000, this, [=, this] { if (!myself) { return; } this->initGui(); }); diff --git a/src/gui/components/settingsmatchingcomponent.cpp b/src/gui/components/settingsmatchingcomponent.cpp index aa5a0738e..20c7bb366 100644 --- a/src/gui/components/settingsmatchingcomponent.cpp +++ b/src/gui/components/settingsmatchingcomponent.cpp @@ -85,7 +85,7 @@ namespace swift::gui::components else { QPointer myself(this); - QTimer::singleShot(deferMs, this, [=] { + QTimer::singleShot(deferMs, this, [=, this] { if (!myself) { return; } this->deferredReload(0); }); diff --git a/src/gui/components/settingsmodelcomponent.cpp b/src/gui/components/settingsmodelcomponent.cpp index 703c76b87..762c3972f 100644 --- a/src/gui/components/settingsmodelcomponent.cpp +++ b/src/gui/components/settingsmodelcomponent.cpp @@ -37,7 +37,7 @@ namespace swift::gui::components // start updater if not yet done QPointer myself(this); - QTimer::singleShot(2500, this, [=] { + QTimer::singleShot(2500, this, [=, this] { if (!myself) { return; } this->consolidationEntered(); }); diff --git a/src/gui/components/simulatorselector.cpp b/src/gui/components/simulatorselector.cpp index 5c22e0bda..982baf7c0 100644 --- a/src/gui/components/simulatorselector.cpp +++ b/src/gui/components/simulatorselector.cpp @@ -188,7 +188,7 @@ namespace swift::gui::components if (!sGui || sGui->isShuttingDown()) { return; } QPointer myself(this); - QTimer::singleShot(deferredMs, this, [=] { + QTimer::singleShot(deferredMs, this, [=, this] { if (!sGui || sGui->isShuttingDown() || !myself) { return; } this->setToConnectedSimulator(makeReadOnly); }); @@ -390,7 +390,7 @@ namespace swift::gui::components void CSimulatorSelector::triggerSetToLastSelection() { QPointer myself(this); - QTimer::singleShot(100, this, [=] { + QTimer::singleShot(100, this, [=, this] { if (!myself) { return; } this->setToLastSelection(); }); diff --git a/src/gui/components/textmessagecomponent.cpp b/src/gui/components/textmessagecomponent.cpp index 51bbf41c4..b379a28d0 100644 --- a/src/gui/components/textmessagecomponent.cpp +++ b/src/gui/components/textmessagecomponent.cpp @@ -110,7 +110,7 @@ namespace swift::gui::components // init by settings const QPointer myself(this); - QTimer::singleShot(2000, this, [=] { + QTimer::singleShot(2000, this, [=, this] { // init decoupled when sub components are fully init if (!myself || !sGui || sGui->isShuttingDown()) { return; } this->onSettingsChanged(); // init diff --git a/src/gui/components/updateinfocomponent.cpp b/src/gui/components/updateinfocomponent.cpp index eadf9d80a..f7adf3f37 100644 --- a/src/gui/components/updateinfocomponent.cpp +++ b/src/gui/components/updateinfocomponent.cpp @@ -74,7 +74,7 @@ namespace swift::gui::components void CUpdateInfoComponent::triggerDownload() { QPointer myself(this); - QTimer::singleShot(10, this, [=] { + QTimer::singleShot(10, this, [=, this] { if (!myself) { return; } ui->pb_DownloadInstaller->click(); }); diff --git a/src/gui/editors/ownmodelsetform.cpp b/src/gui/editors/ownmodelsetform.cpp index 9a93fe6b6..4f39c458d 100644 --- a/src/gui/editors/ownmodelsetform.cpp +++ b/src/gui/editors/ownmodelsetform.cpp @@ -38,7 +38,7 @@ namespace swift::gui::editors &COwnModelSetForm::changeDistributorDisplay); QPointer myself(this); - QTimer::singleShot(1250, [=] { + QTimer::singleShot(1250, [=, this] { if (!myself) { return; } this->onSimulatorChanged(ui->comp_SimulatorSelector->getValue()); }); diff --git a/src/gui/enableforframelesswindow.cpp b/src/gui/enableforframelesswindow.cpp index a74fafd91..fc2dabd2a 100644 --- a/src/gui/enableforframelesswindow.cpp +++ b/src/gui/enableforframelesswindow.cpp @@ -240,7 +240,7 @@ namespace swift::gui // still tool, force normal window // decouple, otherwise we end up in infinite loop as it triggers a new changeEvent - QTimer::singleShot(0, m_widget, [=] { + QTimer::singleShot(0, m_widget, [=, this] { if (!widgetSelf) { return; } this->showMinimizedModeChecked(); }); @@ -249,7 +249,7 @@ namespace swift::gui { // not tool, force tool window // decouple, otherwise we end up in infinite loop as it triggers a new changeEvent - QTimer::singleShot(0, m_widget, [=] { + QTimer::singleShot(0, m_widget, [=, this] { if (!widgetSelf) { return; } this->showNormalModeChecked(); }); diff --git a/src/gui/filters/aircraftmodelfilterbar.cpp b/src/gui/filters/aircraftmodelfilterbar.cpp index e1c180868..10e54a783 100644 --- a/src/gui/filters/aircraftmodelfilterbar.cpp +++ b/src/gui/filters/aircraftmodelfilterbar.cpp @@ -54,7 +54,7 @@ namespace swift::gui::filters // connect deferred, avoid to filter during the UI "swing in period" QPointer myself(this); - QTimer::singleShot(2500, this, [=] { + QTimer::singleShot(2500, this, [=, this] { if (!myself) { return; } this->connectTriggerFilterSignals(); }); diff --git a/src/gui/filters/distributorfilterbar.cpp b/src/gui/filters/distributorfilterbar.cpp index a33fc2db7..f545bc105 100644 --- a/src/gui/filters/distributorfilterbar.cpp +++ b/src/gui/filters/distributorfilterbar.cpp @@ -35,7 +35,7 @@ namespace swift::gui::filters // connect deferred, avoid to filter during the UI "swing in period" QPointer myself(this); - QTimer::singleShot(2500, this, [=] { + QTimer::singleShot(2500, this, [=, this] { if (!myself) { return; } this->connectTriggerFilterSignals(); }); diff --git a/src/gui/guiactionbind.cpp b/src/gui/guiactionbind.cpp index 750e3641e..540dcc26f 100644 --- a/src/gui/guiactionbind.cpp +++ b/src/gui/guiactionbind.cpp @@ -86,7 +86,7 @@ namespace swift::gui void CGuiActionBindHandler::connectDestroy(QObject *object) { // if the action is destroyed from somewhere else I unbind myself - QObject::connect(object, &QObject::destroyed, [=] { this->unbind(); }); + QObject::connect(object, &QObject::destroyed, [=, this] { this->unbind(); }); } void CGuiActionBindHandler::unbind() diff --git a/src/gui/guiapplication.cpp b/src/gui/guiapplication.cpp index 077840b26..797a0e2f7 100644 --- a/src/gui/guiapplication.cpp +++ b/src/gui/guiapplication.cpp @@ -253,7 +253,7 @@ namespace swift::gui else { QPointer myself(this); - connectOnce(this, &CGuiApplication::uiObjectTreeReady, this, [=] { + connectOnce(this, &CGuiApplication::uiObjectTreeReady, this, [=, this] { if (!myself) { return; } this->addWindowFlags(flags); }); @@ -499,7 +499,7 @@ namespace swift::gui Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); a = sm->addAction("Reset settings"); - c = connect(a, &QAction::triggered, this, [=] { + c = connect(a, &QAction::triggered, this, [=, this] { if (!sGui || sGui->isShuttingDown()) { return; } CSettingsCache::instance()->clearAllValues(); CLogMessage(this).info(u"Cleared all settings!"); @@ -507,7 +507,7 @@ namespace swift::gui Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); a = sm->addAction("List settings files"); - c = connect(a, &QAction::triggered, this, [=]() { + c = connect(a, &QAction::triggered, this, [=, this]() { if (!sGui || sGui->isShuttingDown()) { return; } const QStringList files(CSettingsCache::instance()->enumerateStore()); CLogMessage(this).info(files.join("\n")); @@ -524,7 +524,7 @@ namespace swift::gui Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); a = sm->addAction("Reset cache"); - c = connect(a, &QAction::triggered, this, [=]() { + c = connect(a, &QAction::triggered, this, [=, this]() { if (!sGui || sGui->isShuttingDown()) { return; } const QStringList files = CApplication::clearCaches(); CLogMessage(this).info(u"Cleared caches! " % QString::number(files.size()) + " files"); @@ -532,7 +532,7 @@ namespace swift::gui Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); a = sm->addAction("List cache files"); - c = connect(a, &QAction::triggered, this, [=]() { + c = connect(a, &QAction::triggered, this, [=, this]() { if (!sGui || sGui->isShuttingDown()) { return; } const QStringList files(CDataCache::instance()->enumerateStore()); CLogMessage(this).info(files.join("\n")); @@ -540,14 +540,14 @@ namespace swift::gui Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); a = menu.addAction(CIcons::disk16(), "Log directory"); - c = connect(a, &QAction::triggered, this, [=]() { + c = connect(a, &QAction::triggered, this, [=, this]() { if (!sGui || sGui->isShuttingDown()) { return; } this->openStandardLogDirectory(); }); Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); a = menu.addAction(CIcons::disk16(), "Crash dumps directory"); - c = connect(a, &QAction::triggered, this, [=]() { + c = connect(a, &QAction::triggered, this, [=, this]() { if (!sGui || sGui->isShuttingDown()) { return; } this->openStandardCrashDumpDirectory(); }); @@ -563,14 +563,14 @@ namespace swift::gui { QMenu *sm = menu.addMenu("Style sheet"); QAction *aReload = sm->addAction(CIcons::refresh16(), "Reload"); - bool c = connect(aReload, &QAction::triggered, this, [=]() { + bool c = connect(aReload, &QAction::triggered, this, [=, this]() { if (!sGui || sGui->isShuttingDown()) { return; } this->reloadStyleSheets(); }); Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); QAction *aOpen = sm->addAction(CIcons::text16(), "Open qss file"); - c = connect(aOpen, &QAction::triggered, this, [=]() { + c = connect(aOpen, &QAction::triggered, this, [=, this]() { if (!sGui || sGui->isShuttingDown()) { return; } this->openStandardWidgetStyleSheet(); }); @@ -611,7 +611,7 @@ namespace swift::gui QAction *a = sm->addAction("JSON bootstrap"); bool c = connect( a, &QAction::triggered, this, - [=]() { + [=, this]() { if (!sGui || sGui->isShuttingDown()) { return; } const CGlobalSetup s = this->getGlobalSetup(); CLogMessage(this).info(s.toJsonString()); @@ -622,7 +622,7 @@ namespace swift::gui a = sm->addAction("JSON version update info (for info only)"); c = connect( a, &QAction::triggered, this, - [=]() { + [=, this]() { if (!sGui || sGui->isShuttingDown()) { return; } const CUpdateInfo info = this->getUpdateInfo(); CLogMessage(this).info(info.toJsonString()); @@ -635,7 +635,7 @@ namespace swift::gui a = menu.addAction("Services log.(console)"); c = connect( a, &QAction::triggered, this, - [=]() { + [=, this]() { if (!sGui || sGui->isShuttingDown()) { return; } CLogMessage(this).info(this->getWebDataServices()->getReadersLog()); }, @@ -645,7 +645,7 @@ namespace swift::gui a = sm->addAction("JSON DB info (for info only)"); c = connect( a, &QAction::triggered, this, - [=]() { + [=, this]() { if (!sGui || sGui->isShuttingDown()) { return; } if (!this->getWebDataServices()->getDbInfoDataReader()) { return; } const CDbInfoList info = this->getWebDataServices()->getDbInfoDataReader()->getInfoObjects(); @@ -657,7 +657,7 @@ namespace swift::gui a = sm->addAction("JSON shared info (for info only)"); c = connect( a, &QAction::triggered, this, - [=]() { + [=, this]() { if (!sGui || sGui->isShuttingDown()) { return; } if (!this->getWebDataServices()->getDbInfoDataReader()) { return; } const CDbInfoList info = this->getWebDataServices()->getSharedInfoDataReader()->getInfoObjects(); @@ -670,7 +670,7 @@ namespace swift::gui a = menu.addAction("Metadata (slow)"); c = connect( a, &QAction::triggered, this, - [=]() { + [=, this]() { if (!sGui || sGui->isShuttingDown()) { return; } CLogMessage(this).info(getAllUserMetatypesTypes()); }, @@ -711,7 +711,7 @@ namespace swift::gui Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); a = menu.addAction("Toggle stay on top"); - c = connect(a, &QAction::triggered, this, [=]() { + c = connect(a, &QAction::triggered, this, [=, this]() { if (!w) { return; } this->toggleStayOnTop(); }); @@ -730,7 +730,7 @@ namespace swift::gui Q_ASSERT_X(c, Q_FUNC_INFO, "connect failed"); a = menu.addAction("Toggle normal or minimized"); - c = connect(a, &QAction::triggered, this, [=]() { + c = connect(a, &QAction::triggered, this, [=, this]() { if (!w) { return; } this->windowMinimizeNormalToggle(); }); @@ -750,7 +750,7 @@ namespace swift::gui if (!w) { return; } QAction *a = menu.addAction(w->style()->standardIcon(QStyle::SP_TitleBarContextHelpButton), "Online help"); - bool c = connect(a, &QAction::triggered, this, [=]() { + bool c = connect(a, &QAction::triggered, this, [=, this]() { if (!sGui || sGui->isShuttingDown()) { return; } this->showHelp(); }); @@ -984,7 +984,7 @@ namespace swift::gui void CGuiApplication::triggerNewVersionCheck(int delayedMs) { if (!m_updateSetting.get()) { return; } - QTimer::singleShot(delayedMs, this, [=] { + QTimer::singleShot(delayedMs, this, [=, this] { if (!sGui || sGui->isShuttingDown()) { return; } if (m_updateDialog) { return; } // already checked elsewhere this->checkNewVersion(true); diff --git a/src/gui/led.cpp b/src/gui/led.cpp index 7229d0031..37acc3da4 100644 --- a/src/gui/led.cpp +++ b/src/gui/led.cpp @@ -229,7 +229,7 @@ namespace swift::gui if (resetTimeMs > 0) { QPointer myself(this); - QTimer::singleShot(resetTimeMs, this, [=] { + QTimer::singleShot(resetTimeMs, this, [=, this] { if (!myself) { return; } this->resetState(); }); diff --git a/src/gui/loadindicator.cpp b/src/gui/loadindicator.cpp index 4b34b5f50..235d7954f 100644 --- a/src/gui/loadindicator.cpp +++ b/src/gui/loadindicator.cpp @@ -60,7 +60,7 @@ namespace swift::gui const int stopId = m_currentId++; // copy if (timeout > 0ms) { - QTimer::singleShot(timeout, this, [=] { + QTimer::singleShot(timeout, this, [=, this] { if (!myself) { return; } // only timeout myself id diff --git a/src/gui/overlaymessages.cpp b/src/gui/overlaymessages.cpp index 3c04afa7a..ea9158a5e 100644 --- a/src/gui/overlaymessages.cpp +++ b/src/gui/overlaymessages.cpp @@ -463,7 +463,7 @@ namespace swift::gui { // defer message QPointer myself(this); - m_pendingMessageCalls.push_back([=]() { + m_pendingMessageCalls.push_back([=, this]() { if (!myself) { return; } this->showOverlayMessagesWithConfirmation(messages, appendOldMessages, confirmationMessage, okLambda, defaultButton, timeout); diff --git a/src/gui/views/aircraftmodelvalidationdialog.cpp b/src/gui/views/aircraftmodelvalidationdialog.cpp index 7f3a900d7..7c8a1e7ef 100644 --- a/src/gui/views/aircraftmodelvalidationdialog.cpp +++ b/src/gui/views/aircraftmodelvalidationdialog.cpp @@ -43,7 +43,7 @@ namespace swift::gui::views void CAircraftModelValidationDialog::triggerValidation(int delayMs) { QPointer myself(this); - QTimer::singleShot(delayMs, this, [=] { + QTimer::singleShot(delayMs, this, [=, this] { if (!myself) { return; } this->validate(); }); diff --git a/src/gui/views/simulatedaircraftview.cpp b/src/gui/views/simulatedaircraftview.cpp index 04c2e54e7..13ef42113 100644 --- a/src/gui/views/simulatedaircraftview.cpp +++ b/src/gui/views/simulatedaircraftview.cpp @@ -296,7 +296,7 @@ namespace swift::gui::views const QPointer myself(this); for (const CSimulatedAircraft &sa : aircraft) { - QTimer::singleShot(10, this, [=] { + QTimer::singleShot(10, this, [=, this] { if (!myself) { return; } if (!sGui || sGui->isShuttingDown()) { return; } CSimulatedAircraft enabledAircraft(sa); diff --git a/src/gui/views/viewbasenontemplate.cpp b/src/gui/views/viewbasenontemplate.cpp index d2145a311..17ec0765f 100644 --- a/src/gui/views/viewbasenontemplate.cpp +++ b/src/gui/views/viewbasenontemplate.cpp @@ -589,7 +589,7 @@ namespace swift::gui::views // call this deferred, otherwise the values are overridden with any values // from the UI builder const QPointer guard(this); - QTimer::singleShot(500, this, [=]() { + QTimer::singleShot(500, this, [=, this]() { if (!guard) { return; } CViewBaseNonTemplate::settingsChanged(); }); diff --git a/src/misc/datacache.cpp b/src/misc/datacache.cpp index 036d314bb..7d887c356 100644 --- a/src/misc/datacache.cpp +++ b/src/misc/datacache.cpp @@ -75,7 +75,7 @@ namespace swift::misc } connect(this, &CValueCache::valuesChangedByLocal, this, &CDataCache::saveToStoreAsync); - connect(this, &CValueCache::valuesChangedByLocal, this, [=](CValueCachePacket values) { + connect(this, &CValueCache::valuesChangedByLocal, this, [=, this](CValueCachePacket values) { values.setSaved(); changeValuesFromRemote(values, CIdentifier()); }); diff --git a/src/misc/digestsignal.cpp b/src/misc/digestsignal.cpp index e00121b94..31db452d0 100644 --- a/src/misc/digestsignal.cpp +++ b/src/misc/digestsignal.cpp @@ -15,7 +15,7 @@ namespace swift::misc { // call in correct thread const QPointer myself(this); - QTimer::singleShot(0, this, [=] { + QTimer::singleShot(0, this, [=, this] { if (!myself) { return; } this->inputSignal(); }); diff --git a/src/misc/identifier.cpp b/src/misc/identifier.cpp index 44272c441..3ff3c6eca 100644 --- a/src/misc/identifier.cpp +++ b/src/misc/identifier.cpp @@ -120,7 +120,7 @@ namespace swift::misc { if (!object) { return; } QObject::connect(object, &QObject::objectNameChanged, object, - [=](const QString &name) { this->appendName(name); }); + [=, this](const QString &name) { this->appendName(name); }); } QByteArray CIdentifier::getMachineId() const diff --git a/src/misc/lockfree.h b/src/misc/lockfree.h index 77801cf1e..32eb15a53 100644 --- a/src/misc/lockfree.h +++ b/src/misc/lockfree.h @@ -105,7 +105,13 @@ namespace swift::misc ~LockFreeUniqueWriter() { if (m_ptr.use_count() == 0) { return; } // *this has been moved from + +#ifdef __cpp_lib_atomic_shared_ptr // atomic shared pointer is currently not supported by clang + bool success = m_now->compare_exchange_strong(m_old, std::shared_ptr(m_ptr)); +#else bool success = std::atomic_compare_exchange_strong(m_now, &m_old, std::shared_ptr(m_ptr)); +#endif + Q_ASSERT_X(success, Q_FUNC_INFO, "UniqueWriter detected simultaneous writes"); Q_UNUSED(success); } @@ -113,99 +119,19 @@ namespace swift::misc private: friend class LockFree; +#ifdef __cpp_lib_atomic_shared_ptr + LockFreeUniqueWriter(std::shared_ptr ptr, std::atomic> *now) +#else LockFreeUniqueWriter(std::shared_ptr ptr, std::shared_ptr *now) +#endif : m_old(ptr), m_now(now), m_ptr(std::make_shared(*m_old)) {} std::shared_ptr m_old; +#ifdef __cpp_lib_atomic_shared_ptr + std::atomic> *m_now; +#else std::shared_ptr *m_now; - std::shared_ptr m_ptr; - }; - - /*! - * Return value of LockFree::sharedWrite(). Allows any one thread to safely write to the lock-free object. - */ - template - class LockFreeSharedWriter - { - public: - //! @{ - //! The value can be modified through the returned reference. The modification is applied by evaluating in a - //! bool context. - T &get() { return *m_ptr; } - T *operator->() { return m_ptr.get(); } - T &operator*() { return *m_ptr; } - operator T &() { return *m_ptr; } - //! @} - - //! Replace the stored value by copying from a T. The change is applied by evaluating in a bool context. - LockFreeSharedWriter &operator=(const T &other) - { - *m_ptr = other; - return *this; - } - - //! Replace the stored value by moving from a T. The change is applied by evaluating in a bool context. - LockFreeSharedWriter &operator=(T &&other) noexcept(std::is_nothrow_move_assignable_v) - { - *m_ptr = std::move(other); - return *this; - } - - //! Try to overwrite the original object with the new one stored in the writer, and return false on success. - //! If true is returned, then the caller must try again. This would happen if another simultaneous write had - //! occurred. - bool operator!() { return !operator bool(); } - - //! Try to overwrite the original object with the new one stored in the writer, and return true on success. - //! If false is returned, then the caller must try again. This would happen if another simultaneous write had - //! occurred. - operator bool() - { - Q_ASSERT_X(m_ptr.use_count() > 0, Q_FUNC_INFO, "SharedWriter tried to commit changes twice"); - if (std::atomic_compare_exchange_strong(m_now, &m_old, std::shared_ptr(m_ptr))) - { - m_ptr.reset(); - return true; - } - QThread::msleep(1); - m_old = std::atomic_load(m_now); - m_ptr = std::make_shared(*m_old); - return false; - } - - //! Destructor. The writer's changes must be committed before this is called. - ~LockFreeSharedWriter() - { - Q_ASSERT_X(m_ptr.use_count() == 0, Q_FUNC_INFO, "SharedWriter destroyed without committing changes"); - } - - //! @{ - //! LockFreeSharedWriter cannot be copied. - LockFreeSharedWriter(const LockFreeSharedWriter &) = delete; - LockFreeSharedWriter &operator=(const LockFreeSharedWriter &) = delete; - //! @} - - //! Move constructor. - LockFreeSharedWriter(LockFreeSharedWriter &&other) noexcept - : m_old(std::move(other.m_old)), m_now(std::move(other.m_now)), m_ptr(std::move(other.m_ptr)) - {} - - //! Move assignment operator. - LockFreeSharedWriter &operator=(LockFreeSharedWriter &&other) noexcept - { - std::tie(m_old, m_now, m_ptr) = - std::forward_as_tuple(std::move(other.m_old), std::move(other.m_now), std::move(other.m_ptr)); - return *this; - } - - private: - friend class LockFree; - - LockFreeSharedWriter(std::shared_ptr ptr, std::shared_ptr *now) - : m_old(ptr), m_now(now), m_ptr(std::make_shared(*m_old)) - {} - std::shared_ptr m_old; - std::shared_ptr *m_now; +#endif std::shared_ptr m_ptr; }; @@ -238,13 +164,18 @@ namespace swift::misc //! @} //! Return an object which can read the current value. +#ifdef __cpp_lib_atomic_shared_ptr + LockFreeReader read() const { return { m_ptr.load() }; } +#else LockFreeReader read() const { return { std::atomic_load(&m_ptr) }; } +#endif //! Return an object which can write a new value, as long as there are no other writes. +#ifdef __cpp_lib_atomic_shared_ptr + LockFreeUniqueWriter uniqueWrite() { return { m_ptr.load(), &m_ptr }; } +#else LockFreeUniqueWriter uniqueWrite() { return { std::atomic_load(&m_ptr), &m_ptr }; } - - //! Return an object which can write a new value, even if there are other writes. - LockFreeSharedWriter sharedWrite() { return { std::atomic_load(&m_ptr), &m_ptr }; } +#endif //! Pass the current value to the functor inspector, and return whatever inspector returns. template @@ -260,20 +191,12 @@ namespace swift::misc std::forward(mutator)(uniqueWrite().get()); } - //! Pass a modifiable reference to the functor mutator. Safe if there are multiple writers. - //! The mutator may be called multiple times. - template - void sharedWrite(F &&mutator) - { - auto writer = sharedWrite(); - do { - std::forward(mutator)(writer.get()); - } - while (!writer); - } - private: +#ifdef __cpp_lib_atomic_shared_ptr + std::atomic> m_ptr = std::make_shared(); +#else std::shared_ptr m_ptr = std::make_shared(); +#endif }; /*! @@ -351,18 +274,6 @@ namespace swift::misc { return writer->end(); } - - template - typename T::iterator begin(const LockFreeSharedWriter &writer) - { - return writer->begin(); - } - - template - typename T::iterator end(const LockFreeSharedWriter &writer) - { - return writer->end(); - } //! @} //! @{ @@ -382,12 +293,6 @@ namespace swift::misc template typename T::iterator end(const LockFreeUniqueWriter &&) = delete; - - template - typename T::iterator begin(const LockFreeSharedWriter &&) = delete; - - template - typename T::iterator end(const LockFreeSharedWriter &&) = delete; //! @} } // namespace swift::misc diff --git a/src/misc/provider.h b/src/misc/provider.h index d9b1fda6a..f91e6c8da 100644 --- a/src/misc/provider.h +++ b/src/misc/provider.h @@ -62,8 +62,9 @@ namespace swift::misc auto iProvider = dynamic_cast(provider); if (iProvider && iProvider->asQObject()) { - QMetaObject::Connection con = QObject::connect(iProvider->asQObject(), &QObject::destroyed, - [=](QObject *obj) { this->onProviderDestroyed(obj); }); + QMetaObject::Connection con = + QObject::connect(iProvider->asQObject(), &QObject::destroyed, + [=, this](QObject *obj) { this->onProviderDestroyed(obj); }); m_lastProviderConnections.append(con); } } diff --git a/src/misc/sharedstate/dbus/hubproxy.cpp b/src/misc/sharedstate/dbus/hubproxy.cpp index 841a70ce4..35f095189 100644 --- a/src/misc/sharedstate/dbus/hubproxy.cpp +++ b/src/misc/sharedstate/dbus/hubproxy.cpp @@ -25,7 +25,7 @@ namespace swift::misc::shared_state::dbus std::pair, QFuture> CHubProxy::getDuplex(const CIdentifier &identifier) { auto duplex = QSharedPointer::create(m_interface->connection(), m_service, this); - connect(duplex.get(), &QObject::destroyed, this, [=] { closeDuplex(identifier); }); + connect(duplex.get(), &QObject::destroyed, this, [=, this] { closeDuplex(identifier); }); return std::make_pair(duplex, openDuplexAsync(identifier)); } diff --git a/src/misc/simulation/flightgear/aircraftmodelloaderflightgear.cpp b/src/misc/simulation/flightgear/aircraftmodelloaderflightgear.cpp index 0310c324b..59b5a5547 100644 --- a/src/misc/simulation/flightgear/aircraftmodelloaderflightgear.cpp +++ b/src/misc/simulation/flightgear/aircraftmodelloaderflightgear.cpp @@ -143,7 +143,7 @@ namespace swift::misc::simulation::flightgear if (modelConsolidation) { modelConsolidation(models, true); } return models; }); - m_parserWorker->thenWithResult(this, [=](const auto &models) { + m_parserWorker->thenWithResult(this, [=, this](const auto &models) { this->updateInstalledModels(models); m_loadingMessages.freezeOrder(); emit this->loadingFinished(m_loadingMessages, simulator, ParsedData); diff --git a/src/misc/simulation/interpolation/interpolator.cpp b/src/misc/simulation/interpolation/interpolator.cpp index 79e9a8267..08ac95642 100644 --- a/src/misc/simulation/interpolation/interpolator.cpp +++ b/src/misc/simulation/interpolation/interpolator.cpp @@ -45,7 +45,7 @@ namespace swift::misc::simulation if (remoteProvider) { this->setRemoteAircraftProvider(remoteProvider); - QObject::connect(&m_initTimer, &QTimer::timeout, [=] { this->deferredInit(); }); + QObject::connect(&m_initTimer, &QTimer::timeout, [=, this] { this->deferredInit(); }); m_initTimer.setSingleShot(true); m_initTimer.start(2500); } @@ -386,7 +386,7 @@ namespace swift::misc::simulation CAircraftParts currentParts; // find the first parts earlier than the current time - const auto pivot = std::partition_point(validParts.begin(), validParts.end(), [=](auto &&p) { + const auto pivot = std::partition_point(validParts.begin(), validParts.end(), [=, this](auto &&p) { return p.getAdjustedMSecsSinceEpoch() > m_currentTimeMsSinceEpoch; }); const auto partsNewer = makeRange(validParts.begin(), pivot).reverse(); diff --git a/src/misc/simulation/interpolation/interpolatorlinear.cpp b/src/misc/simulation/interpolation/interpolatorlinear.cpp index 40c82eea7..db9ba4f5e 100644 --- a/src/misc/simulation/interpolation/interpolatorlinear.cpp +++ b/src/misc/simulation/interpolation/interpolatorlinear.cpp @@ -125,7 +125,7 @@ namespace swift::misc::simulation // find the first situation earlier than the current time const auto pivot = - std::partition_point(m_currentSituations.begin(), m_currentSituations.end(), [=](auto &&s) { + std::partition_point(m_currentSituations.begin(), m_currentSituations.end(), [=, this](auto &&s) { return s.getAdjustedMSecsSinceEpoch() > m_currentTimeMsSinceEpoch; }); const auto situationsNewer = makeRange(m_currentSituations.begin(), pivot); diff --git a/src/misc/simulation/xplane/aircraftmodelloaderxplane.cpp b/src/misc/simulation/xplane/aircraftmodelloaderxplane.cpp index b946ae292..01e735922 100644 --- a/src/misc/simulation/xplane/aircraftmodelloaderxplane.cpp +++ b/src/misc/simulation/xplane/aircraftmodelloaderxplane.cpp @@ -120,7 +120,7 @@ namespace swift::misc::simulation::xplane if (modelConsolidation) { modelConsolidation(models, true); } return models; }); - m_parserWorker->thenWithResult(this, [=](const auto &models) { + m_parserWorker->thenWithResult(this, [=, this](const auto &models) { this->updateInstalledModels(models); m_loadingMessages.freezeOrder(); emit this->loadingFinished(m_loadingMessages, simulator, ParsedData); diff --git a/src/misc/threadedtimer.cpp b/src/misc/threadedtimer.cpp index 021c8b028..693ac4f2a 100644 --- a/src/misc/threadedtimer.cpp +++ b/src/misc/threadedtimer.cpp @@ -22,7 +22,7 @@ namespace swift::misc { // shift in correct thread QPointer myself(this); - QTimer::singleShot(0, this, [=] { + QTimer::singleShot(0, this, [=, this] { if (!myself) { return; } this->startTimer(ms); }); @@ -39,7 +39,7 @@ namespace swift::misc { // shift in correct thread QPointer myself(this); - QTimer::singleShot(0, this, [=] { + QTimer::singleShot(0, this, [=, this] { if (!myself) { return; } this->stopTimer(); }); diff --git a/src/plugins/simulator/emulated/simulatoremulated.cpp b/src/plugins/simulator/emulated/simulatoremulated.cpp index 85c2cb4c9..a6a42d7d9 100644 --- a/src/plugins/simulator/emulated/simulatoremulated.cpp +++ b/src/plugins/simulator/emulated/simulatoremulated.cpp @@ -62,7 +62,7 @@ namespace swift::simplugin::emulated bool CSimulatorEmulated::connectTo() { const QPointer myself(this); - QTimer::singleShot(1000, this, [=] { + QTimer::singleShot(1000, this, [=, this] { if (myself.isNull() || !sGui || sGui->isShuttingDown()) { return; } this->emitSimulatorCombinedStatus(); m_monitorWidget->show(); @@ -213,7 +213,7 @@ namespace swift::simplugin::emulated else { elv.setGeodeticHeight(m_pseudoElevation); } QPointer myself(this); - QTimer::singleShot(444, this, [=] { + QTimer::singleShot(444, this, [=, this] { if (!myself) { return; } // updates in providers and emits signal @@ -440,7 +440,7 @@ namespace swift::simplugin::emulated //! \fixme signal name not hardcoded would be nice m_connectionGuard.append(connect( this, &ISimulator::simulatorStatusChanged, this, - [=](SimulatorStatus status) { + [=, this](SimulatorStatus status) { if (!m_monitorWidget) return; m_monitorWidget->appendSendingCall("simulatorStatusChanged", CSimulatorEmulated::statusToString(status)); @@ -449,7 +449,7 @@ namespace swift::simplugin::emulated m_connectionGuard.append(connect( this, &ISimulator::ownAircraftModelChanged, this, - [=](const CAircraftModel &model) { + [=, this](const CAircraftModel &model) { if (!m_monitorWidget) return; m_monitorWidget->appendSendingCall("ownAircraftModelChanged", model.toQString()); }, @@ -457,7 +457,7 @@ namespace swift::simplugin::emulated m_connectionGuard.append(connect( this, &ISimulator::renderRestrictionsChanged, this, - [=](bool restricted, bool enabled, int maxAircraft, const CLength &maxRenderedDistance) { + [=, this](bool restricted, bool enabled, int maxAircraft, const CLength &maxRenderedDistance) { if (!m_monitorWidget) return; static const QString params("restricted: %1 enabled: %2 max aircraft: %3"); m_monitorWidget->appendSendingCall( @@ -469,7 +469,7 @@ namespace swift::simplugin::emulated m_connectionGuard.append(connect( this, &ISimulator::interpolationAndRenderingSetupChanged, this, - [=]() { + [=, this]() { if (!m_monitorWidget) return; m_monitorWidget->appendSendingCall("interpolationAndRenderingSetupChanged"); }, @@ -477,7 +477,7 @@ namespace swift::simplugin::emulated m_connectionGuard.append(connect( this, &ISimulator::aircraftRenderingChanged, this, - [=](const CSimulatedAircraft &aircraft) { + [=, this](const CSimulatedAircraft &aircraft) { if (!m_monitorWidget) return; m_monitorWidget->appendSendingCall("aircraftRenderingChanged", aircraft.toQString()); }, @@ -485,7 +485,7 @@ namespace swift::simplugin::emulated m_connectionGuard.append(connect( this, &ISimulator::physicallyAddingRemoteModelFailed, this, - [=](const CSimulatedAircraft &aircraft) { + [=, this](const CSimulatedAircraft &aircraft) { if (!m_monitorWidget) return; m_monitorWidget->appendSendingCall("physicallyAddingRemoteModelFailed", aircraft.toQString()); }, @@ -493,7 +493,7 @@ namespace swift::simplugin::emulated m_connectionGuard.append(connect( this, &ISimulator::airspaceSnapshotHandled, this, - [=] { + [=, this] { if (!m_monitorWidget) return; m_monitorWidget->appendSendingCall("airspaceSnapshotHandled"); }, @@ -533,7 +533,7 @@ namespace swift::simplugin::emulated { if (this->isShuttingDown()) { return; } const QPointer myself(this); - QTimer::singleShot(2000, this, [=] { + QTimer::singleShot(2000, this, [=, this] { if (!myself) { return; } Q_ASSERT_X(this->getPluginInfo().isValid(), Q_FUNC_INFO, "Invalid plugin"); emit this->simulatorStarted(this->getPluginInfo()); diff --git a/src/plugins/simulator/flightgear/simulatorflightgear.cpp b/src/plugins/simulator/flightgear/simulatorflightgear.cpp index 8f7f0e9e0..edd2062b4 100644 --- a/src/plugins/simulator/flightgear/simulatorflightgear.cpp +++ b/src/plugins/simulator/flightgear/simulatorflightgear.cpp @@ -577,7 +577,7 @@ namespace swift::simplugin::flightgear { // we are just about to add that aircraft QPointer myself(this); - QTimer::singleShot(TimeoutAdding, this, [=] { + QTimer::singleShot(TimeoutAdding, this, [=, this] { if (!myself) { return; } m_addingInProgressAircraft.remove(callsign); // remove as "in progress" this->physicallyRemoveRemoteAircraft(callsign); // and remove from sim. if it was added in the mean time @@ -726,8 +726,8 @@ namespace swift::simplugin::flightgear QPointer myself(this); m_trafficProxy->getRemoteAircraftData( csStrings, - [=](const QStringList &callsigns, const QDoubleList &latitudesDeg, const QDoubleList &longitudesDeg, - const QDoubleList &elevationsMeters, const QDoubleList &verticalOffsetsMeters) { + [=, this](const QStringList &callsigns, const QDoubleList &latitudesDeg, const QDoubleList &longitudesDeg, + const QDoubleList &elevationsMeters, const QDoubleList &verticalOffsetsMeters) { if (!myself) { return; } this->updateRemoteAircraftFromSimulator(callsigns, latitudesDeg, longitudesDeg, elevationsMeters, verticalOffsetsMeters); @@ -738,7 +738,7 @@ namespace swift::simplugin::flightgear { if (callsigns.isEmpty()) { return; } QPointer myself(this); - QTimer::singleShot(0, this, [=] { + QTimer::singleShot(0, this, [=, this] { if (!myself) { return; } this->requestRemoteAircraftDataFromFlightgear(callsigns); }); @@ -936,7 +936,7 @@ namespace swift::simplugin::flightgear void CSimulatorFlightgear::triggerAddNextPendingAircraft() { QPointer myself(this); - QTimer::singleShot(100, this, [=] { + QTimer::singleShot(100, this, [=, this] { if (!myself) { return; } this->addNextPendingAircraft(); }); @@ -966,7 +966,7 @@ namespace swift::simplugin::flightgear void CSimulatorFlightgear::triggerRemoveAircraft(const CCallsign &callsign, qint64 deferMs) { QPointer myself(this); - QTimer::singleShot(deferMs, this, [=] { + QTimer::singleShot(deferMs, this, [=, this] { if (!myself) { return; } this->physicallyRemoveRemoteAircraft(callsign); }); @@ -1022,7 +1022,7 @@ namespace swift::simplugin::flightgear m_timer.start(); // restart because we will check just now QPointer myself(this); - QTimer::singleShot(0, this, [=] { + QTimer::singleShot(0, this, [=, this] { if (!myself) { return; } checkConnection(); }); diff --git a/src/plugins/simulator/xplane/simulatorxplane.cpp b/src/plugins/simulator/xplane/simulatorxplane.cpp index 3c76ea07f..66e7a306a 100644 --- a/src/plugins/simulator/xplane/simulatorxplane.cpp +++ b/src/plugins/simulator/xplane/simulatorxplane.cpp @@ -855,7 +855,7 @@ namespace swift::simplugin::xplane { // we are just about to add that aircraft QPointer myself(this); - QTimer::singleShot(TimeoutAdding, this, [=] { + QTimer::singleShot(TimeoutAdding, this, [=, this] { if (!myself) { return; } m_addingInProgressAircraft.remove(callsign); // remove as "in progress" this->physicallyRemoveRemoteAircraft(callsign); // and remove from sim. if it was added in the mean time @@ -1015,9 +1015,9 @@ namespace swift::simplugin::xplane const QStringList csStrings = callsigns.getCallsignStrings(); QPointer myself(this); m_trafficProxy->getRemoteAircraftData( - csStrings, [=](const QStringList &callsigns, const QDoubleList &latitudesDeg, - const QDoubleList &longitudesDeg, const QDoubleList &elevationsMeters, - const QBoolList &waterFlags, const QDoubleList &verticalOffsetsMeters) { + csStrings, [=, this](const QStringList &callsigns, const QDoubleList &latitudesDeg, + const QDoubleList &longitudesDeg, const QDoubleList &elevationsMeters, + const QBoolList &waterFlags, const QDoubleList &verticalOffsetsMeters) { if (!myself) { return; } this->updateRemoteAircraftFromSimulator(callsigns, latitudesDeg, longitudesDeg, elevationsMeters, waterFlags, verticalOffsetsMeters); @@ -1028,7 +1028,7 @@ namespace swift::simplugin::xplane { if (callsigns.isEmpty()) { return; } QPointer myself(this); - QTimer::singleShot(0, this, [=] { + QTimer::singleShot(0, this, [=, this] { if (!myself) { return; } this->requestRemoteAircraftDataFromXPlane(callsigns); }); @@ -1262,7 +1262,7 @@ namespace swift::simplugin::xplane void CSimulatorXPlane::triggerAddNextPendingAircraft() { QPointer myself(this); - QTimer::singleShot(100, this, [=] { + QTimer::singleShot(100, this, [=, this] { if (!myself || !sApp || sApp->isShuttingDown()) { return; } this->addNextPendingAircraft(); }); @@ -1292,7 +1292,7 @@ namespace swift::simplugin::xplane void CSimulatorXPlane::triggerRemoveAircraft(const CCallsign &callsign, qint64 deferMs) { QPointer myself(this); - QTimer::singleShot(deferMs, this, [=] { + QTimer::singleShot(deferMs, this, [=, this] { if (!myself) { return; } this->physicallyRemoveRemoteAircraft(callsign); }); @@ -1346,7 +1346,7 @@ namespace swift::simplugin::xplane m_timer.start(); // restart because we will check just now QPointer myself(this); - QTimer::singleShot(0, this, [=] { + QTimer::singleShot(0, this, [=, this] { if (!myself) { return; } checkConnection(); }); diff --git a/src/plugins/simulator/xplane/xswiftbustrafficproxy.cpp b/src/plugins/simulator/xplane/xswiftbustrafficproxy.cpp index fcf9140a5..4d8e2e326 100644 --- a/src/plugins/simulator/xplane/xswiftbustrafficproxy.cpp +++ b/src/plugins/simulator/xplane/xswiftbustrafficproxy.cpp @@ -135,7 +135,7 @@ namespace swift::simplugin::xplane void CXSwiftBusTrafficProxy::getRemoteAircraftData(const QStringList &callsigns, const RemoteAircraftDataCallback &setter) const { - std::function callback = [=](QDBusPendingCallWatcher *watcher) { + std::function callback = [=, this](QDBusPendingCallWatcher *watcher) { QDBusPendingReply, QList, QList, QList, QList> reply = *watcher; if (!reply.isError()) diff --git a/src/sound/notificationplayer.cpp b/src/sound/notificationplayer.cpp index bc7862f04..7866adebf 100644 --- a/src/sound/notificationplayer.cpp +++ b/src/sound/notificationplayer.cpp @@ -35,7 +35,7 @@ namespace swift::sound // used for too long or hanging sounds QPointer myself(this); - QTimer::singleShot(3000, effect, [=] { + QTimer::singleShot(3000, effect, [=, this] { if (!myself || !m_playingEffect) { return; } if (currentEffect != m_playingEffectCounter) { return; } m_playingEffect->stop(); diff --git a/src/swiftdata/swiftdata.cpp b/src/swiftdata/swiftdata.cpp index e399f4042..be5c44c00 100644 --- a/src/swiftdata/swiftdata.cpp +++ b/src/swiftdata/swiftdata.cpp @@ -96,7 +96,7 @@ void CSwiftData::init() sGui->triggerNewVersionCheck(20 * 1000); QPointer myself(this); - QTimer::singleShot(15 * 1000, this, [=] { + QTimer::singleShot(15 * 1000, this, [=, this] { if (!myself || !sGui || sGui->isShuttingDown()) { return; } this->checkMinimumVersion(); this->checkAutoPublishing(); diff --git a/src/swiftguistandard/swiftguistdinit.cpp b/src/swiftguistandard/swiftguistdinit.cpp index 7bfee738e..42f006809 100644 --- a/src/swiftguistandard/swiftguistdinit.cpp +++ b/src/swiftguistandard/swiftguistdinit.cpp @@ -188,7 +188,7 @@ void SwiftGuiStd::init() // more checks QPointer myself(this); - QTimer::singleShot(5000, this, [=] { + QTimer::singleShot(5000, this, [=, this] { if (!myself) { return; } this->verifyPrerequisites(); }); diff --git a/src/swiftlauncher/swiftlauncher.cpp b/src/swiftlauncher/swiftlauncher.cpp index d9da57abe..ef0f9be18 100644 --- a/src/swiftlauncher/swiftlauncher.cpp +++ b/src/swiftlauncher/swiftlauncher.cpp @@ -114,7 +114,7 @@ CSwiftLauncher::CSwiftLauncher(bool installerMode, QWidget *parent) const QPointer myself(this); if (installerMode) { - QTimer::singleShot(1000, this, [=] { + QTimer::singleShot(1000, this, [=, this] { if (!sGui || sGui->isShuttingDown() || !myself) { return; } ui->fr_SwiftLauncherMain->showOverlayHTMLMessage("Checking installation!
One moment please ...."); this->raise(); @@ -122,7 +122,7 @@ CSwiftLauncher::CSwiftLauncher(bool installerMode, QWidget *parent) } // auto launch wizard and other init parts - QTimer::singleShot(2500, this, [=] { + QTimer::singleShot(2500, this, [=, this] { if (!sGui || sGui->isShuttingDown() || !myself) { return; } this->onCoreModeReleased(); this->requestMacMicrophoneAccess(); diff --git a/src/xswiftbus/service.cpp b/src/xswiftbus/service.cpp index 93f26d604..056468ef9 100644 --- a/src/xswiftbus/service.cpp +++ b/src/xswiftbus/service.cpp @@ -267,6 +267,7 @@ namespace XSwiftBus static const char *introspection_service = DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE #include "org.swift_project.xswiftbus.service.xml" + ; DBusHandlerResult CService::dbusMessageHandler(const CDBusMessage &message_) @@ -284,11 +285,11 @@ namespace XSwiftBus { if (message.getMethodName() == "getVersionNumber") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getVersionNumber()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getVersionNumber()); }); } else if (message.getMethodName() == "getCommitHash") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getCommitHash()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getCommitHash()); }); } else if (message.getMethodName() == "addTextMessage") { @@ -303,11 +304,11 @@ namespace XSwiftBus message.getArgument(green); message.getArgument(blue); - queueDBusCall([=]() { addTextMessage(text, red, green, blue); }); + queueDBusCall([=, this]() { addTextMessage(text, red, green, blue); }); } else if (message.getMethodName() == "getOwnAircraftSituationData") { - queueDBusCall([=]() { + queueDBusCall([=, this]() { const double lat = m_latitude.get(); const double lon = m_longitude.get(); const double alt = m_elevation.get(); @@ -331,7 +332,7 @@ namespace XSwiftBus } else if (message.getMethodName() == "getOwnAircraftVelocityData") { - queueDBusCall([=]() { + queueDBusCall([=, this]() { const double velocityX = m_velocityX.get(); const double velocityY = m_velocityY.get(); const double velocityZ = m_velocityZ.get(); @@ -351,7 +352,7 @@ namespace XSwiftBus } else if (message.getMethodName() == "getOwnAircraftCom1Data") { - queueDBusCall([=]() { + queueDBusCall([=, this]() { const int active = m_com1Active.get(); const int standby = m_com1Standby.get(); const double volume = m_com1Volume.get(); @@ -369,7 +370,7 @@ namespace XSwiftBus } else if (message.getMethodName() == "getOwnAircraftCom2Data") { - queueDBusCall([=]() { + queueDBusCall([=, this]() { const int active = m_com2Active.get(); const int standby = m_com2Standby.get(); const double volume = m_com2Volume.get(); @@ -387,7 +388,7 @@ namespace XSwiftBus } else if (message.getMethodName() == "getOwnAircraftXpdr") { - queueDBusCall([=]() { + queueDBusCall([=, this]() { const int code = m_xpdrCode.get(); const int mode = m_xpdrMode.get(); const bool id = m_xpdrIdent.get(); @@ -401,7 +402,7 @@ namespace XSwiftBus } else if (message.getMethodName() == "getOwnAircraftLights") { - queueDBusCall([=]() { + queueDBusCall([=, this]() { const bool beaconLightsOn = m_beaconLightsOn.get(); const bool landingLightsOn = m_landingLightsOn.get(); const bool navLightsOn = m_navLightsOn.get(); @@ -419,7 +420,7 @@ namespace XSwiftBus } else if (message.getMethodName() == "getOwnAircraftParts") { - queueDBusCall([=]() { + queueDBusCall([=, this]() { const double flapsReployRatio = m_flapsReployRatio.get(); const double gearReployRatio = m_gearReployRatio.getAt(0); const double speedBrakeRatio = m_speedBrakeRatio.get(); @@ -435,7 +436,7 @@ namespace XSwiftBus } else if (message.getMethodName() == "getOwnAircraftModelData") { - queueDBusCall([=]() { + queueDBusCall([=, this]() { const std::string aircraftModelPath = this->getAircraftModelPath(); const std::string aircraftIcaoCode = this->getAircraftIcaoCode(); CDBusMessage reply = CDBusMessage::createReply(sender, serial); @@ -447,59 +448,59 @@ namespace XSwiftBus } else if (message.getMethodName() == "getAircraftModelPath") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getAircraftModelPath()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getAircraftModelPath()); }); } else if (message.getMethodName() == "getAircraftModelFilename") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getAircraftModelFilename()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getAircraftModelFilename()); }); } else if (message.getMethodName() == "getAircraftModelString") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getAircraftModelString()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getAircraftModelString()); }); } else if (message.getMethodName() == "getAircraftName") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getAircraftName()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getAircraftName()); }); } else if (message.getMethodName() == "getAircraftLivery") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getAircraftLivery()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getAircraftLivery()); }); } else if (message.getMethodName() == "getAircraftIcaoCode") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getAircraftIcaoCode()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getAircraftIcaoCode()); }); } else if (message.getMethodName() == "getAircraftDescription") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getAircraftDescription()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getAircraftDescription()); }); } else if (message.getMethodName() == "getXPlaneVersionMajor") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getXPlaneVersionMajor()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getXPlaneVersionMajor()); }); } else if (message.getMethodName() == "getXPlaneVersionMinor") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getXPlaneVersionMinor()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getXPlaneVersionMinor()); }); } else if (message.getMethodName() == "getXPlaneInstallationPath") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getXPlaneInstallationPath()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getXPlaneInstallationPath()); }); } else if (message.getMethodName() == "getXPlanePreferencesPath") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getXPlanePreferencesPath()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getXPlanePreferencesPath()); }); } else if (message.getMethodName() == "isPaused") { - queueDBusCall([=]() { sendDBusReply(sender, serial, isPaused()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, isPaused()); }); } else if (message.getMethodName() == "isUsingRealTime") { - queueDBusCall([=]() { sendDBusReply(sender, serial, isUsingRealTime()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, isUsingRealTime()); }); } else if (message.getMethodName() == "getFrameStats") { - queueDBusCall([=]() { + queueDBusCall([=, this]() { const auto stats = getFrameStats(); CDBusMessage reply = CDBusMessage::createReply(sender, serial); reply.beginArgumentWrite(); @@ -513,7 +514,7 @@ namespace XSwiftBus else if (message.getMethodName() == "resetFrameTotals") { maybeSendEmptyDBusReply(wantsReply, sender, serial); - queueDBusCall([=]() { resetFrameTotals(); }); + queueDBusCall([=, this]() { resetFrameTotals(); }); } else if (message.getMethodName() == "setFlightNetworkConnected") { @@ -521,7 +522,7 @@ namespace XSwiftBus bool connected = false; message.beginArgumentRead(); message.getArgument(connected); - queueDBusCall([=]() { setFlightNetworkConnected(connected); }); + queueDBusCall([=, this]() { setFlightNetworkConnected(connected); }); } else if (message.getMethodName() == "setOwnCallsign") { @@ -529,163 +530,163 @@ namespace XSwiftBus std::string callsign; message.beginArgumentRead(); message.getArgument(callsign); - queueDBusCall([=]() { setOwnCallsign(callsign); }); + queueDBusCall([=, this]() { setOwnCallsign(callsign); }); } else if (message.getMethodName() == "getLatitudeDeg") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getLatitudeDeg()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getLatitudeDeg()); }); } else if (message.getMethodName() == "getLongitudeDeg") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getLongitudeDeg()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getLongitudeDeg()); }); } else if (message.getMethodName() == "getAltitudeMslM") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getAltitudeMslM()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getAltitudeMslM()); }); } else if (message.getMethodName() == "getPressureAltitudeFt") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getPressureAltitudeFt()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getPressureAltitudeFt()); }); } else if (message.getMethodName() == "getHeightAglM") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getHeightAglM()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getHeightAglM()); }); } else if (message.getMethodName() == "getGroundSpeedMps") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getGroundSpeedMps()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getGroundSpeedMps()); }); } else if (message.getMethodName() == "getIndicatedAirspeedKias") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getIndicatedAirspeedKias()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getIndicatedAirspeedKias()); }); } else if (message.getMethodName() == "getTrueAirspeedKias") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getTrueAirspeedKias()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getTrueAirspeedKias()); }); } else if (message.getMethodName() == "getPitchDeg") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getPitchDeg()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getPitchDeg()); }); } else if (message.getMethodName() == "getRollDeg") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getRollDeg()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getRollDeg()); }); } else if (message.getMethodName() == "getTrueHeadingDeg") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getTrueHeadingDeg()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getTrueHeadingDeg()); }); } else if (message.getMethodName() == "getLocalXVelocityXMps") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getLocalXVelocityMps()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getLocalXVelocityMps()); }); } else if (message.getMethodName() == "getLocalYVelocityYMps") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getLocalYVelocityMps()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getLocalYVelocityMps()); }); } else if (message.getMethodName() == "getLocalZVelocityZMps") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getLocalZVelocityMps()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getLocalZVelocityMps()); }); } else if (message.getMethodName() == "getPitchRadPerSec") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getPitchRadPerSec()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getPitchRadPerSec()); }); } else if (message.getMethodName() == "getRollRadPerSec") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getRollRadPerSec()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getRollRadPerSec()); }); } else if (message.getMethodName() == "getHeadingRadPerSec") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getHeadingRadPerSec()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getHeadingRadPerSec()); }); } else if (message.getMethodName() == "getAnyWheelOnGround") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getAnyWheelOnGround()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getAnyWheelOnGround()); }); } else if (message.getMethodName() == "getAllWheelsOnGround") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getAllWheelsOnGround()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getAllWheelsOnGround()); }); } else if (message.getMethodName() == "getGroundElevation") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getGroundElevation()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getGroundElevation()); }); } else if (message.getMethodName() == "getCom1ActiveKhz") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getCom1ActiveKhz()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getCom1ActiveKhz()); }); } else if (message.getMethodName() == "getCom1StandbyKhz") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getCom1StandbyKhz()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getCom1StandbyKhz()); }); } else if (message.getMethodName() == "getCom2ActiveKhz") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getCom2ActiveKhz()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getCom2ActiveKhz()); }); } else if (message.getMethodName() == "getCom2StandbyKhz") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getCom2StandbyKhz()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getCom2StandbyKhz()); }); } else if (message.getMethodName() == "isCom1Receiving") { - queueDBusCall([=]() { sendDBusReply(sender, serial, isCom1Receiving()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, isCom1Receiving()); }); } else if (message.getMethodName() == "isCom1Transmitting") { - queueDBusCall([=]() { sendDBusReply(sender, serial, isCom1Transmitting()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, isCom1Transmitting()); }); } else if (message.getMethodName() == "getCom1Volume") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getCom1Volume()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getCom1Volume()); }); } else if (message.getMethodName() == "isCom2Receiving") { - queueDBusCall([=]() { sendDBusReply(sender, serial, isCom2Receiving()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, isCom2Receiving()); }); } else if (message.getMethodName() == "isCom2Transmitting") { - queueDBusCall([=]() { sendDBusReply(sender, serial, isCom2Transmitting()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, isCom2Transmitting()); }); } else if (message.getMethodName() == "getCom2Volume") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getCom2Volume()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getCom2Volume()); }); } else if (message.getMethodName() == "getTransponderCode") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getTransponderCode()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getTransponderCode()); }); } else if (message.getMethodName() == "getTransponderMode") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getTransponderMode()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getTransponderMode()); }); } else if (message.getMethodName() == "getTransponderIdent") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getTransponderIdent()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getTransponderIdent()); }); } else if (message.getMethodName() == "getBeaconLightsOn") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getBeaconLightsOn()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getBeaconLightsOn()); }); } else if (message.getMethodName() == "getLandingLightsOn") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getLandingLightsOn()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getLandingLightsOn()); }); } else if (message.getMethodName() == "getTaxiLightsOn") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getTaxiLightsOn()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getTaxiLightsOn()); }); } else if (message.getMethodName() == "getNavLightsOn") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getNavLightsOn()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getNavLightsOn()); }); } else if (message.getMethodName() == "getStrobeLightsOn") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getStrobeLightsOn()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getStrobeLightsOn()); }); } else if (message.getMethodName() == "getQNHInHg") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getQNHInHg()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getQNHInHg()); }); } else if (message.getMethodName() == "setCom1ActiveKhz") { @@ -693,7 +694,7 @@ namespace XSwiftBus int frequency = 0; message.beginArgumentRead(); message.getArgument(frequency); - queueDBusCall([=]() { setCom1ActiveKhz(frequency); }); + queueDBusCall([=, this]() { setCom1ActiveKhz(frequency); }); } else if (message.getMethodName() == "setCom1StandbyKhz") { @@ -701,7 +702,7 @@ namespace XSwiftBus int frequency = 0; message.beginArgumentRead(); message.getArgument(frequency); - queueDBusCall([=]() { setCom1StandbyKhz(frequency); }); + queueDBusCall([=, this]() { setCom1StandbyKhz(frequency); }); } else if (message.getMethodName() == "setCom2ActiveKhz") { @@ -709,7 +710,7 @@ namespace XSwiftBus int frequency = 0; message.beginArgumentRead(); message.getArgument(frequency); - queueDBusCall([=]() { setCom2ActiveKhz(frequency); }); + queueDBusCall([=, this]() { setCom2ActiveKhz(frequency); }); } else if (message.getMethodName() == "setCom2StandbyKhz") { @@ -717,7 +718,7 @@ namespace XSwiftBus int frequency = 0; message.beginArgumentRead(); message.getArgument(frequency); - queueDBusCall([=]() { setCom2StandbyKhz(frequency); }); + queueDBusCall([=, this]() { setCom2StandbyKhz(frequency); }); } else if (message.getMethodName() == "setTransponderCode") { @@ -725,7 +726,7 @@ namespace XSwiftBus int code = 0; message.beginArgumentRead(); message.getArgument(code); - queueDBusCall([=]() { setTransponderCode(code); }); + queueDBusCall([=, this]() { setTransponderCode(code); }); } else if (message.getMethodName() == "setTransponderMode") { @@ -733,34 +734,34 @@ namespace XSwiftBus int mode = 0; message.beginArgumentRead(); message.getArgument(mode); - queueDBusCall([=]() { setTransponderMode(mode); }); + queueDBusCall([=, this]() { setTransponderMode(mode); }); } else if (message.getMethodName() == "getFlapsDeployRatio") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getFlapsDeployRatio()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getFlapsDeployRatio()); }); } else if (message.getMethodName() == "getGearDeployRatio") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getGearDeployRatio()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getGearDeployRatio()); }); } else if (message.getMethodName() == "getNumberOfEngines") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getNumberOfEngines()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getNumberOfEngines()); }); } else if (message.getMethodName() == "getEngineN1Percentage") { - queueDBusCall([=]() { + queueDBusCall([=, this]() { const std::vector enginesN1Percentage = getEngineN1Percentage(); sendDBusReply(sender, serial, enginesN1Percentage); }); } else if (message.getMethodName() == "getSpeedBrakeRatio") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getSpeedBrakeRatio()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getSpeedBrakeRatio()); }); } else if (message.getMethodName() == "getSettingsJson") { - queueDBusCall([=]() { sendDBusReply(sender, serial, getSettingsJson()); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, getSettingsJson()); }); } else if (message.getMethodName() == "setSettingsJson") { @@ -768,7 +769,7 @@ namespace XSwiftBus std::string json; message.beginArgumentRead(); message.getArgument(json); - queueDBusCall([=]() { setSettingsJson(json); }); + queueDBusCall([=, this]() { setSettingsJson(json); }); } else { diff --git a/src/xswiftbus/traffic.cpp b/src/xswiftbus/traffic.cpp index 2c6ea3325..9cd87b7a4 100644 --- a/src/xswiftbus/traffic.cpp +++ b/src/xswiftbus/traffic.cpp @@ -567,7 +567,7 @@ namespace XSwiftBus { if (message.getMethodName() == "acquireMultiplayerPlanes") { - queueDBusCall([=]() { + queueDBusCall([=, this]() { std::string owner; bool acquired = acquireMultiplayerPlanes(&owner); CDBusMessage reply = CDBusMessage::createReply(sender, serial); @@ -581,21 +581,21 @@ namespace XSwiftBus else if (message.getMethodName() == "cleanup") { maybeSendEmptyDBusReply(wantsReply, sender, serial); - queueDBusCall([=]() { cleanup(); }); + queueDBusCall([=, this]() { cleanup(); }); } else if (message.getMethodName() == "loadPlanesPackage") { std::string path; message.beginArgumentRead(); message.getArgument(path); - queueDBusCall([=]() { sendDBusReply(sender, serial, loadPlanesPackage(path)); }); + queueDBusCall([=, this]() { sendDBusReply(sender, serial, loadPlanesPackage(path)); }); } else if (message.getMethodName() == "setDefaultIcao") { std::string defaultIcao; message.beginArgumentRead(); message.getArgument(defaultIcao); - queueDBusCall([=]() { setDefaultIcao(defaultIcao); }); + queueDBusCall([=, this]() { setDefaultIcao(defaultIcao); }); } else if (message.getMethodName() == "setMaxPlanes") { @@ -603,7 +603,7 @@ namespace XSwiftBus int planes = 100; message.beginArgumentRead(); message.getArgument(planes); - queueDBusCall([=]() { setMaxPlanes(planes); }); + queueDBusCall([=, this]() { setMaxPlanes(planes); }); } else if (message.getMethodName() == "setMaxDrawDistance") { @@ -611,7 +611,7 @@ namespace XSwiftBus double nauticalMiles = 100; message.beginArgumentRead(); message.getArgument(nauticalMiles); - queueDBusCall([=]() { setMaxDrawDistance(nauticalMiles); }); + queueDBusCall([=, this]() { setMaxDrawDistance(nauticalMiles); }); } else if (message.getMethodName() == "addPlane") { @@ -628,7 +628,7 @@ namespace XSwiftBus message.getArgument(airlineIcao); message.getArgument(livery); - queueDBusCall([=]() { addPlane(callsign, modelName, aircraftIcao, airlineIcao, livery); }); + queueDBusCall([=, this]() { addPlane(callsign, modelName, aircraftIcao, airlineIcao, livery); }); } else if (message.getMethodName() == "removePlane") { @@ -636,12 +636,12 @@ namespace XSwiftBus std::string callsign; message.beginArgumentRead(); message.getArgument(callsign); - queueDBusCall([=]() { removePlane(callsign); }); + queueDBusCall([=, this]() { removePlane(callsign); }); } else if (message.getMethodName() == "removeAllPlanes") { maybeSendEmptyDBusReply(wantsReply, sender, serial); - queueDBusCall([=]() { removeAllPlanes(); }); + queueDBusCall([=, this]() { removeAllPlanes(); }); } else if (message.getMethodName() == "setPlanesPositions") { @@ -663,7 +663,7 @@ namespace XSwiftBus message.getArgument(rolls); message.getArgument(headings); message.getArgument(onGrounds); - queueDBusCall([=]() { + queueDBusCall([=, this]() { setPlanesPositions(callsigns, latitudes, longitudes, altitudes, pitches, rolls, headings, onGrounds); }); @@ -706,7 +706,7 @@ namespace XSwiftBus message.getArgument(strobeLights); message.getArgument(navLights); message.getArgument(lightPatterns); - queueDBusCall([=]() { + queueDBusCall([=, this]() { setPlanesSurfaces(callsigns, gears, flaps, spoilers, speedBrakes, slats, wingSweeps, thrusts, elevators, rudders, ailerons, landLights, taxiLights, beaconLights, strobeLights, navLights, lightPatterns); @@ -724,14 +724,14 @@ namespace XSwiftBus message.getArgument(codes); message.getArgument(modeCs); message.getArgument(idents); - queueDBusCall([=]() { setPlanesTransponders(callsigns, codes, modeCs, idents); }); + queueDBusCall([=, this]() { setPlanesTransponders(callsigns, codes, modeCs, idents); }); } else if (message.getMethodName() == "getRemoteAircraftData") { std::vector requestedCallsigns; message.beginArgumentRead(); message.getArgument(requestedCallsigns); - queueDBusCall([=]() { + queueDBusCall([=, this]() { std::vector callsigns = requestedCallsigns; std::vector latitudesDeg; std::vector longitudesDeg; @@ -762,7 +762,7 @@ namespace XSwiftBus message.getArgument(latitudeDeg); message.getArgument(longitudeDeg); message.getArgument(altitudeMeters); - queueDBusCall([=]() { + queueDBusCall([=, this]() { bool isWater = false; const auto elevation = getElevationAtPosition(callsign, latitudeDeg, longitudeDeg, altitudeMeters, isWater); @@ -782,7 +782,7 @@ namespace XSwiftBus std::string callsign; message.beginArgumentRead(); message.getArgument(callsign); - queueDBusCall([=]() { setFollowedAircraft(callsign); }); + queueDBusCall([=, this]() { setFollowedAircraft(callsign); }); } else {