mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-10-01 01:06:10 -04:00
Don't compare non-numeric parts of the version string.
Signed-off-by: Adam Treat <treat.adam@gmail.com>
This commit is contained in:
parent
f3734e5de8
commit
b4dc7deec1
@ -1444,14 +1444,21 @@ void ModelList::updateDataForSettings()
|
|||||||
|
|
||||||
static std::strong_ordering compareVersions(const QString &a, const QString &b)
|
static std::strong_ordering compareVersions(const QString &a, const QString &b)
|
||||||
{
|
{
|
||||||
|
QRegularExpression regex("(\\d+)");
|
||||||
QStringList aParts = a.split('.');
|
QStringList aParts = a.split('.');
|
||||||
QStringList bParts = b.split('.');
|
QStringList bParts = b.split('.');
|
||||||
|
Q_ASSERT(aParts.size() == 3);
|
||||||
|
Q_ASSERT(bParts.size() == 3);
|
||||||
|
|
||||||
for (int i = 0; i < std::min(aParts.size(), bParts.size()); ++i) {
|
for (int i = 0; i < std::min(aParts.size(), bParts.size()); ++i) {
|
||||||
int aInt = aParts[i].toInt();
|
QRegularExpressionMatch aMatch = regex.match(aParts[i]);
|
||||||
int bInt = bParts[i].toInt();
|
QRegularExpressionMatch bMatch = regex.match(bParts[i]);
|
||||||
if (auto diff = aInt <=> bInt; diff != 0) {
|
Q_ASSERT(aMatch.hasMatch() && bMatch.hasMatch());
|
||||||
return diff;
|
if (aMatch.hasMatch() && bMatch.hasMatch()) {
|
||||||
|
int aInt = aMatch.captured(1).toInt();
|
||||||
|
int bInt = bMatch.captured(1).toInt();
|
||||||
|
if (auto diff = aInt <=> bInt; diff != 0)
|
||||||
|
return diff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user