mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-12 13:00:01 -08:00
Compare commits
3 commits
2c0c8b416a
...
94c5a7d43f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94c5a7d43f | ||
|
|
7a4cfa5685 | ||
|
|
fdbc4734a4 |
5 changed files with 34 additions and 15 deletions
|
|
@ -166,7 +166,7 @@ bool DeckList::readElement(QXmlStreamReader *xml)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeMetadata(QXmlStreamWriter *xml, const DeckList::Metadata &metadata)
|
static void writeMetadata(QXmlStreamWriter *xml, const DeckList::Metadata &metadata)
|
||||||
{
|
{
|
||||||
xml->writeTextElement("lastLoadedTimestamp", metadata.lastLoadedTimestamp);
|
xml->writeTextElement("lastLoadedTimestamp", metadata.lastLoadedTimestamp);
|
||||||
xml->writeTextElement("deckname", metadata.name);
|
xml->writeTextElement("deckname", metadata.name);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ public:
|
||||||
{
|
{
|
||||||
return playerId;
|
return playerId;
|
||||||
}
|
}
|
||||||
bool operator==(const PlayerReference &other)
|
bool operator==(const PlayerReference &other) const
|
||||||
{
|
{
|
||||||
return ((roomId == other.roomId) && (gameId == other.gameId) && (playerId == other.playerId));
|
return ((roomId == other.roomId) && (gameId == other.gameId) && (playerId == other.playerId));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,11 @@ qulonglong SystemMemoryQuerier::availableMemoryBytes()
|
||||||
while (!in.atEnd()) {
|
while (!in.atEnd()) {
|
||||||
QString line = in.readLine();
|
QString line = in.readLine();
|
||||||
if (line.startsWith("MemAvailable:")) {
|
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)
|
if (parts.size() >= 2)
|
||||||
return parts[1].toULongLong() * 1024;
|
return parts[1].toULongLong() * 1024;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,14 @@ public:
|
||||||
|
|
||||||
static bool hasAtLeastGiB(int gib)
|
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;
|
const qulonglong GiB = 1024ull * 1024ull * 1024ull;
|
||||||
return totalMemoryBytes() >= (qulonglong)gib * GiB;
|
return total >= (qulonglong)gib * GiB;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -188,21 +188,30 @@ void LoadSetsPage::initializePage()
|
||||||
urlLineEdit->setText(wizard()->settings->value("allsetsurl", ALLSETS_URL).toString());
|
urlLineEdit->setText(wizard()->settings->value("allsetsurl", ALLSETS_URL).toString());
|
||||||
|
|
||||||
// Memory check because Oracle parsing fails on systems with less than 4GiB for MTGJsons allPrintings.json
|
// Memory check because Oracle parsing fails on systems with less than 4GiB for MTGJsons allPrintings.json
|
||||||
|
// The fallback URL is xz-compressed, so only offer it in builds that can read it.
|
||||||
|
// During background (automatic) updates there is no user to answer, so switch silently.
|
||||||
|
#ifdef HAS_LZMA
|
||||||
if (!SystemMemoryQuerier::hasAtLeastGiB(4) && urlLineEdit->text() == ALLSETS_URL) {
|
if (!SystemMemoryQuerier::hasAtLeastGiB(4) && urlLineEdit->text() == ALLSETS_URL) {
|
||||||
// Ask user whether to switch URL
|
if (wizard()->backgroundMode) {
|
||||||
QMessageBox msgBox(
|
|
||||||
QMessageBox::Question, tr("Low Memory Detected"),
|
|
||||||
tr("Your system has less than 4 GiB of memory.\n"
|
|
||||||
"Using the default AllPrintings URL may cause high memory usage and is known to fail as a result.\n\n"
|
|
||||||
"Would you like to switch to the direct-download pre-parsed URL instead? (Updated daily)"),
|
|
||||||
QMessageBox::Yes | QMessageBox::No, this);
|
|
||||||
|
|
||||||
msgBox.setDefaultButton(QMessageBox::Yes);
|
|
||||||
|
|
||||||
if (msgBox.exec() == QMessageBox::Yes) {
|
|
||||||
urlLineEdit->setText(MTGXML_URL);
|
urlLineEdit->setText(MTGXML_URL);
|
||||||
|
} else {
|
||||||
|
// Ask user whether to switch URL
|
||||||
|
QMessageBox msgBox(
|
||||||
|
QMessageBox::Question, tr("Low Memory Detected"),
|
||||||
|
tr("Your system has less than 4 GiB of memory.\n"
|
||||||
|
"Using the default AllPrintings URL may cause high memory usage and is known to fail as a "
|
||||||
|
"result.\n\n"
|
||||||
|
"Would you like to switch to the direct-download pre-parsed URL instead? (Updated daily)"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No, this);
|
||||||
|
|
||||||
|
msgBox.setDefaultButton(QMessageBox::Yes);
|
||||||
|
|
||||||
|
if (msgBox.exec() == QMessageBox::Yes) {
|
||||||
|
urlLineEdit->setText(MTGXML_URL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
progressLabel->hide();
|
progressLabel->hide();
|
||||||
progressBar->hide();
|
progressBar->hide();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue