diff --git a/utils/rbutilqt/base/playerbuildinfo.cpp b/utils/rbutilqt/base/playerbuildinfo.cpp index aba377eafc..195c170f0e 100644 --- a/utils/rbutilqt/base/playerbuildinfo.cpp +++ b/utils/rbutilqt/base/playerbuildinfo.cpp @@ -137,9 +137,9 @@ QVariant PlayerBuildInfo::value(BuildInfo item, BuildType type) break; } - QVariant result = QString(); + QVariant result; if (!serverInfo) - return result; + return QString(); QStringList version = serverInfo->value(buildtypename + "/" + target, "").toStringList(); serverinfo.replace(":build:", buildtypename); serverinfo.replace(":version:", version.at(0)); @@ -149,7 +149,7 @@ QVariant PlayerBuildInfo::value(BuildInfo item, BuildType type) // For invalid data return an empty string. if(version.at(0).isEmpty()) { LOG_INFO() << serverinfo << "(version invalid)"; - return result; + return QString(); } if(!serverinfo.isEmpty()) result = serverInfo->value(serverinfo); @@ -189,7 +189,11 @@ QVariant PlayerBuildInfo::value(BuildInfo item, BuildType type) // if the value is a string we can replace some patterns. // if we cannot convert it (f.e. for a QStringList) we leave as-is, since // the conversion would return an empty type. - if (result.canConvert(QMetaType::QString)) +#if QT_VERSION < 0x060000 + if (result.type() == QVariant::String) +#else + if (result.metaType().id() == QMetaType::QString) +#endif result = result.toString() .replace("%TARGET%", target) .replace("%VERSION%", version.at(0)); diff --git a/utils/rbutilqt/test/test-playerbuildinfo.cpp b/utils/rbutilqt/test/test-playerbuildinfo.cpp index de81b36a30..281f2682e9 100644 --- a/utils/rbutilqt/test/test-playerbuildinfo.cpp +++ b/utils/rbutilqt/test/test-playerbuildinfo.cpp @@ -212,10 +212,10 @@ void TestPlayerBuildInfo::testBuildInfo() RbSettings::setValue(RbSettings::CurrentPlatform, target); QVariant result = PlayerBuildInfo::instance()->value(item, type); - if(result.canConvert(QMetaType::QString)) - QCOMPARE(result.toString(), QString(expected)); - else + if(result.canConvert(QMetaType::QStringList)) QCOMPARE(result.toStringList().join(","), QString(expected)); + else + QCOMPARE(result.toString(), QString(expected)); } @@ -252,10 +252,10 @@ void TestPlayerBuildInfo::testPlayerInfo() QFETCH(QString, expected); QVariant result = PlayerBuildInfo::instance()->value(item, target); - if(result.canConvert(QMetaType::QString)) - QCOMPARE(result.toString(), QString(expected)); - else + if(result.canConvert(QMetaType::QStringList)) QCOMPARE(result.toStringList().join(","), QString(expected)); + else + QCOMPARE(result.toString(), QString(expected)); }