forked from qt-creator/qt-creator
QmlDesigner: Fix examples version handling
Example version should be <= QDS version to show in the examples.
Fixes: QDS-12853
Change-Id: Iaa4e6244a5451e05672f9001a0d74ef84144b1bc
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
(cherry picked from commit f752178576
)
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
committed by
Tim Jenssen
parent
50501d7ab8
commit
e9de4e0805
@@ -338,30 +338,27 @@ public:
|
|||||||
if (exampleVersion.isEmpty())
|
if (exampleVersion.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
const QStringList exampleVersionParts = exampleVersion.split('.');
|
// Split versions into parts (major, minor, patch)
|
||||||
const QStringList qdsVersionParts = QCoreApplication::applicationVersion().split('.');
|
QStringList qdsVersionParts = QCoreApplication::applicationVersion().split('.');
|
||||||
|
QStringList exampleVersionParts = exampleVersion.split('.');
|
||||||
|
|
||||||
QList<int> exampleVerInts;
|
// Fill missing parts with zeros
|
||||||
QList<int> qdsVerInts;
|
while (qdsVersionParts.size() < 3)
|
||||||
for (const QString &part : exampleVersionParts)
|
qdsVersionParts.append("0");
|
||||||
exampleVerInts.append(part.toInt());
|
|
||||||
|
|
||||||
for (const QString &part : qdsVersionParts)
|
while (exampleVersionParts.size() < 3)
|
||||||
qdsVerInts.append(part.toInt());
|
exampleVersionParts.append("0");
|
||||||
|
|
||||||
// pad zeros so both lists are same size
|
int qdsMajor = qdsVersionParts.at(0).toInt();
|
||||||
while (qdsVerInts.size() < exampleVerInts.size())
|
int qdsMinor = qdsVersionParts.at(1).toInt();
|
||||||
qdsVerInts.append(0);
|
int qdsPatch = qdsVersionParts.at(2).toInt();
|
||||||
|
|
||||||
while (exampleVerInts.size() < qdsVerInts.size())
|
int exMajor = exampleVersionParts.at(0).toInt();
|
||||||
exampleVerInts.append(0);
|
int exMinor = exampleVersionParts.at(1).toInt();
|
||||||
|
int exPatch = exampleVersionParts.at(2).toInt();
|
||||||
|
|
||||||
for (int i = 0; i < qdsVerInts.size(); ++i) {
|
return QT_VERSION_CHECK(exMajor, exMinor, exPatch)
|
||||||
if (exampleVerInts[i] < qdsVerInts[i])
|
<= QT_VERSION_CHECK(qdsMajor, qdsMinor, qdsPatch);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
Reference in New Issue
Block a user