Remove QEventLoop::DeferredDeletion
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>
This commit is contained in:
parent
75583bd605
commit
1831abb5bb
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -1258,15 +1258,12 @@ public slots:
|
||||
{
|
||||
QApplication::processEvents();
|
||||
}
|
||||
void processEventsWithDeferredDeletion()
|
||||
{
|
||||
QApplication::processEvents(QEventLoop::DeferredDeletion);
|
||||
}
|
||||
void sendPostedEventsWithDeferredDelete()
|
||||
{
|
||||
QApplication::sendPostedEvents(0, QEvent::DeferredDelete);
|
||||
}
|
||||
void deleteLaterAndProcessEvents1()
|
||||
|
||||
void deleteLaterAndProcessEvents()
|
||||
{
|
||||
QEventLoop eventLoop;
|
||||
|
||||
@ -1280,48 +1277,6 @@ public slots:
|
||||
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()
|
||||
{
|
||||
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);
|
||||
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user