diff options
Diffstat (limited to 'src/qt_common/game_list/model.cpp')
| -rw-r--r-- | src/qt_common/game_list/model.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/qt_common/game_list/model.cpp b/src/qt_common/game_list/model.cpp index 4f3916b04d..23d8ec1f43 100644 --- a/src/qt_common/game_list/model.cpp +++ b/src/qt_common/game_list/model.cpp @@ -44,9 +44,21 @@ GameListModel::GameListModel(std::shared_ptr<FileSys::VfsFilesystem> vfs_, setSortRole(GameListItemPath::SortRole); } -GameListModel::~GameListModel() = default; +GameListModel::~GameListModel() { + StopWorker(); +} + +void GameListModel::SetScanEnabled(bool enabled) { + scan_enabled = enabled; + if (!enabled) { + StopWorker(); + } +} void GameListModel::PopulateAsync(QVector<UISettings::GameDir>& game_dirs) { + if (!scan_enabled || system.IsPoweredOn()) { + return; + } emit PopulatingStarted(); StopWorker(); @@ -62,11 +74,14 @@ void GameListModel::PopulateAsync(QVector<UISettings::GameDir>& game_dirs) { } void GameListModel::WorkerEvent() { - current_worker->ProcessEvents(this); + if (current_worker) { + current_worker->ProcessEvents(this); + } } void GameListModel::AddDirEntry(GameListDir* entry_items) { if (m_flat) { + delete entry_items; return; } invisibleRootItem()->appendRow(entry_items); @@ -172,7 +187,7 @@ void GameListModel::StopWorker() { void GameListModel::Repopulate() { // CreateFactories replaces the content providers a running game reads from. Stopping // emulation repopulates the list anyway, so skip watcher-driven reloads until then. - if (QtCommon::system->IsPoweredOn()) { + if (!scan_enabled || QtCommon::system->IsPoweredOn()) { LOG_INFO(Frontend, "Emulation is running, deferring game list reload."); return; } |
