mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-06 10:03:26 -08:00
[Oracle] Fix Qt6 build and treat unknown memory as sufficient
Use QRegularExpression behind the same Qt version guard as totalMemoryBytes() in availableMemoryBytes(), where a bare QRegExp broke every Qt6 Linux build. hasAtLeastGiB() now treats a 0 reading (unsupported platform or failed query) as unknown and skips the low-memory prompt instead of misreading it as low memory.
This commit is contained in:
parent
d36b366f1a
commit
d5094a8d00
2 changed files with 12 additions and 2 deletions
|
|
@ -84,7 +84,11 @@ qulonglong SystemMemoryQuerier::availableMemoryBytes()
|
|||
while (!in.atEnd()) {
|
||||
QString line = in.readLine();
|
||||
if (line.startsWith("MemAvailable:")) {
|
||||
QStringList parts = line.split(QRegExp("\\s+"), Qt::SkipEmptyParts);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QStringList parts = line.split(QRegExp("\\s+"), QString::SkipEmptyParts);
|
||||
#else
|
||||
QStringList parts = line.split(QRegularExpression("\\s+"), Qt::SkipEmptyParts);
|
||||
#endif
|
||||
if (parts.size() >= 2)
|
||||
return parts[1].toULongLong() * 1024;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,14 @@ public:
|
|||
|
||||
static bool hasAtLeastGiB(int gib)
|
||||
{
|
||||
const qulonglong total = totalMemoryBytes();
|
||||
// 0 means the amount could not be determined (unsupported platform or failed query).
|
||||
// Treat it as unknown and skip the check instead of misreading it as low memory.
|
||||
if (total == 0) {
|
||||
return true;
|
||||
}
|
||||
const qulonglong GiB = 1024ull * 1024ull * 1024ull;
|
||||
return totalMemoryBytes() >= (qulonglong)gib * GiB;
|
||||
return total >= (qulonglong)gib * GiB;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue