Commit fb8fa53f authored by Samoilenko Yuri's avatar Samoilenko Yuri
Browse files

some fixes

parent 5e0ddd2d
......@@ -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<QDBusPendingCall*>(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<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
{
Q_FOREACH(int type, m_registered)
......
......@@ -4,7 +4,7 @@
#include <QObject>
#include <QVariant>
#include <QDebug>
#include <QTimer>
#include <QDeclarativeEngine>
......@@ -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;
};
......
......@@ -52,7 +52,7 @@ QtObject {
}
function browse() {
sftp.startBrowsing()
startupCheck.setPendingCall(sftp.startBrowsing())
}
function unmount() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment