diff options
Diffstat (limited to 'src/libs/installer/utils.cpp')
-rw-r--r-- | src/libs/installer/utils.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/libs/installer/utils.cpp b/src/libs/installer/utils.cpp index 1112bcebb..2b5491f62 100644 --- a/src/libs/installer/utils.cpp +++ b/src/libs/installer/utils.cpp @@ -45,6 +45,7 @@ #include <QtCore/QDir> #include <QtCore/QProcessEnvironment> #include <QtCore/QVector> +#include <QCoreApplication> #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) # include "qt_windows.h" @@ -54,6 +55,39 @@ #include <iostream> #include <sstream> + +#ifdef Q_OS_WIN +#include <windows.h> // for Sleep +#endif +#ifdef Q_OS_UNIX +#include <errno.h> +#include <signal.h> +#include <time.h> +#endif + +namespace { +void sleepCopiedFromQTest(int ms) +{ + if (ms < 0) + return; +#ifdef Q_OS_WIN + Sleep(uint(ms)); +#else + struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 }; + nanosleep(&ts, NULL); +#endif +} +} +void QInstaller::uiDetachedWait(int ms) +{ + QTime timer; + timer.start(); + do { + QCoreApplication::processEvents(QEventLoop::AllEvents, ms); + sleepCopiedFromQTest(10); + } while (timer.elapsed() < ms); +} + static bool verb = false; void QInstaller::setVerbose(bool v) |