LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File 0001-Don-t-crash-if-the-relayed-signal-was-emitted-from-t.patch of Package libqt4 (Project KDE:Qt)

From c776e155a904527a36a1ba9c788c344ca171780c Mon Sep 17 00:00:00 2001
From: Thiago Macieira <thiago.macieira@intel.com>
Date: Sun, 23 Jun 2013 16:39:56 -0700
Subject: [PATCH 1/6] 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
(cherry-picked from qtbase commit d94961d08f91696824d9035f666af5fe28d59ef6)
Reviewed-by: Peter Seiderer <ps.report@gmx.net>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
---
 src/dbus/qdbusabstractadaptor.cpp | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/dbus/qdbusabstractadaptor.cpp b/src/dbus/qdbusabstractadaptor.cpp
index 84c30cd..9ce843e 100644
--- a/src/dbus/qdbusabstractadaptor.cpp
+++ b/src/dbus/qdbusabstractadaptor.cpp
@@ -267,7 +267,15 @@ void QDBusAdaptorConnector::polish()
 void QDBusAdaptorConnector::relaySlot(void **argv)
 {
     QObjectPrivate *d = static_cast<QObjectPrivate *>(d_ptr.data());
-    relay(d->currentSender->sender, d->currentSender->signal, argv);
+    if (Q_LIKELY(d->currentSender)) {
+        relay(d->currentSender->sender, d->currentSender->signal, 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)
-- 
1.8.3.1