diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2013-07-09 15:31:26 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-07-10 17:57:10 +0200 |
commit | d6d9edd7c47b183edc1acc631602ea4f4a885d84 (patch) | |
tree | d9e58995cb2c59810a9a51c2298c36ee0a742203 /src/corelib/kernel/qcoreapplication.cpp | |
parent | e07bdb8f7401f207a1637d2c2efd299db31756ed (diff) |
Fix dead lock in the Qt event handling
The deadlock is caused because the QEvent is destroyed while holding the
event list mutex. And the QEvent may have a custom destructor that will
re-enter the event handlng code.
The QScopedPointer that should destroy the event must be created after
the MutexUnlocker.
Regression introduced by commit f9035587b98ac5dc9491e642b8ec84470ec03f0e
Task-number: QTBUG-31606
Change-Id: I6b2cbc2656eacdec61b641886953f00bf5b3ff36
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qcoreapplication.cpp')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 0301a40876..c3a05551b8 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1451,7 +1451,7 @@ void QCoreApplicationPrivate::sendPostedEvents(QObject *receiver, int event_type // first, we diddle the event so that we can deliver // it, and that no one will try to touch it later. pe.event->posted = false; - QScopedPointer<QEvent> e(pe.event); + QEvent *e = pe.event; QObject * r = pe.receiver; --r->d_func()->postedEvents; @@ -1469,8 +1469,10 @@ void QCoreApplicationPrivate::sendPostedEvents(QObject *receiver, int event_type }; MutexUnlocker unlocker(locker); + QScopedPointer<QEvent> event_deleter(e); // will delete the event (with the mutex unlocked) + // after all that work, it's time to deliver the event. - QCoreApplication::sendEvent(r, e.data()); + QCoreApplication::sendEvent(r, e); // careful when adding anything below this point - the // sendEvent() call might invalidate any invariants this |