From 152e4ee249915b15241c5f37830f37bb569151b6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 12 Jan 2010 16:14:07 +0100 Subject: Fix D-Bus calls with QDBus::BlockWithGui. We must wait for a reply in case the reply hasn't been received yet, not if it has already been received. Simple typo. Task-number: QT-2307 Reviewed-by: Trust Me --- src/dbus/qdbusintegrator.cpp | 2 +- tests/auto/qdbusconnection/tst_qdbusconnection.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 572c050..30fa0b6 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1826,7 +1826,7 @@ QDBusMessage QDBusConnectionPrivate::sendWithReply(const QDBusMessage &message, QDBusPendingCallPrivate *pcall = sendWithReplyAsync(message, timeout); Q_ASSERT(pcall); - if (pcall->replyMessage.type() != QDBusMessage::InvalidMessage) { + if (pcall->replyMessage.type() == QDBusMessage::InvalidMessage) { pcall->watcherHelper = new QDBusPendingCallWatcherHelper; QEventLoop loop; loop.connect(pcall->watcherHelper, SIGNAL(reply(QDBusMessage)), SLOT(quit())); diff --git a/tests/auto/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/qdbusconnection/tst_qdbusconnection.cpp index 606659f..5e2f3a9 100644 --- a/tests/auto/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/qdbusconnection/tst_qdbusconnection.cpp @@ -86,6 +86,7 @@ private slots: void connectToBus(); void connect(); void send(); + void sendWithGui(); void sendAsync(); void sendSignal(); @@ -173,6 +174,22 @@ void tst_QDBusConnection::send() QVERIFY(reply.arguments().at(0).toStringList().contains(con.baseService())); } +void tst_QDBusConnection::sendWithGui() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + + QVERIFY(con.isConnected()); + + QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.DBus", + "/org/freedesktop/DBus", "org.freedesktop.DBus", "ListNames"); + + QDBusMessage reply = con.call(msg, QDBus::BlockWithGui); + + QCOMPARE(reply.arguments().count(), 1); + QCOMPARE(reply.arguments().at(0).typeName(), "QStringList"); + QVERIFY(reply.arguments().at(0).toStringList().contains(con.baseService())); +} + void tst_QDBusConnection::sendAsync() { QDBusConnection con = QDBusConnection::sessionBus(); -- cgit v0.12