some fixes
This commit is contained in:
parent
5e0ddd2d8f
commit
fb8fa53f8d
3 changed files with 26 additions and 6 deletions
|
@ -56,20 +56,33 @@ QVariant DBusResponseWaiter::waitForReply(QVariant variant) const
|
||||||
return QVariant();
|
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)
|
void DBusAsyncResponse::setPendingCall(QVariant variant)
|
||||||
{
|
{
|
||||||
if (QDBusPendingCall* call = const_cast<QDBusPendingCall*>(DBusResponseWaiter::instance()->extractPendingCall(variant)))
|
if (QDBusPendingCall* call = const_cast<QDBusPendingCall*>(DBusResponseWaiter::instance()->extractPendingCall(variant)))
|
||||||
{
|
{
|
||||||
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(*call);
|
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*)), this, SLOT(onCallFinished(QDBusPendingCallWatcher*)));
|
||||||
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), watcher, SLOT(deleteLater()));
|
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), watcher, SLOT(deleteLater()));
|
||||||
|
connect(&m_timeout, SIGNAL(timeout()), watcher, SLOT(deleteLater()));
|
||||||
|
m_timeout.start();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBusAsyncResponse::onCallFinished(QDBusPendingCallWatcher* watcher)
|
void DBusAsyncResponse::onCallFinished(QDBusPendingCallWatcher* watcher)
|
||||||
{
|
{
|
||||||
QVariant variant = watcher->property("pengingCall");
|
m_timeout.stop();
|
||||||
|
QVariant variant = watcher->property("pengingCallVariant");
|
||||||
|
|
||||||
if (QDBusPendingCall* call = const_cast<QDBusPendingCall*>(DBusResponseWaiter::instance()->extractPendingCall(variant)))
|
if (QDBusPendingCall* call = const_cast<QDBusPendingCall*>(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
|
const QDBusPendingCall* DBusResponseWaiter::extractPendingCall(QVariant& variant) const
|
||||||
{
|
{
|
||||||
Q_FOREACH(int type, m_registered)
|
Q_FOREACH(int type, m_registered)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QDebug>
|
#include <QTimer>
|
||||||
|
|
||||||
#include <QDeclarativeEngine>
|
#include <QDeclarativeEngine>
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class DBusAsyncResponse : public QObject
|
||||||
Q_PROPERTY(bool autoDelete READ autodelete WRITE setAutodelete)
|
Q_PROPERTY(bool autoDelete READ autodelete WRITE setAutodelete)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DBusAsyncResponse(QObject* parent = 0) : QObject(parent), m_autodelete(false) {}
|
DBusAsyncResponse(QObject* parent = 0);
|
||||||
virtual ~DBusAsyncResponse() {};
|
virtual ~DBusAsyncResponse() {};
|
||||||
|
|
||||||
Q_INVOKABLE void setPendingCall(QVariant e);
|
Q_INVOKABLE void setPendingCall(QVariant e);
|
||||||
|
@ -52,8 +52,10 @@ Q_SIGNALS:
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onCallFinished(QDBusPendingCallWatcher* watcher);
|
void onCallFinished(QDBusPendingCallWatcher* watcher);
|
||||||
|
void onTimeout();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QTimer m_timeout;
|
||||||
bool m_autodelete;
|
bool m_autodelete;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ QtObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
function browse() {
|
function browse() {
|
||||||
sftp.startBrowsing()
|
startupCheck.setPendingCall(sftp.startBrowsing())
|
||||||
}
|
}
|
||||||
|
|
||||||
function unmount() {
|
function unmount() {
|
||||||
|
|
Loading…
Reference in a new issue