diff --git a/plasmoid/declarativeplugin/responsewaiter.cpp b/plasmoid/declarativeplugin/responsewaiter.cpp index b8327a91d..725e8dec0 100644 --- a/plasmoid/declarativeplugin/responsewaiter.cpp +++ b/plasmoid/declarativeplugin/responsewaiter.cpp @@ -3,9 +3,6 @@ #include #include #include -#include -#include -#include #include "responsewaiter.h" @@ -43,6 +40,12 @@ QVariant DBusResponseWaiter::waitForReply(QVariant variant) const if (QDBusPendingCall* call = const_cast(extractPendingCall(variant))) { call->waitForFinished(); + + if (call->isError()) + { + return QVariant("error"); + } + QDBusMessage reply = call->reply(); if (reply.arguments().count() > 0) @@ -64,7 +67,6 @@ void DBusAsyncResponse::setPendingCall(QVariant variant) }; } - void DBusAsyncResponse::onCallFinished(QDBusPendingCallWatcher* watcher) { QVariant variant = watcher->property("pengingCall"); @@ -89,7 +91,10 @@ void DBusAsyncResponse::onCallFinished(QDBusPendingCallWatcher* watcher) } } } - deleteLater(); + if (m_autodelete) + { + deleteLater(); + } } const QDBusPendingCall* DBusResponseWaiter::extractPendingCall(QVariant& variant) const diff --git a/plasmoid/declarativeplugin/responsewaiter.h b/plasmoid/declarativeplugin/responsewaiter.h index ea57370e1..aaeb9fefc 100644 --- a/plasmoid/declarativeplugin/responsewaiter.h +++ b/plasmoid/declarativeplugin/responsewaiter.h @@ -37,12 +37,14 @@ class DBusAsyncResponse : public QObject Q_OBJECT Q_PROPERTY(QVariant pendingCall WRITE setPendingCall) + Q_PROPERTY(bool autoDelete WRITE setAutodelete) public: - DBusAsyncResponse(QObject* parent = 0) : QObject(parent) {} - virtual ~DBusAsyncResponse() {}; + DBusAsyncResponse(QObject* parent = 0) : QObject(parent), m_autodelete(false) {} + virtual ~DBusAsyncResponse() {}; void setPendingCall(QVariant e); + void setAutodelete(bool b) {m_autodelete = b;}; Q_SIGNALS: void success(QVariant result); @@ -50,6 +52,9 @@ Q_SIGNALS: private Q_SLOTS: void onCallFinished(QDBusPendingCallWatcher* watcher); + +private: + bool m_autodelete; };