Remove QEventLoop::DeferredDeletion
authorBradley T. Hughes <bradley.hughes@nokia.com>
Thu, 19 Jan 2012 10:53:09 +0000 (11:53 +0100)
committerQt by Nokia <qt-info@nokia.com>
Mon, 23 Jan 2012 13:47:10 +0000 (14:47 +0100)
This flag has been deprecated since Qt 4.4, so remove it.
tst_QApplication had 2 nearly identical tests, one for testing the
QEventLoop::DeferredDeletion flag, and one to test sendPostedEvents()
with QEvent::DeferredDelete. The latter is the preferred way, so keep
that test, but remove the test for the obsoleted flag.

Change-Id: Icdb7483c32b3c920bda31d2bbb4f7414ece6d826
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
src/corelib/kernel/qcoreapplication.cpp
src/corelib/kernel/qeventloop.cpp
src/corelib/kernel/qeventloop.h
tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp

index 2e56aca..79a724c 100644 (file)
@@ -952,8 +952,6 @@ void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags)
     QThreadData *data = QThreadData::current();
     if (!data->eventDispatcher)
         return;
-    if (flags & QEventLoop::DeferredDeletion)
-        QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
     data->eventDispatcher->processEvents(flags);
 }
 
@@ -980,13 +978,9 @@ void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags, int m
         return;
     QElapsedTimer start;
     start.start();
-    if (flags & QEventLoop::DeferredDeletion)
-        QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
     while (data->eventDispatcher->processEvents(flags & ~QEventLoop::WaitForMoreEvents)) {
         if (start.elapsed() > maxtime)
             break;
-        if (flags & QEventLoop::DeferredDeletion)
-            QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
     }
 }
 
index d0d1953..0d4a4b4 100644 (file)
@@ -96,11 +96,8 @@ public:
     available.
 
     \omitvalue X11ExcludeTimers
-    \omitvalue ExcludeUserInput
-    \omitvalue WaitForMore
     \omitvalue EventLoopExec
     \omitvalue DialogExec
-    \value DeferredDeletion deprecated - do not use.
 
     \sa processEvents()
 */
@@ -144,8 +141,6 @@ bool QEventLoop::processEvents(ProcessEventsFlags flags)
     Q_D(QEventLoop);
     if (!d->threadData->eventDispatcher)
         return false;
-    if (flags & DeferredDeletion)
-        QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
     return d->threadData->eventDispatcher->processEvents(flags);
 }
 
@@ -252,13 +247,9 @@ void QEventLoop::processEvents(ProcessEventsFlags flags, int maxTime)
 
     QElapsedTimer start;
     start.start();
-    if (flags & DeferredDeletion)
-        QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
     while (processEvents(flags & ~WaitForMoreEvents)) {
         if (start.elapsed() > maxTime)
             break;
-        if (flags & DeferredDeletion)
-            QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
     }
 }
 
index 506a0bc..b501db5 100644 (file)
@@ -66,12 +66,9 @@ public:
         ExcludeUserInputEvents = 0x01,
         ExcludeSocketNotifiers = 0x02,
         WaitForMoreEvents = 0x04,
-       X11ExcludeTimers = 0x08
-#ifdef QT_DEPRECATED
-       , DeferredDeletion = 0x10
-#endif
-        , EventLoopExec = 0x20
-        , DialogExec = 0x40
+        X11ExcludeTimers = 0x08,
+        EventLoopExec = 0x20,
+        DialogExec = 0x40
     };
     Q_DECLARE_FLAGS(ProcessEventsFlags, ProcessEventsFlag)
 
index 821952c..5f0ed80 100644 (file)
@@ -1258,51 +1258,12 @@ public slots:
     {
         QApplication::processEvents();
     }
-    void processEventsWithDeferredDeletion()
-    {
-        QApplication::processEvents(QEventLoop::DeferredDeletion);
-    }
     void sendPostedEventsWithDeferredDelete()
     {
         QApplication::sendPostedEvents(0, QEvent::DeferredDelete);
     }
