some fixes

This commit is contained in:
Samoilenko Yuri 2014-02-06 00:36:51 +04:00
parent 9b3382d2b8
commit 499b8b00b7
2 changed files with 17 additions and 7 deletions

View file

@ -3,9 +3,6 @@
#include <QDBusPendingReply>
#include <QDebug>
#include <QCoreApplication>
#include <qdeclarativeexpression.h>
#include <QDeclarativeEngine>
#include <QDeclarativeContext>
#include "responsewaiter.h"
@ -43,6 +40,12 @@ QVariant DBusResponseWaiter::waitForReply(QVariant variant) const
if (QDBusPendingCall* call = const_cast<QDBusPendingCall*>(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

View file

@ -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;
};