More fixes.

Took 4 minutes


Took 4 seconds
This commit is contained in:
Lukas Brübach 2026-07-27 12:42:04 +02:00
parent 48780ccc24
commit e4dc46ce37
6 changed files with 32 additions and 7 deletions

View file

@ -541,8 +541,10 @@ MainWindow::MainWindow(QWidget *parent)
void MainWindow::startupConfigCheck() void MainWindow::startupConfigCheck()
{ {
// Signals for unknown/failed DB were emitted during the front-loaded parse // checkUnknownSets() is intentionally deferred from the card database load
// before MainWindow existed. Drive the UX now that receivers are connected. // (which runs in main() before MainWindow exists) so that
// cardDatabaseNewSetsFound / cardDatabaseAllNewSetsEnabled have live
// receivers when emitted.
CardDatabaseManager::getInstance()->checkUnknownSets(); CardDatabaseManager::getInstance()->checkUnknownSets();
if (SettingsCache::instance().debug().getLocalGameOnStartup()) { if (SettingsCache::instance().debug().getLocalGameOnStartup()) {

View file

@ -264,8 +264,9 @@ int main(int argc, char *argv[])
// contention that happens when the load runs alongside window construction. // contention that happens when the load runs alongside window construction.
// The CardDatabaseModel populates from the already-loaded data in its // The CardDatabaseModel populates from the already-loaded data in its
// constructor, so the window appears fully populated with no startup lag. // constructor, so the window appears fully populated with no startup lag.
// Note: unknown-set / failure signals are deferred; MainWindow triggers // Note: checkUnknownSets() is deferred until MainWindow::startupConfigCheck()
// checkUnknownSets() in startupConfigCheck() once receivers are connected. // so that cardDatabaseNewSetsFound / cardDatabaseAllNewSetsEnabled have live
// receivers when emitted.
CardDatabaseManager::getInstance()->loadCardDatabases(); CardDatabaseManager::getInstance()->loadCardDatabases();
MainWindow ui; MainWindow ui;

View file

@ -57,6 +57,12 @@ protected:
public: public:
/** /**
* @brief Check for sets that are unknown and emit signals if needed. * @brief Check for sets that are unknown and emit signals if needed.
*
* Called from MainWindow::startupConfigCheck() after signal connections are
* live (the front-loaded parse in main() runs before MainWindow exists, so
* signals emitted there would have no receivers). May also be called by
* the loader via the friend declaration. Has side effects: enables all
* sets when none are enabled (first-run), marks all sets as known.
*/ */
void checkUnknownSets(); void checkUnknownSets();

View file

@ -129,7 +129,11 @@ LoadStatus CardDatabaseLoader::doLoadCardDatabases()
qCInfo(CardDatabaseLoadingSuccessOrFailureLog) << "Card Database Loading Success"; qCInfo(CardDatabaseLoadingSuccessOrFailureLog) << "Card Database Loading Success";
emit databaseDataReady(std::move(data)); emit databaseDataReady(std::move(data));
emit loadingFinished(); emit loadingFinished();
database->checkUnknownSets(); // NOTE: checkUnknownSets() is intentionally NOT called here. During
// the front-loaded parse in main() this runs before MainWindow exists,
// so cardDatabaseNewSetsFound / cardDatabaseAllNewSetsEnabled would be
// emitted with no receivers. MainWindow::startupConfigCheck() calls
// checkUnknownSets() once its signal connections are live.
} else { } else {
qCInfo(CardDatabaseLoadingSuccessOrFailureLog) << "Card Database Loading Failed"; qCInfo(CardDatabaseLoadingSuccessOrFailureLog) << "Card Database Loading Failed";
emit loadingFailed(); // bring up the settings dialog emit loadingFailed(); // bring up the settings dialog

View file

@ -72,7 +72,19 @@ protected:
static SetNameMap sets; static SetNameMap sets;
ICardSetPriorityController *cardSetPriorityController; ICardSetPriorityController *cardSetPriorityController;
/** @brief Snapshot the current parse is filling, or nullptr when emitting signals. */ /**
* @brief Snapshot the current parse is filling, or nullptr when emitting signals.
*
* This is an implicit-inheritance-via-member-variable pattern: parseFileInto()
* sets this before delegating to parseFile(), and loadCardsFromXml() /
* loadFormats() check it to decide between direct insertion and signal
* emission. Safe under the current model because loadFromFileMutex serialises
* all parser access and parseFile() is never re-entered. If a future change
* adds parallel parsing or a second parseFileInto() call within parseFile(),
* this pointer would race -- at that point refactor to pass CardDatabaseData*
* through the call chain instead. However, we are mostly RAM, not CPU bound on
* DB startup at this point so there's not much point to parallel parsing.
*/
CardDatabaseData *targetData = nullptr; CardDatabaseData *targetData = nullptr;
/** /**

View file

@ -31,7 +31,7 @@ public:
SetOptions getSetOptions(QString /* shortName */) const override SetOptions getSetOptions(QString /* shortName */) const override
{ {
return {}; return {0, true, true};
} }
void saveSets(const QVector<SetSaveData> & /* data */) override void saveSets(const QVector<SetSaveData> & /* data */) override