summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/dbus/qdbusinterface.cpp2
-rw-r--r--tests/auto/qdbusinterface/tst_qdbusinterface.cpp22
2 files changed, 23 insertions, 1 deletions
diff --git a/src/dbus/qdbusinterface.cpp b/src/dbus/qdbusinterface.cpp
index 300f425..56d5231 100644
--- a/src/dbus/qdbusinterface.cpp
+++ b/src/dbus/qdbusinterface.cpp
@@ -258,7 +258,7 @@ void *QDBusInterface::qt_metacast(const char *_clname)
int QDBusInterface::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QDBusAbstractInterface::qt_metacall(_c, _id, _a);
- if (_id < 0 || !d_func()->isValid)
+ if (_id < 0 || !d_func()->isValid || !d_func()->metaObject)
return _id;
return d_func()->metacall(_c, _id, _a);
}
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()