diff --git a/tests/auto/corelib/kernel/qcoreapplication/apphelper.cpp b/tests/auto/corelib/kernel/qcoreapplication/apphelper.cpp index 8bf44bd00d2..58e702a643d 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/apphelper.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/apphelper.cpp @@ -10,6 +10,12 @@ #include #include +#ifdef Q_OS_WIN +# include +#else +# include +# include +#endif #if defined(QT_WIDGETS_LIB) #include @@ -23,6 +29,10 @@ using TestApplication = QGuiApplication; using TestApplication = QCoreApplication; #endif +#ifndef STDIN_FILENO +# define STDIN_FILENO 0 +#endif + #include "maybeshow.h" static int exitFromEventLoop(int argc, char **argv) @@ -42,7 +52,15 @@ static int exitFromThread(int argc, char **argv) fprintf(stderr, "QThread::currentThread is null!\n"); ::exit(EXIT_SUCCESS); }); - QTimer::singleShot(200, thr, [&thr] { thr->start(); }); + QTimer::singleShot(200, thr, [&thr] { + thr->start(); + + // block the GUI forever, otherwise the unloading of the QPA plugins + // could cause a crash if something is running. + char c; + int r = read(STDIN_FILENO, &c, 1); + Q_UNUSED(r); + }); app.exec(); Q_UNREACHABLE_RETURN(EXIT_FAILURE); }