From e48c0a6e7c081a4209cdcae07c1b577f55bcc515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 14 Oct 2022 12:54:13 +0000 Subject: Revert "QObject: attempt to fix a deadlock introduced by an earlier fix" This reverts commit 22d4c67234fd152296c3ec98fc57526356a9f62b. Reason for revert: The fix causes crashes tst_QObjectRace::disconnectRace2 and we don't currently have a clear resolution on further fixes. Task-number: QTBUG-107034 Change-Id: I310c27654f125cdb2939940d432724e73c89f485 Reviewed-by: Fabian Kosmale --- src/corelib/kernel/qobject.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'src/corelib/kernel/qobject.cpp') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 6bfa7619db1..6d7079e47f5 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -5311,20 +5311,11 @@ bool QObjectPrivate::disconnect(const QObject *sender, int signal_index, const Q /*! \internal \threadsafe - - Thread-safety warning: this function may be called from any thread and is - thread-safe, \b{so long as the sender is not being deleted}. At the time of - this writing, this function is called from QObject::disconnect() and from - the multiple places where a single-shot connection is activated; in both - cases, the construction of the user code is already such that the sender - object cannot be undergoing deletion in another thread. */ inline bool QObjectPrivate::removeConnection(QObjectPrivate::Connection *c) { if (!c) return false; - - // double-checked locking on this pointer QObject *receiver = c->receiver.loadRelaxed(); if (!receiver) return false; @@ -5345,6 +5336,7 @@ inline bool QObjectPrivate::removeConnection(QObjectPrivate::Connection *c) Q_ASSERT(connections); connections->removeConnection(c); + c->sender->disconnectNotify(QMetaObjectPrivate::signal(c->sender->metaObject(), c->signal_index)); // We must not hold the receiver mutex, else we risk dead-locking; we also only need the sender mutex // It is however vital to hold the senderMutex before calling cleanOrphanedConnections, as otherwise // another thread might modify/delete the connection @@ -5356,8 +5348,6 @@ inline bool QObjectPrivate::removeConnection(QObjectPrivate::Connection *c) locker.dismiss(); // so we dismiss the QOrderedMutexLocker } - // this is safe if the condition in the documentation is correct - c->sender->disconnectNotify(QMetaObjectPrivate::signal(c->sender->metaObject(), c->signal_index)); return true; } -- cgit v1.2.3