Synchronized Achievement Window

Expanded the use of the lock mutex already used for loading the player's existing unlock status to guard against races involving the Achievements dialog window reading from data AchievementManager might be in the process of updating. The lock has been exposed publicly and the AchievementsWindow uses it in its UpdateData method, and anywhere else that might modify data used to render that window has also been wrapped with it.
This commit is contained in:
LillyJadeKatrin
2023-06-09 17:05:52 -04:00
parent fbaeaf305b
commit ccc9d0e5ea
3 changed files with 54 additions and 29 deletions

View File

@ -4,6 +4,8 @@
#ifdef USE_RETRO_ACHIEVEMENTS
#include "DolphinQt/Achievements/AchievementsWindow.h"
#include <mutex>
#include <QDialogButtonBox>
#include <QTabWidget>
#include <QVBoxLayout>
@ -60,11 +62,14 @@ void AchievementsWindow::ConnectWidgets()
void AchievementsWindow::UpdateData()
{
m_header_widget->UpdateData();
m_header_widget->setVisible(AchievementManager::GetInstance()->IsLoggedIn());
// Settings tab handles its own updates ... indeed, that calls this
m_progress_widget->UpdateData();
m_tab_widget->setTabVisible(1, AchievementManager::GetInstance()->IsGameLoaded());
{
std::lock_guard lg{*AchievementManager::GetInstance()->GetLock()};
m_header_widget->UpdateData();
m_header_widget->setVisible(AchievementManager::GetInstance()->IsLoggedIn());
// Settings tab handles its own updates ... indeed, that calls this
m_progress_widget->UpdateData();
m_tab_widget->setTabVisible(1, AchievementManager::GetInstance()->IsGameLoaded());
}
update();
}