AchievementManager: Return by reference from GetLock()
This makes the API a little nicer to use, since you don't need to do a mandatory dereference when passing the lock into any kind of scope guard.
This commit is contained in:
parent
3c7fa0738c
commit
d90537cc18
|
@ -731,9 +731,9 @@ void AchievementManager::AchievementEventHandler(const rc_runtime_event_t* runti
|
|||
m_update_callback();
|
||||
}
|
||||
|
||||
std::recursive_mutex* AchievementManager::GetLock()
|
||||
std::recursive_mutex& AchievementManager::GetLock()
|
||||
{
|
||||
return &m_lock;
|
||||
return m_lock;
|
||||
}
|
||||
|
||||
bool AchievementManager::IsHardcoreModeActive() const
|
||||
|
@ -934,7 +934,7 @@ void* AchievementManager::FilereaderOpenByVolume(const char* path_utf8)
|
|||
auto state = std::make_unique<FilereaderState>();
|
||||
{
|
||||
auto& instance = GetInstance();
|
||||
std::lock_guard lg{*instance.GetLock()};
|
||||
std::lock_guard lg{instance.GetLock()};
|
||||
state->volume = std::move(instance.GetLoadingVolume());
|
||||
}
|
||||
if (!state->volume)
|
||||
|
|
|
@ -129,7 +129,7 @@ public:
|
|||
u32 MemoryPeeker(u32 address, u32 num_bytes, void* ud);
|
||||
void AchievementEventHandler(const rc_runtime_event_t* runtime_event);
|
||||
|
||||
std::recursive_mutex* GetLock();
|
||||
std::recursive_mutex& GetLock();
|
||||
bool IsHardcoreModeActive() const;
|
||||
std::string GetPlayerDisplayName() const;
|
||||
u32 GetPlayerScore() const;
|
||||
|
|
|
@ -62,7 +62,7 @@ AchievementHeaderWidget::AchievementHeaderWidget(QWidget* parent) : QWidget(pare
|
|||
m_total->setAlignment(Qt::AlignTop);
|
||||
setLayout(m_total);
|
||||
|
||||
std::lock_guard lg{*AchievementManager::GetInstance().GetLock()};
|
||||
std::lock_guard lg{AchievementManager::GetInstance().GetLock()};
|
||||
UpdateData();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ AchievementLeaderboardWidget::AchievementLeaderboardWidget(QWidget* parent) : QW
|
|||
m_common_layout = new QGridLayout();
|
||||
|
||||
{
|
||||
std::lock_guard lg{*AchievementManager::GetInstance().GetLock()};
|
||||
std::lock_guard lg{AchievementManager::GetInstance().GetLock()};
|
||||
UpdateData();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ AchievementProgressWidget::AchievementProgressWidget(QWidget* parent) : QWidget(
|
|||
m_common_layout = new QVBoxLayout();
|
||||
|
||||
{
|
||||
std::lock_guard lg{*AchievementManager::GetInstance().GetLock()};
|
||||
std::lock_guard lg{AchievementManager::GetInstance().GetLock()};
|
||||
UpdateData();
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ void AchievementsWindow::UpdateData()
|
|||
{
|
||||
{
|
||||
auto& instance = AchievementManager::GetInstance();
|
||||
std::lock_guard lg{*instance.GetLock()};
|
||||
std::lock_guard lg{instance.GetLock()};
|
||||
const bool is_game_loaded = instance.IsGameLoaded();
|
||||
|
||||
m_header_widget->UpdateData();
|
||||
|
|
|
@ -330,7 +330,7 @@ void OnScreenUI::DrawDebugText()
|
|||
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||
void OnScreenUI::DrawChallenges()
|
||||
{
|
||||
std::lock_guard lg{*AchievementManager::GetInstance().GetLock()};
|
||||
std::lock_guard lg{AchievementManager::GetInstance().GetLock()};
|
||||
const auto& challenge_icons = AchievementManager::GetInstance().GetChallengeIcons();
|
||||
if (challenge_icons.empty())
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue