diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2017-04-26 15:37:57 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2017-04-27 09:30:35 +0000 |
commit | 5ef48dc2396257056fedca94fa359b1d392c33cd (patch) | |
tree | bd64f1df011f1ef383e63a397bafcee6bc135261 | |
parent | 533fe3fabad2a897c05d3e7edfab9738b67a21d3 (diff) |
libqtprofilesetup: Support default QPA detection also in dev builds
In a developer build, qtgui-config.h is a forwarding header.
Change-Id: I7f5747503174eaf04ef96dcd6c6bc70c303b37f7
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
-rw-r--r-- | src/lib/qtprofilesetup/qtprofilesetup.cpp | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/src/lib/qtprofilesetup/qtprofilesetup.cpp b/src/lib/qtprofilesetup/qtprofilesetup.cpp index 81dcbbf63..9f9462a38 100644 --- a/src/lib/qtprofilesetup/qtprofilesetup.cpp +++ b/src/lib/qtprofilesetup/qtprofilesetup.cpp @@ -57,6 +57,8 @@ #include <QtCore/qregularexpression.h> #include <QtCore/qtextstream.h> +#include <queue> + namespace qbs { using namespace Internal; @@ -98,22 +100,37 @@ static QString defaultQpaPlugin(const Profile &profile, const QtModuleInfo &modu + QStringLiteral("/QtGui") + (qtEnv.frameworkBuild ? QStringLiteral(".framework/Headers") : QString()) + QStringLiteral("/qtgui-config.h"); - QFile qtGuiConfigHeaderFile(qtGuiConfigHeader); - if (!qtGuiConfigHeaderFile.open(QIODevice::ReadOnly)) { - throw ErrorInfo(Tr::tr("Setting up Qt profile '%1' failed: Cannot open " - "file '%2' (%3).") - .arg(profile.name(), qtGuiConfigHeaderFile.fileName(), - qtGuiConfigHeaderFile.errorString())); - } - - const QRegularExpression regexp( - QStringLiteral("^#define QT_QPA_DEFAULT_PLATFORM_NAME \"(?<name>.+)\"")); - const QList<QByteArray> lines = qtGuiConfigHeaderFile.readAll().split('\n'); - for (const QByteArray &line : lines) { - const QRegularExpressionMatch match = regexp.match( - QString::fromLatin1(line.simplified())); - if (match.hasMatch()) - return QLatin1Char('q') + match.captured(QStringLiteral("name")); + std::queue<QString> headerFiles; + headerFiles.push(qtGuiConfigHeader); + while (!headerFiles.empty()) { + QFile headerFile(headerFiles.front()); + headerFiles.pop(); + if (!headerFile.open(QIODevice::ReadOnly)) { + throw ErrorInfo(Tr::tr("Setting up Qt profile '%1' failed: Cannot open " + "file '%2' (%3).") + .arg(profile.name(), headerFile.fileName(), + headerFile.errorString())); + } + static const QRegularExpression regexp( + QStringLiteral("^#define QT_QPA_DEFAULT_PLATFORM_NAME \"(?<name>.+)\"")); + static const QRegularExpression includeRegexp( + QStringLiteral("^#include \"(?<header>.+)\"")); + const QList<QByteArray> lines = headerFile.readAll().split('\n'); + for (const QByteArray &line: lines) { + const QString lineStr = QString::fromLatin1(line.simplified()); + QRegularExpressionMatch match = regexp.match(lineStr); + if (match.hasMatch()) + return QLatin1Char('q') + match.captured(QStringLiteral("name")); + match = includeRegexp.match(lineStr); + if (match.hasMatch()) { + QString filePath = match.captured(QStringLiteral("header")); + if (QFileInfo(filePath).isRelative()) { + filePath = QDir::cleanPath(QFileInfo(headerFile.fileName()).absolutePath() + + QLatin1Char('/') + filePath); + } + headerFiles.push(filePath); + } + } } } |