AchievementManager: Use HookableEvent instead of std::function callbacks

The callback mechanism AchievementManager had until now only supported
one caller registering a callback, and it didn't have any
synchronization. This isn't a problem for DolphinQt, but the PR to add
Android support for RetroAchievements exposes these problems. Let's
replace it with HookableEvent, which can handle all of this.
This commit is contained in:
JosJuice committed 2025-08-24 14:47:13 +02:00
1 parent 0c7fe651bb
commit de98c3b96f
6 files changed
+39 -44

No files matched your search

@@ -30,12 +30,16 @@ AchievementsWindow::AchievementsWindow(QWidget* parent) : QDialog(parent)
CreateMainLayout();
ConnectWidgets();
AchievementManager::GetInstance().SetUpdateCallback(
m_event_hook = AchievementManager::UpdateEvent::Register(
[this](AchievementManager::UpdatedItems updated_items) {
QueueOnObject(this, [this, updated_items = std::move(updated_items)] {
AchievementsWindow::UpdateData(std::move(updated_items));
});
});
},
"AchievementsWindow");
UpdateData(AchievementManager::UpdatedItems{.all = true});
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
[this] { m_settings_widget->UpdateData(RC_OK); });
}