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())
|
||||
return true;
|
||||
|
||||
const QStringList exampleVersionParts = exampleVersion.split('.');
|
||||
const QStringList qdsVersionParts = QCoreApplication::applicationVersion().split('.');
|
||||
// Split versions into parts (major, minor, patch)
|
||||
QStringList qdsVersionParts = QCoreApplication::applicationVersion().split('.');
|
||||
QStringList exampleVersionParts = exampleVersion.split('.');
|
||||
|
||||
QList<int> exampleVerInts;
|
||||
QList<int> qdsVerInts;
|
||||
for (const QString &part : exampleVersionParts)
|
||||
exampleVerInts.append(part.toInt());
|
||||
// Fill missing parts with zeros
|
||||
while (qdsVersionParts.size() < 3)
|
||||
qdsVersionParts.append("0");
|
||||
|
||||
for (const QString &part : qdsVersionParts)
|
||||
qdsVerInts.append(part.toInt());
|
||||
while (exampleVersionParts.size() < 3)
|
||||
exampleVersionParts.append("0");
|
||||
|
||||
// pad zeros so both lists are same size
|
||||
while (qdsVerInts.size() < exampleVerInts.size())
|
||||
qdsVerInts.append(0);
|
||||
int qdsMajor = qdsVersionParts.at(0).toInt();
|
||||
int qdsMinor = qdsVersionParts.at(1).toInt();
|
||||
int qdsPatch = qdsVersionParts.at(2).toInt();
|
||||
|
||||
while (exampleVerInts.size() < qdsVerInts.size())
|
||||
exampleVerInts.append(0);
|
||||
int exMajor = exampleVersionParts.at(0).toInt();
|
||||
int exMinor = exampleVersionParts.at(1).toInt();
|
||||
int exPatch = exampleVersionParts.at(2).toInt();
|
||||
|
||||
for (int i = 0; i < qdsVerInts.size(); ++i) {
|
||||
if (exampleVerInts[i] < qdsVerInts[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return QT_VERSION_CHECK(exMajor, exMinor, exPatch)
|
||||
<= QT_VERSION_CHECK(qdsMajor, qdsMinor, qdsPatch);
|
||||
}
|
||||
|
||||
public slots:
|
||||
|
Reference in New Issue
Block a user