diff options
author | Tim Jenssen <tim.jenssen@digia.com> | 2013-05-31 16:40:12 +0200 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@digia.com> | 2013-06-03 16:35:23 +0200 |
commit | c2cfa6dd833f60d75cc7aafe7282d052cdae5257 (patch) | |
tree | 61abe2480beaef69b583e7ff420fa5db7ba1925d /src/libs/installer/qtpatch.cpp | |
parent | 955db4b7492cbb044de2a7f1d3a145e533f5a701 (diff) |
adding ConsumeOutputOperation
- With that operation we can save the original qmake output,
before the installer does the patching. So we can use the old values
for modules patching if they will be installed later.
- added a autotest which does that with the current used qmake
Change-Id: Ie07d273bf64d1813b7af3374a0db35a9e1215503
Reviewed-by: Niels Weber <niels.weber@digia.com>
Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
Diffstat (limited to 'src/libs/installer/qtpatch.cpp')
-rw-r--r-- | src/libs/installer/qtpatch.cpp | 57 |
1 files changed, 17 insertions, 40 deletions
diff --git a/src/libs/installer/qtpatch.cpp b/src/libs/installer/qtpatch.cpp index 02795b34b..6581815c2 100644 --- a/src/libs/installer/qtpatch.cpp +++ b/src/libs/installer/qtpatch.cpp @@ -40,6 +40,7 @@ **************************************************************************/ #include "qtpatch.h" +#include "utils.h" #include <QString> #include <QStringList> @@ -52,35 +53,20 @@ #include <QCoreApplication> #include <QByteArrayMatcher> -#ifdef Q_OS_WIN -#include <windows.h> // for Sleep -#endif -#ifdef Q_OS_UNIX -#include <errno.h> -#include <signal.h> -#include <time.h> -#endif - -static void sleepCopiedFromQTest(int ms) +QHash<QString, QByteArray> QtPatch::readQmakeOutput(const QByteArray &data) { - 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 -} - -static void uiDetachedWait(int ms) -{ - QTime timer; - timer.start(); - do { - QCoreApplication::processEvents(QEventLoop::AllEvents, ms); - sleepCopiedFromQTest(10); - } while (timer.elapsed() < ms); + QHash<QString, QByteArray> qmakeValueHash; + QTextStream stream(data, QIODevice::ReadOnly); + while (!stream.atEnd()) { + const QString line = stream.readLine(); + const int index = line.indexOf(QLatin1Char(':')); + if (index != -1) { + QString value = line.mid(index+1); + if (value != QLatin1String("**Unknown**") ) + qmakeValueHash.insert(line.left(index), value.toUtf8()); + } + } + return qmakeValueHash; } QHash<QString, QByteArray> QtPatch::qmakeValues(const QString &qmakePath, QByteArray *qmakeOutput) @@ -113,21 +99,12 @@ QHash<QString, QByteArray> QtPatch::qmakeValues(const QString &qmakePath, QByteA } QByteArray output = process.readAllStandardOutput(); qmakeOutput->append(output); - QTextStream stream(&output); - while (!stream.atEnd()) { - const QString line = stream.readLine(); - const int index = line.indexOf(QLatin1Char(':')); - if (index != -1) { - QString value = line.mid(index+1); - if (value != QLatin1String("**Unknown**") ) - qmakeValueHash.insert(line.left(index), value.toUtf8()); - } - } + qmakeValueHash = readQmakeOutput(output); } if (qmakeValueHash.isEmpty()) { ++waitCount; static const int waitTimeInMilliSeconds = 500; - uiDetachedWait(waitTimeInMilliSeconds); + QInstaller::uiDetachedWait(waitTimeInMilliSeconds); } if (process.state() > QProcess::NotRunning ) { qDebug() << "qmake process is still running, need to kill it."; @@ -232,7 +209,7 @@ bool QtPatch::openFileForPatching(QFile *file) while (!file->open(QFile::ReadWrite) && waitCount < 60) { ++waitCount; static const int waitTimeInMilliSeconds = 500; - uiDetachedWait(waitTimeInMilliSeconds); + QInstaller::uiDetachedWait(waitTimeInMilliSeconds); } return file->openMode() == QFile::ReadWrite; } |