diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-04-29 11:14:09 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-04-29 11:19:16 (GMT) |
commit | ce3d9fb3b3ec1f23d76b04a8593680d7eeee689d (patch) | |
tree | febf82fb0fbb7178c8598304c8a83abc1724a9a6 /tests | |
parent | 78e8af4fea3cc527b0dc5ace5a4c4445f044c2cd (diff) | |
download | Qt-ce3d9fb3b3ec1f23d76b04a8593680d7eeee689d.zip Qt-ce3d9fb3b3ec1f23d76b04a8593680d7eeee689d.tar.gz Qt-ce3d9fb3b3ec1f23d76b04a8593680d7eeee689d.tar.bz2 |
Fix crash in QDBusInterface when invoking a method in a derived class.
If metaObject is 0 and the signal or slot is in a class deriving from
QDBusInterface, this would lead to a crash.
Deriving from QDBusInterface is very unusual and usually indicates
misunderstanding of QtDBus, but the fix is correct.
Task-number: https://projects.maemo.org/bugzilla/show_bug.cgi?id=165175
Patch-By: Maemo developer
Reviewed-by: Thiago Macieira <thiago.macieira@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qdbusinterface/tst_qdbusinterface.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp index 826bd70..d8ff2d3 100644 --- a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp @@ -157,6 +157,18 @@ public slots: } }; +class DerivedFromQDBusInterface: public QDBusInterface +{ + Q_OBJECT +public: + DerivedFromQDBusInterface() + : QDBusInterface("com.example.Test", "/") + {} + +public slots: + void method() {} +}; + // helper function void emitSignal(const QString &interface, const QString &name, const QString &arg) { @@ -183,6 +195,7 @@ private slots: void notConnected(); void notValid(); + void notValidDerived(); void invalidAfterServiceOwnerChanged(); void introspect(); void callMethod(); @@ -219,6 +232,7 @@ void tst_QDBusInterface::notConnected() connection); QVERIFY(!interface.isValid()); + QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection)); } void tst_QDBusInterface::notValid() @@ -230,6 +244,14 @@ void tst_QDBusInterface::notValid() connection); QVERIFY(!interface.isValid()); + QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection)); +} + +void tst_QDBusInterface::notValidDerived() +{ + DerivedFromQDBusInterface c; + QVERIFY(!c.isValid()); + QMetaObject::invokeMethod(&c, "method", Qt::DirectConnection); } void tst_QDBusInterface::invalidAfterServiceOwnerChanged() |