Stabilize tst_qclipboard.

If the process terminates while QApplication::processEvents()
runs, the subsequent waitForFinished() returns false and the test
fails.

Task-number: QTBUG-29951
Change-Id: I41f461358920ad430951613dd919885f68ae212c
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
This commit is contained in:
Friedemann Kleint 2013-03-06 12:34:44 +01:00 committed by The Qt Project
parent 2041f4eae8
commit 583349de03

View File

@ -208,11 +208,12 @@ static bool runHelper(const QString &program, const QStringList &arguments, QByt
// Windows: Due to implementation changes, the event loop needs
// to be spun since we ourselves also need to answer the
// WM_DRAWCLIPBOARD message as we are in the chain of clipboard
// viewers.
// viewers. Check for running before waitForFinished() in case
// the process terminated while processEvents() was executed.
bool running = true;
for (int i = 0; i < 60 && running; ++i) {
QGuiApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
if (process.waitForFinished(500))
if (process.state() != QProcess::Running || process.waitForFinished(500))
running = false;
}
if (running) {