qt: Workaround for Qt directoryChanged event spam on macOS (#1665)

* qt: Workaround for Qt directoryChanged event spam on macOS

* Use steady_clock instead of system_clock
This commit is contained in:
OpenSauce 2026-01-21 21:15:49 +00:00 committed by GitHub
parent 3fdcd6b7dc
commit a5ac24adc5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View file

@ -1113,13 +1113,21 @@ const QStringList GameList::supported_file_extensions = {
}; };
void GameList::RefreshGameDirectory() { void GameList::RefreshGameDirectory() {
// Do not scan directories when the system is powered on, it will be // Do not scan directories when the system is powered on, it will be
// repopulated on shutdown anyways. // repopulated on shutdown anyways.
if (Core::System::GetInstance().IsPoweredOn()) { if (Core::System::GetInstance().IsPoweredOn()) {
return; return;
} }
const auto time_now = std::chrono::steady_clock::now();
// Max of 1 refresh every 1 second.
if (time_last_refresh + std::chrono::seconds(1) > time_now) {
return;
}
time_last_refresh = time_now;
if (!UISettings::values.game_dirs.isEmpty() && current_worker != nullptr) { if (!UISettings::values.game_dirs.isEmpty() && current_worker != nullptr) {
LOG_INFO(Frontend, "Change detected in the applications directory. Reloading game list."); LOG_INFO(Frontend, "Change detected in the applications directory. Reloading game list.");
PopulateAsync(UISettings::values.game_dirs); PopulateAsync(UISettings::values.game_dirs);

View file

@ -153,6 +153,8 @@ private:
friend class GameListSearchField; friend class GameListSearchField;
const PlayTime::PlayTimeManager& play_time_manager; const PlayTime::PlayTimeManager& play_time_manager;
std::chrono::time_point<std::chrono::steady_clock> time_last_refresh;
}; };
class GameListPlaceholder : public QWidget { class GameListPlaceholder : public QWidget {