-    void deleteLaterAndProcessEvents1()
-    {
-        QEventLoop eventLoop;
-
-        QPointer<QObject> p = this;
-        deleteLater();
-
-        // trying to delete this object in a deeper eventloop just won't work
-        QMetaObject::invokeMethod(this,
-                                  "processEventsOnly",
-                                  Qt::QueuedConnection);
-        QMetaObject::invokeMethod(&eventLoop, "quit", Qt::QueuedConnection);
-        eventLoop.exec();
-        QVERIFY(p);
-        QMetaObject::invokeMethod(this,
-                                  "processEventsWithDeferredDeletion",
-                                  Qt::QueuedConnection);
-        QMetaObject::invokeMethod(&eventLoop, "quit", Qt::QueuedConnection);
-        eventLoop.exec();
-        QVERIFY(p);
-        QMetaObject::invokeMethod(this,
-                                  "sendPostedEventsWithDeferredDelete",
-                                  Qt::QueuedConnection);
-        QMetaObject::invokeMethod(&eventLoop, "quit", Qt::QueuedConnection);
-        eventLoop.exec();
-        QVERIFY(p);
-
-        // trying to delete it from this eventloop still doesn't work
-        QApplication::processEvents();
-        QVERIFY(p);
-
-        // however, it *will* work with this magic incantation
-        QApplication::processEvents(QEventLoop::DeferredDeletion);
-        QVERIFY(!p);
-    }
 
-    void deleteLaterAndProcessEvents2()
+    void deleteLaterAndProcessEvents()
     {
         QEventLoop eventLoop;
 
@@ -1317,12 +1278,6 @@ public slots:
         eventLoop.exec();
         QVERIFY(p);
         QMetaObject::invokeMethod(this,
-                                  "processEventsWithDeferredDeletion",
-                                  Qt::QueuedConnection);
-        QMetaObject::invokeMethod(&eventLoop, "quit", Qt::QueuedConnection);
-        eventLoop.exec();
-        QVERIFY(p);
-        QMetaObject::invokeMethod(this,
                                   "sendPostedEventsWithDeferredDelete",
                                   Qt::QueuedConnection);
         QMetaObject::invokeMethod(&eventLoop, "quit", Qt::QueuedConnection);
@@ -1355,16 +1310,7 @@ void tst_QApplication::testDeleteLaterProcessEvents()
         QApplication app(argc, 0, QApplication::GuiServer);
         // If you call processEvents() with an event dispatcher present, but
         // outside any event loops, deferred deletes are not processed unless
-        // QEventLoop::DeferredDeletion is passed.
-        object = new QObject;
-        p = object;
-        object->deleteLater();
-        app.processEvents();
-        QVERIFY(p);
-        app.processEvents(QEventLoop::ProcessEventsFlag(0x10)); // 0x10 == QEventLoop::DeferredDeletion
-        QVERIFY(!p);
-
-        // sendPostedEvents(0, DeferredDelete); also works
+        // sendPostedEvents(0, DeferredDelete) is called.
         object = new QObject;
         p = object;
         object->deleteLater();
@@ -1423,22 +1369,7 @@ void tst_QApplication::testDeleteLaterProcessEvents()
         EventLoopNester *nester = new EventLoopNester();
         p = nester;
         QTimer::singleShot(3000, &loop, SLOT(quit()));
-        QTimer::singleShot(0, nester, SLOT(deleteLaterAndProcessEvents1()));
-
-        loop.exec();
-        QVERIFY(!p);
-    }
-
-    {
-        // when the event loop that calls deleteLater() also calls
-        // processEvents() immediately afterwards, the object should
-        // not die until the parent loop continues
-        QApplication app(argc, 0, QApplication::GuiServer);
-        QEventLoop loop;
-        EventLoopNester *nester = new EventLoopNester();
-        p = nester;
-        QTimer::singleShot(3000, &loop, SLOT(quit()));
-        QTimer::singleShot(0, nester, SLOT(deleteLaterAndProcessEvents2()));
+        QTimer::singleShot(0, nester, SLOT(deleteLaterAndProcessEvents()));
 
         loop.exec();
         QVERIFY(!p);