Commit 499b8b00 authored by Samoilenko Yuri's avatar Samoilenko Yuri
Browse files

some fixes

parent 9b3382d2
......@@ -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
......
......@@ -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;
};
......
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