diff options
Diffstat (limited to 'tests/auto')
4 files changed, 34 insertions, 2 deletions
diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index edba67bf46..73fe06a83f 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -9,6 +9,7 @@ #include <private/qabstracteventdispatcher_p.h> // for qGlobalPostedEventsCount() #include <private/qcoreapplication_p.h> +#include <private/qcoreevent_p.h> #include <private/qeventloop_p.h> #include <private/qthread_p.h> @@ -24,9 +25,12 @@ class EventSpy : public QObject public: QList<int> recordedEvents; - bool eventFilter(QObject *, QEvent *event) override + std::function<void(QObject *, QEvent *)> eventCallback; + bool eventFilter(QObject *target, QEvent *event) override { recordedEvents.append(event->type()); + if (eventCallback) + eventCallback(target, event); return false; } }; @@ -1081,6 +1085,29 @@ static void createQObjectOnDestruction() } Q_DESTRUCTOR_FUNCTION(createQObjectOnDestruction) +void tst_QCoreApplication::testDeleteLaterFromBeforeOutermostEventLoop() +{ + int argc = 0; + QCoreApplication app(argc, nullptr); + + EventSpy *spy = new EventSpy(); + QPointer<QObject> spyPointer = spy; + + app.installEventFilter(spy); + spy->eventCallback = [spy](QObject *, QEvent *event) { + if (event->type() == QEvent::User + 1) + spy->deleteLater(); + }; + + QCoreApplication::postEvent(&app, new QEvent(QEvent::Type(QEvent::User + 1))); + QCoreApplication::processEvents(); + + QEventLoop loop; + QTimer::singleShot(0, &loop, &QEventLoop::quit); + loop.exec(); + QVERIFY(!spyPointer); +} + #ifndef QT_QGUIAPPLICATIONTEST QTEST_APPLESS_MAIN(tst_QCoreApplication) #endif diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h index 91d9324db4..8271c0cbb2 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h @@ -45,6 +45,7 @@ private slots: void addRemoveLibPaths(); #endif void theMainThread(); + void testDeleteLaterFromBeforeOutermostEventLoop(); }; #endif // TST_QCOREAPPLICATION_H diff --git a/tests/auto/gui/kernel/qevent/tst_qevent.cpp b/tests/auto/gui/kernel/qevent/tst_qevent.cpp index f1ffb8c35e..56d483107b 100644 --- a/tests/auto/gui/kernel/qevent/tst_qevent.cpp +++ b/tests/auto/gui/kernel/qevent/tst_qevent.cpp @@ -14,7 +14,6 @@ X(QTimerEvent, (42)) \ X(QChildEvent, (QEvent::ChildAdded, nullptr)) \ X(QDynamicPropertyChangeEvent, ("size")) \ - X(QDeferredDeleteEvent, ()) \ /* qfutureinterface_p.h */ \ X(QFutureCallOutEvent, ()) \ /* end */ diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 3ed9743838..fe98b4a9c1 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -19,6 +19,7 @@ #if QT_CONFIG(process) # include <QtCore/QProcess> #endif +#include <QtCore/private/qcoreevent_p.h> #include <QtCore/private/qeventloop_p.h> #include <QtGui/QFontDatabase> @@ -94,7 +95,9 @@ private slots: void libraryPaths_qt_plugin_path_2(); #endif +#ifdef QT_BUILD_INTERNAL void sendPostedEvents(); +#endif // ifdef QT_BUILD_INTERNAL void thread(); void desktopSettingsAware(); @@ -1126,6 +1129,7 @@ void tst_QApplication::libraryPaths_qt_plugin_path_2() } #endif +#ifdef QT_BUILD_INTERNAL class SendPostedEventsTester : public QObject { Q_OBJECT @@ -1171,6 +1175,7 @@ void tst_QApplication::sendPostedEvents() (void) QCoreApplication::exec(); QVERIFY(p.isNull()); } +#endif void tst_QApplication::thread() { |