mirror of
https://github.com/azahar-emu/azahar.git
synced 2026-06-06 02:33:44 -04:00
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:
parent
3fdcd6b7dc
commit
a5ac24adc5
2 changed files with 11 additions and 1 deletions
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue