diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-12-08 19:28:45 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-12-09 09:15:29 (GMT) |
commit | 970f19bdb55cd559e9ef97228d30fd52b20e39cb (patch) | |
tree | 1a807904533630fede6cdc423a85a686af89f5a1 /tests | |
parent | 0b78ccc201f58b53c90e6327b051bfdb8c08ee14 (diff) | |
download | Qt-970f19bdb55cd559e9ef97228d30fd52b20e39cb.zip Qt-970f19bdb55cd559e9ef97228d30fd52b20e39cb.tar.gz Qt-970f19bdb55cd559e9ef97228d30fd52b20e39cb.tar.bz2 |
Fix crash in QDBusPendingReply/QDBusReply in case of unconnected calls.
If we made calls on a QDBusConnection that isn't connected, the d
pointer is 0. Ensure we don't crash.
Task-number: QTBUG-6571
Reviewed-by: Bradley T. Hughes
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qdbuspendingreply/tst_qdbuspendingreply.cpp | 25 | ||||
-rw-r--r-- | tests/auto/qdbusreply/tst_qdbusreply.cpp | 16 |
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qdbuspendingreply/tst_qdbuspendingreply.cpp b/tests/auto/qdbuspendingreply/tst_qdbuspendingreply.cpp index 6398d9c..82e6389 100644 --- a/tests/auto/qdbuspendingreply/tst_qdbuspendingreply.cpp +++ b/tests/auto/qdbuspendingreply/tst_qdbuspendingreply.cpp @@ -93,6 +93,7 @@ private slots: } void init(); + void unconnected(); void simpleTypes(); void complexTypes(); void wrongTypes(); @@ -252,6 +253,30 @@ void tst_QDBusPendingReply::init() QVERIFY(iface->isValid()); } +void tst_QDBusPendingReply::unconnected() +{ + QDBusConnection con("invalid stored connection"); + QVERIFY(!con.isConnected()); + QDBusInterface iface("doesnt.matter", "/", "doesnt.matter", con); + QVERIFY(!iface.isValid()); + + QDBusPendingReply<> rvoid = iface.asyncCall("ReloadConfig"); + QVERIFY(rvoid.isFinished()); + QVERIFY(!rvoid.isValid()); + QVERIFY(rvoid.isError()); + rvoid.waitForFinished(); + QVERIFY(!rvoid.isValid()); + QVERIFY(rvoid.isError()); + + QDBusPendingReply<QString> rstring = iface.asyncCall("GetId"); + QVERIFY(rstring.isFinished()); + QVERIFY(!rstring.isValid()); + QVERIFY(rstring.isError()); + rstring.waitForFinished(); + QVERIFY(!rstring.isValid()); + QVERIFY(rstring.isError()); +} + void tst_QDBusPendingReply::simpleTypes() { QDBusPendingReply<> rvoid = iface->asyncCall("retrieveVoid"); diff --git a/tests/auto/qdbusreply/tst_qdbusreply.cpp b/tests/auto/qdbusreply/tst_qdbusreply.cpp index 9866302..e36d288 100644 --- a/tests/auto/qdbusreply/tst_qdbusreply.cpp +++ b/tests/auto/qdbusreply/tst_qdbusreply.cpp @@ -93,6 +93,7 @@ private slots: } void init(); + void unconnected(); void simpleTypes(); void complexTypes(); void wrongTypes(); @@ -236,6 +237,21 @@ void tst_QDBusReply::init() QVERIFY(iface->isValid()); } +void tst_QDBusReply::unconnected() +{ + QDBusConnection con("invalid stored connection"); + QVERIFY(!con.isConnected()); + QDBusInterface iface("doesnt.matter", "/", "doesnt.matter", con); + QVERIFY(!iface.isValid()); + + QDBusReply<void> rvoid = iface.asyncCall("ReloadConfig"); + QVERIFY(!rvoid.isValid()); + + QDBusReply<QString> rstring = iface.asyncCall("GetId"); + QVERIFY(!rstring.isValid()); + QVERIFY(rstring.value().isEmpty()); +} + void tst_QDBusReply::simpleTypes() { QDBusReply<bool> rbool = iface->call(QDBus::BlockWithGui, "retrieveBool"); |