From ce823759cccee980552659b829b3513af290aeea Mon Sep 17 00:00:00 2001 From: BreadFish64 Date: Mon, 8 Oct 2018 15:37:44 -0500 Subject: [PATCH] citra-qt: disable directory watcher during CIA installation (#4284) * disable directory watcher during CIA installation fixes several errors while installing multiple CIAs * use braces in if statement --- src/citra_qt/game_list.cpp | 13 ++++++++++++- src/citra_qt/game_list.h | 1 + src/citra_qt/main.cpp | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index 1682e7caa2..e21edb11dc 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -267,7 +267,8 @@ void GameList::onFilterCloseClicked() { GameList::GameList(GMainWindow* parent) : QWidget{parent} { watcher = new QFileSystemWatcher(this); - connect(watcher, &QFileSystemWatcher::directoryChanged, this, &GameList::RefreshGameDirectory); + connect(watcher, &QFileSystemWatcher::directoryChanged, this, &GameList::RefreshGameDirectory, + Qt::UniqueConnection); this->main_window = parent; layout = new QVBoxLayout; @@ -325,6 +326,16 @@ void GameList::setFilterVisible(bool visibility) { search_field->setVisible(visibility); } +void GameList::setDirectoryWatcherEnabled(bool enabled) { + if (enabled) { + connect(watcher, &QFileSystemWatcher::directoryChanged, this, + &GameList::RefreshGameDirectory, Qt::UniqueConnection); + } else { + disconnect(watcher, &QFileSystemWatcher::directoryChanged, this, + &GameList::RefreshGameDirectory); + } +} + void GameList::clearFilter() { search_field->clear(); } diff --git a/src/citra_qt/game_list.h b/src/citra_qt/game_list.h index ffa1d64e7f..b3e2911b67 100644 --- a/src/citra_qt/game_list.h +++ b/src/citra_qt/game_list.h @@ -49,6 +49,7 @@ public: void clearFilter(); void setFilterFocus(); void setFilterVisible(bool visibility); + void setDirectoryWatcherEnabled(bool enabled); bool isEmpty(); void LoadCompatibilityList(); diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 5ff9b71196..40c42fc310 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -1013,6 +1013,7 @@ void GMainWindow::OnMenuInstallCIA() { return; ui.action_Install_CIA->setEnabled(false); + game_list->setDirectoryWatcherEnabled(false); progress_bar->show(); progress_bar->setMaximum(INT_MAX); @@ -1066,7 +1067,9 @@ void GMainWindow::OnCIAInstallReport(Service::AM::InstallStatus status, QString void GMainWindow::OnCIAInstallFinished() { progress_bar->hide(); progress_bar->setValue(0); + game_list->setDirectoryWatcherEnabled(true); ui.action_Install_CIA->setEnabled(true); + game_list->PopulateAsync(UISettings::values.game_dirs); } void GMainWindow::OnMenuRecentFile() {