Index: sources/ApplicationPost.cpp =================================================================== diff -u -ra5760947d3ed0d2748ba023a1c25e3c6aa0b1de1 -r3e682c5afdadcf4dd2006e3d975fbee58e48619e --- sources/ApplicationPost.cpp (.../ApplicationPost.cpp) (revision a5760947d3ed0d2748ba023a1c25e3c6aa0b1de1) +++ sources/ApplicationPost.cpp (.../ApplicationPost.cpp) (revision 3e682c5afdadcf4dd2006e3d975fbee58e48619e) @@ -17,6 +17,8 @@ #include #include #include +#include +#include // Project #include "Logger.h" @@ -89,37 +91,34 @@ */ bool ApplicationPost::checkOSVersion() { - QString exrVer("%1\\s*\"\\d+\\.\\d+\\.\\d+\""); - QString exrBld("%1\\s*\"\\d+\""); + // TODO: Qt6 Port - verify function has been correctly ported + QString exrVer("%1\\s*\"(\\d+)\\.(\\d+)\\.(\\d+)\""); + QString exrBld("%1\\s*\"(\\d+)\""); - QRegExp regVer(exrVer.arg(_postmsg_osversion)); - QRegExp regBld(exrBld.arg(_postmsg_osbuild )); + QRegularExpression regVer(exrVer.arg(_postmsg_osversion)); + QRegularExpression regBld(exrBld.arg(_postmsg_osbuild)); QString version; QString build; - QStringList versions; quint16 major; quint16 minor; quint16 micro; - // check the statement exists in the long - int rowVer = _content.indexOf (regVer); - int rowBld = _content.indexOf (regBld); Q_UNUSED(rowBld); - bool ok = rowVer >= 0; // found + QRegularExpressionMatch matchVer = regVer.match(_content); + QRegularExpressionMatch matchBld = regBld.match(_content); + + bool ok = matchVer.hasMatch() && matchBld.hasMatch(); if ( ! ok ) goto lOut; - // check the Os version is compatible - version = regVer.cap(0).replace(_postmsg_osversion,"").replace("\"",""); // 0 is the first captured and next if any are the subsets. - build = regBld.cap(0).replace(_postmsg_osbuild ,"").replace("\"",""); // 0 is the first captured and next if any are the subsets. - versions = version.split("."); - major = versions[0].toUInt(); // type, existance, count has been already tested by regex, and was rejected in first check section. - minor = versions[1].toUInt(); // type, existance, count has been already tested by regex, and was rejected in first check section. - micro = versions[2].toUInt(); // type, existance, count has been already tested by regex, and was rejected in first check section. + major = matchVer.captured(1).toUInt(); + minor = matchVer.captured(2).toUInt(); + micro = matchVer.captured(3).toUInt(); + ok = major >= Storage::OS_VERSION_MAJOR && minor >= Storage::OS_VERSION_MINOR && micro >= Storage::OS_VERSION_MICRO ; if ( ! ok ) goto lOut; - _osVersion = version + "." + build; + _osVersion = QString("%1.%2.%3.%4").arg(major).arg(minor).arg(micro).arg(matchBld.captured(1)); lOut: if ( ! ok ) emit didFail(Gui::GuiAlarmID::ALARM_ID_UI_POST_FAILURE_OS_VERSION);