diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2013-06-23 16:52:13 -0700 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-07-03 01:24:12 +0200 |
commit | d94961d08f91696824d9035f666af5fe28d59ef6 (patch) | |
tree | 058cb6afda4f655196dd143db38f7e85b1154c1f /src/dbus | |
parent | efb592503afb38073bb005850272af03c8500d3f (diff) |
Don't crash if the relayed signal was emitted from the wrong thread
Under normal circumstances, this should never happen. Signals exported
to D-Bus should only be emitted from the object's own thread. That's the
only way for the receiver (the QDBusAdaptorConnector object) to know
what the sender object and signal were. If they are emitted from another
thread, the sender will be null.
Task-number: QTBUG-31932
Change-Id: Ia5a45d648985e0645bffd4abc0881fca9da64f79
Reviewed-by: Lorn Potter <lorn.potter@jollamobile.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
Diffstat (limited to 'src/dbus')
-rw-r--r-- | src/dbus/qdbusabstractadaptor.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/dbus/qdbusabstractadaptor.cpp b/src/dbus/qdbusabstractadaptor.cpp index e08714f04d..02ff40068b 100644 --- a/src/dbus/qdbusabstractadaptor.cpp +++ b/src/dbus/qdbusabstractadaptor.cpp @@ -279,7 +279,16 @@ void QDBusAdaptorConnector::polish() void QDBusAdaptorConnector::relaySlot(void **argv) { - relay(sender(), senderSignalIndex(), argv); + QObject *sndr = sender(); + if (Q_LIKELY(sndr)) { + relay(sndr, senderSignalIndex(), argv); + } else { + qWarning("QtDBus: cannot relay signals from parent %s(%p \"%s\") unless they are emitted in the object's thread %s(%p \"%s\"). " + "Current thread is %s(%p \"%s\").", + parent()->metaObject()->className(), parent(), qPrintable(parent()->objectName()), + parent()->thread()->metaObject()->className(), parent()->thread(), qPrintable(parent()->thread()->objectName()), + QThread::currentThread()->metaObject()->className(), QThread::currentThread(), qPrintable(QThread::currentThread()->objectName())); + } } void QDBusAdaptorConnector::relay(QObject *senderObj, int lastSignalIdx, void **argv) |