From 87a065002f9bc78b58c6f699ef52dda08045ad7c Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 9 Oct 2009 14:38:59 +0200 Subject: Carbon: QApplication auto test shows bug in event dispatcher The reason for the bug is that we call _quit_ on the eventloop just _after_ posting the deffered delete event (from inside deleteLater function, ref the test where it fails, tst_qapplication.cpp:1242). And the point is, even if the loop level tells us that we _can_ delete the object in this case, the 'quit' tells us that we should not process _any_ events (until we get a call to processEvents again). So this patch makes sure that we don't call sendPostedEvents from the eventDispatcher if it is interruped. Rev-By: brad --- src/gui/kernel/qeventdispatcher_mac.mm | 2 +- tests/auto/qapplication/tst_qapplication.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm index 7152705..49c851b 100644 --- a/src/gui/kernel/qeventdispatcher_mac.mm +++ b/src/gui/kernel/qeventdispatcher_mac.mm @@ -942,7 +942,7 @@ Boolean QEventDispatcherMacPrivate::postedEventSourceEqualCallback(const void *i inline static void processPostedEvents(QEventDispatcherMacPrivate *const d, const bool blockSendPostedEvents) { - if (blockSendPostedEvents) { + if (blockSendPostedEvents || d->interrupt) { CFRunLoopSourceSignal(d->postedEventsSource); } else { if (!d->threadData->canWait || (d->serialNumber != d->lastSerial)) { diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp index abcacef..97aa092 100644 --- a/tests/auto/qapplication/tst_qapplication.cpp +++ b/tests/auto/qapplication/tst_qapplication.cpp @@ -1242,6 +1242,10 @@ public slots: } void deleteLaterAndExitLoop() { + // Check that 'p' is not deleted before exec returns, since the call + // to QEventLoop::quit() should stop 'eventLoop' from processing + // any more events (that is, delete later) until we return to the + // _current_ event loop: QEventLoop eventLoop; QPointer p(this); QMetaObject::invokeMethod(this, "deleteLater", Qt::QueuedConnection); -- cgit v0.12