Skip to content

Commit 4779677

Browse files
committed
I turns out that the syncqt tool does not create a correct hex version
parse the string version instead
1 parent 6df6025 commit 4779677

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

generator/main.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ bool preprocess(const QString& sourceFile, const QString& targetFile, const QStr
307307

308308
unsigned int getQtVersion(const QStringList& paths)
309309
{
310-
QRegularExpression re("#define\\s+QTCORE_VERSION\\s+0x([0-9a-f]+)", QRegularExpression::CaseInsensitiveOption);
310+
QRegularExpression re(R"*(#define\s+QTCORE_VERSION_STR\s+"(\d+)\.(\d+)\.(\d+)")*",
311+
QRegularExpression::CaseInsensitiveOption);
311312

312313
// Iterate through provided paths to find the qtcoreversion.h header file
313314
for (const QString& path : paths) {
@@ -341,10 +342,11 @@ unsigned int getQtVersion(const QStringList& paths)
341342
auto match = re.match(content);
342343
if (match.isValid()) {
343344
unsigned int result;
344-
bool ok;
345-
result = match.captured(1).toUInt(&ok, 16);
346-
if (!ok) {
347-
printf("Could not parse Qt version in file [%s] (looked for #define QTCORE_VERSION)\n",
345+
bool ok1, ok2, ok3;
346+
result = (match.captured(1).toUInt(&ok1) << 16) + (match.captured(2).toUInt(&ok2) << 8)
347+
+ match.captured(3).toUInt(&ok3);
348+
if (!ok1 || !ok2 || !ok3) {
349+
printf("Could not parse Qt version in file [%s] (looked for #define QTCORE_VERSION_STR)\n",
348350
qPrintable(filePath));
349351
}
350352
return result;

0 commit comments

Comments
 (0)