From 8562b5628efa856901a9b4dd3d98cb82838da644 Mon Sep 17 00:00:00 2001 From: Oliver Wolff <oliver.wolff@qt.io> Date: Wed, 17 Jun 2020 08:17:34 +0200 Subject: [PATCH] Replace BaselineProtocol::sysSleep with QThread::msleep Just waiting can be done by QThread::msleep and we can get rid of ifdefery. As an additional bonus the change removes the one single occurrence of winrt code. Task-number: QTBUG-84434 Pick-to: 5.15 Change-Id: I2b75e20cec16abbd93064722943f8977c0267bee Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- .../shared/baselineprotocol.cpp | 23 ++----------------- .../shared/baselineprotocol.h | 1 - 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/tests/auto/quick3d_lancelot/shared/baselineprotocol.cpp b/tests/auto/quick3d_lancelot/shared/baselineprotocol.cpp index 727573690..2045187be 100644 --- a/tests/auto/quick3d_lancelot/shared/baselineprotocol.cpp +++ b/tests/auto/quick3d_lancelot/shared/baselineprotocol.cpp @@ -36,6 +36,7 @@ #endif #include <QFileInfo> #include <QDir> +#include <QThread> #include <QTime> #include <QPointer> #include <QRegularExpression> @@ -57,26 +58,6 @@ const QString PI_PulseTestrBranch(QLS("PulseTestrBranch")); #define QMAKESPEC "Unknown" #endif -#if defined(Q_OS_WIN) -#include <QtCore/qt_windows.h> -#endif -#if defined(Q_OS_UNIX) -#include <time.h> -#endif -void BaselineProtocol::sysSleep(int ms) -{ -#if defined(Q_OS_WIN) -# ifndef Q_OS_WINRT - Sleep(DWORD(ms)); -# else - WaitForSingleObjectEx(GetCurrentThread(), ms, false); -# endif -#else - struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 }; - nanosleep(&ts, NULL); -#endif -} - PlatformInfo::PlatformInfo() : QMap<QString, QString>(), adHoc(true) { @@ -365,7 +346,7 @@ bool BaselineProtocol::connect(const QString &testCase, bool *dryrun, const Plat socket.connectToHost(serverName, ServerPort); if (!socket.waitForConnected(Timeout)) { - sysSleep(3000); // Wait a bit and try again, the server might just be restarting + QThread::msleep(3000); // Wait a bit and try again, the server might just be restarting if (!socket.waitForConnected(Timeout)) { errMsg += QLS("TCP connectToHost failed. Host:") + QLS(serverName) + QLS(" port:") + QString::number(ServerPort); return false; diff --git a/tests/auto/quick3d_lancelot/shared/baselineprotocol.h b/tests/auto/quick3d_lancelot/shared/baselineprotocol.h index dde789d8e..2be91308e 100644 --- a/tests/auto/quick3d_lancelot/shared/baselineprotocol.h +++ b/tests/auto/quick3d_lancelot/shared/baselineprotocol.h @@ -175,7 +175,6 @@ private: bool sendBlock(Command cmd, const QByteArray &block); bool receiveBlock(Command *cmd, QByteArray *block); - void sysSleep(int ms); QString errMsg; QTcpSocket socket; -- GitLab