diff --git a/components/hapticsplugin/vibrationmanager.cpp b/components/hapticsplugin/vibrationmanager.cpp index 77f76180..9e3cd6cb 100644 --- a/components/hapticsplugin/vibrationmanager.cpp +++ b/components/hapticsplugin/vibrationmanager.cpp @@ -3,6 +3,8 @@ #include "vibrationmanager.h" +#include + VibrationManager::VibrationManager(QObject *parent) : QObject{parent} { @@ -21,8 +23,14 @@ QCoro::Task VibrationManager::vibrateTask(int durationMs) const QString appId = QStringLiteral("org.kde.plasmashell"); const VibrationEvent event{1.0, static_cast(durationMs)}; const VibrationEventList pattern = {event}; + + QPointer guard(this); QDBusPendingReply reply = co_await m_interface->Vibrate(appId, pattern); + if (!guard) { + co_return; + } + if (!reply.isValid() || !reply.value()) { qWarning() << "feedbackd vibration failed"; } diff --git a/components/mmplugin/signalindicator.cpp b/components/mmplugin/signalindicator.cpp index 0ff27e09..84023bdf 100644 --- a/components/mmplugin/signalindicator.cpp +++ b/components/mmplugin/signalindicator.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -226,7 +227,13 @@ QCoro::Task SignalIndicator::activateProfile(const QString &connectionUni) // activate connection manually // despite the documentation saying otherwise, activateConnection seems to need the DBus path, not uuid of the connection + QPointer guard(this); QDBusReply reply = co_await NetworkManager::activateConnection(con->path(), m_nmModem->uni(), {}); + + if (!guard) { + co_return; + } + if (!reply.isValid()) { qWarning() << QStringLiteral("Error activating connection:") << reply.error().message(); co_return; @@ -255,7 +262,13 @@ QCoro::Task SignalIndicator::addProfile(const QString &name, const QString gsmSetting->setInitialized(true); + QPointer guard(this); QDBusReply reply = co_await NetworkManager::addAndActivateConnection(settings->toMap(), m_nmModem->uni(), {}); + + if (!guard) { + co_return; + } + if (!reply.isValid()) { qWarning() << "Error adding connection:" << reply.error().message(); } else { @@ -271,7 +284,13 @@ QCoro::Task SignalIndicator::removeProfile(const QString &connectionUni) co_return; } + QPointer guard(this); QDBusPendingReply reply = co_await con->remove(); + + if (!guard) { + co_return; + } + if (!reply.isValid()) { qWarning() << "Error removing connection" << reply.error().message(); } @@ -307,7 +326,13 @@ QCoro::Task SignalIndicator::updateProfile(const QString &connectionUni, gsmSetting->setInitialized(true); + QPointer guard(this); QDBusPendingReply reply = co_await con->update(conSettings->toMap()); + + if (!guard) { + co_return; + } + if (!reply.isValid()) { qWarning() << "Error updating connection settings for" << connectionUni << ":" << reply.error().message() << "."; } else { diff --git a/components/wallpaperimageplugin/wallpaperplugin.cpp b/components/wallpaperimageplugin/wallpaperplugin.cpp index fe159e08..a9bd3e3b 100644 --- a/components/wallpaperimageplugin/wallpaperplugin.cpp +++ b/components/wallpaperimageplugin/wallpaperplugin.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -171,7 +172,13 @@ QCoro::Task WallpaperPlugin::setHomescreenWallpaper(const QString &path) for (uint screen = 0; screen < qApp->screens().size(); screen++) { message.setArguments({"org.kde.image", QVariantMap{{"Image", path}}, screen}); + QPointer guard(this); const QDBusReply reply = co_await QDBusConnection::sessionBus().asyncCall(message); + + if (!guard) { + co_return; + } + if (!reply.isValid()) { qWarning() << "Failed to set wallpaper for screen" << screen << ":" << reply.error(); } @@ -210,7 +217,13 @@ QCoro::Task WallpaperPlugin::loadHomescreenSettings() QLatin1String("wallpaper")); message.setArguments({(uint)0}); // assume wallpaper on first screen + QPointer guard(this); QDBusReply reply = co_await QDBusConnection::sessionBus().asyncCall(message); + + if (!guard) { + co_return; + } + if (!reply.isValid()) { qWarning() << "unable to load homescreen wallpaper settings:" << reply.error(); co_return; @@ -317,7 +330,13 @@ QCoro::Task WallpaperPlugin::saveHomescreenSettings() for (uint screen = 0; screen < qApp->screens().size(); screen++) { QList args = {m_homescreenWallpaperPlugin, params, screen}; + QPointer guard(this); const QDBusReply response = co_await iface->asyncCallWithArgumentList(QStringLiteral("setWallpaper"), args); + + if (!guard) { + co_return; + } + if (!response.isValid()) { qWarning() << "Failed to set wallpaper:" << response.error(); } diff --git a/components/waydroidintegrationplugin/waydroiddbusclient.cpp b/components/waydroidintegrationplugin/waydroiddbusclient.cpp index 0f122fcd..45f343c4 100644 --- a/components/waydroidintegrationplugin/waydroiddbusclient.cpp +++ b/components/waydroidintegrationplugin/waydroiddbusclient.cpp @@ -133,8 +133,7 @@ WaydroidApplicationListModel *WaydroidDBusClient::applicationListModel() const QCoro::Task WaydroidDBusClient::setMultiWindowsTask(const bool multiWindows) { - auto pendingReply = m_interface->setMultiWindows(multiWindows); - co_await pendingReply; + co_await m_interface->setMultiWindows(multiWindows); } QCoro::QmlTask WaydroidDBusClient::setMultiWindows(const bool multiWindows) @@ -149,8 +148,7 @@ bool WaydroidDBusClient::multiWindows() const QCoro::Task WaydroidDBusClient::setSuspendTask(const bool suspend) { - auto pendingReply = m_interface->setSuspend(suspend); - co_await pendingReply; + co_await m_interface->setSuspend(suspend); } QCoro::QmlTask WaydroidDBusClient::setSuspend(const bool suspend) @@ -165,8 +163,7 @@ bool WaydroidDBusClient::suspend() const QCoro::Task WaydroidDBusClient::setUeventTask(const bool uevent) { - auto pendingReply = m_interface->setUevent(uevent); - co_await pendingReply; + co_await m_interface->setUevent(uevent); } QCoro::QmlTask WaydroidDBusClient::setUevent(const bool uevent) @@ -176,8 +173,7 @@ QCoro::QmlTask WaydroidDBusClient::setUevent(const bool uevent) QCoro::Task WaydroidDBusClient::refreshSessionInfoTask() { - auto pendingReply = m_interface->refreshSessionInfo(); - co_await pendingReply; + co_await m_interface->refreshSessionInfo(); } QCoro::QmlTask WaydroidDBusClient::refreshSessionInfo() @@ -187,8 +183,7 @@ QCoro::QmlTask WaydroidDBusClient::refreshSessionInfo() QCoro::Task WaydroidDBusClient::refreshAndroidIdTask() { - auto pendingReply = m_interface->refreshAndroidId(); - co_await pendingReply; + co_await m_interface->refreshAndroidId(); } QCoro::QmlTask WaydroidDBusClient::refreshAndroidId() @@ -198,8 +193,7 @@ QCoro::QmlTask WaydroidDBusClient::refreshAndroidId() QCoro::Task WaydroidDBusClient::refreshApplicationsTask() { - auto pendingReply = m_interface->refreshApplications(); - co_await pendingReply; + co_await m_interface->refreshApplications(); } QCoro::QmlTask WaydroidDBusClient::refreshApplications() @@ -214,8 +208,7 @@ bool WaydroidDBusClient::uevent() const QCoro::Task WaydroidDBusClient::initializeTask(const SystemType systemType, const RomType romType, const bool forced) { - auto pendingReply = m_interface->initialize(systemType, romType, forced); - co_await pendingReply; + co_await m_interface->initialize(systemType, romType, forced); } QCoro::QmlTask WaydroidDBusClient::initialize(const SystemType systemType, const RomType romType, const bool forced) @@ -225,8 +218,7 @@ QCoro::QmlTask WaydroidDBusClient::initialize(const SystemType systemType, const QCoro::Task WaydroidDBusClient::startSessionTask() { - auto pendingReply = m_interface->startSession(); - co_await pendingReply; + co_await m_interface->startSession(); } QCoro::QmlTask WaydroidDBusClient::startSession() @@ -236,8 +228,7 @@ QCoro::QmlTask WaydroidDBusClient::startSession() QCoro::Task WaydroidDBusClient::stopSessionTask() { - auto pendingReply = m_interface->stopSession(); - co_await pendingReply; + co_await m_interface->stopSession(); } QCoro::QmlTask WaydroidDBusClient::stopSession() @@ -247,8 +238,7 @@ QCoro::QmlTask WaydroidDBusClient::stopSession() QCoro::Task WaydroidDBusClient::resetWaydroidTask() { - auto pendingReply = m_interface->resetWaydroid(); - co_await pendingReply; + co_await m_interface->resetWaydroid(); } QCoro::QmlTask WaydroidDBusClient::resetWaydroid() @@ -258,8 +248,7 @@ QCoro::QmlTask WaydroidDBusClient::resetWaydroid() QCoro::Task WaydroidDBusClient::installApkTask(const QString apkFile) { - auto pendingReply = m_interface->installApk(apkFile); - co_await pendingReply; + co_await m_interface->installApk(apkFile); } QCoro::QmlTask WaydroidDBusClient::installApk(const QString apkFile) @@ -269,8 +258,7 @@ QCoro::QmlTask WaydroidDBusClient::installApk(const QString apkFile) QCoro::Task WaydroidDBusClient::deleteApplicationTask(const QString appId) { - auto pendingReply = m_interface->deleteApplication(appId); - co_await pendingReply; + co_await m_interface->deleteApplication(appId); } QCoro::QmlTask WaydroidDBusClient::deleteApplication(const QString appId) diff --git a/kded/autodetectapn/autodetectapn.cpp b/kded/autodetectapn/autodetectapn.cpp index 80a5721c..ccaefa5c 100644 --- a/kded/autodetectapn/autodetectapn.cpp +++ b/kded/autodetectapn/autodetectapn.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -106,7 +107,13 @@ QCoro::Task AutoDetectAPN::checkAndAddAutodetectedAPN() ipv6Setting->setInitialized(true); } + QPointer guard(this); QDBusReply reply = co_await NetworkManager::addAndActivateConnection(settings->toMap(), nmModem->uni(), ""); + + if (!guard) { + co_return; + } + if (!reply.isValid()) { qCWarning(LOGGING_CATEGORY) << "Error adding autodetected connection:" << reply.error().message(); } else {