From fb8fa53f8d019b33a42bd4bc40c7b01a40a366d9 Mon Sep 17 00:00:00 2001 From: Samoilenko Yuri Date: Thu, 6 Feb 2014 19:25:22 +0400 Subject: [PATCH] some fixes --- plasmoid/declarativeplugin/responsewaiter.cpp | 22 +++++++++++++++++-- plasmoid/declarativeplugin/responsewaiter.h | 8 ++++--- plasmoid/package/contents/ui/Sftp.qml | 2 +- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/plasmoid/declarativeplugin/responsewaiter.cpp b/plasmoid/declarativeplugin/responsewaiter.cpp index 725e8dec0..e909842c2 100644 --- a/plasmoid/declarativeplugin/responsewaiter.cpp +++ b/plasmoid/declarativeplugin/responsewaiter.cpp @@ -56,20 +56,33 @@ QVariant DBusResponseWaiter::waitForReply(QVariant variant) const return QVariant(); } +DBusAsyncResponse::DBusAsyncResponse(QObject* parent) + : QObject(parent) + , m_autodelete(false) +{ + m_timeout.setSingleShot(true); + m_timeout.setInterval(15000); + connect(&m_timeout, SIGNAL(timeout()), this, SLOT(onTimeout())); +} + + void DBusAsyncResponse::setPendingCall(QVariant variant) { if (QDBusPendingCall* call = const_cast(DBusResponseWaiter::instance()->extractPendingCall(variant))) { QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(*call); - watcher->setProperty("pengingCall", variant); + watcher->setProperty("pengingCallVariant", variant); connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(onCallFinished(QDBusPendingCallWatcher*))); connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), watcher, SLOT(deleteLater())); + connect(&m_timeout, SIGNAL(timeout()), watcher, SLOT(deleteLater())); + m_timeout.start(); }; } void DBusAsyncResponse::onCallFinished(QDBusPendingCallWatcher* watcher) { - QVariant variant = watcher->property("pengingCall"); + m_timeout.stop(); + QVariant variant = watcher->property("pengingCallVariant"); if (QDBusPendingCall* call = const_cast(DBusResponseWaiter::instance()->extractPendingCall(variant))) { @@ -97,6 +110,11 @@ void DBusAsyncResponse::onCallFinished(QDBusPendingCallWatcher* watcher) } } +void DBusAsyncResponse::onTimeout() +{ + Q_EMIT error("timeout when waiting dbus response!"); +} + const QDBusPendingCall* DBusResponseWaiter::extractPendingCall(QVariant& variant) const { Q_FOREACH(int type, m_registered) diff --git a/plasmoid/declarativeplugin/responsewaiter.h b/plasmoid/declarativeplugin/responsewaiter.h index de7a6346d..3d2a63dd2 100644 --- a/plasmoid/declarativeplugin/responsewaiter.h +++ b/plasmoid/declarativeplugin/responsewaiter.h @@ -4,7 +4,7 @@ #include #include -#include +#include #include @@ -38,7 +38,7 @@ class DBusAsyncResponse : public QObject Q_PROPERTY(bool autoDelete READ autodelete WRITE setAutodelete) public: - DBusAsyncResponse(QObject* parent = 0) : QObject(parent), m_autodelete(false) {} + DBusAsyncResponse(QObject* parent = 0); virtual ~DBusAsyncResponse() {}; Q_INVOKABLE void setPendingCall(QVariant e); @@ -52,8 +52,10 @@ Q_SIGNALS: private Q_SLOTS: void onCallFinished(QDBusPendingCallWatcher* watcher); + void onTimeout(); -private: +private: + QTimer m_timeout; bool m_autodelete; }; diff --git a/plasmoid/package/contents/ui/Sftp.qml b/plasmoid/package/contents/ui/Sftp.qml index 6df71403b..19578ba57 100644 --- a/plasmoid/package/contents/ui/Sftp.qml +++ b/plasmoid/package/contents/ui/Sftp.qml @@ -52,7 +52,7 @@ QtObject { } function browse() { - sftp.startBrowsing() + startupCheck.setPendingCall(sftp.startBrowsing()) } function unmount() {