Skip to content

Commit

Permalink
ensure game is fully unloaded before calling rc_client_logout (#1124)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras authored Nov 9, 2024
1 parent 40b527b commit 0726e5e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/data/context/UserContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,15 @@ void UserContext::Logout()
if (!IsLoggedIn())
return;

_RA_ActivateGame(0U);

auto* pClient = ra::services::ServiceLocator::Get<ra::services::AchievementRuntime>().GetClient();
rc_client_logout(pClient);

m_sUsername.clear();
m_sDisplayName.clear();
m_sApiToken.clear();

auto& pOverlayManager = ra::services::ServiceLocator::GetMutable<ra::ui::viewmodels::OverlayManager>();
pOverlayManager.ClearPopups();
pOverlayManager.HideOverlay();

ra::services::ServiceLocator::Get<ra::services::IConfiguration>().Save();

ra::services::ServiceLocator::GetMutable<ra::ui::viewmodels::WindowManager>().Emulator.UpdateWindowTitle();
Expand Down
3 changes: 3 additions & 0 deletions src/services/AchievementRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,9 @@ void AchievementRuntime::UpdateActiveLeaderboards() noexcept

static rc_client_leaderboard_info_t* GetLeaderboardInfo(rc_client_t* pClient, ra::LeaderboardID nId) noexcept
{
if (!pClient || !pClient->game)
return nullptr;

rc_client_subset_info_t* subset = pClient->game->subsets;
for (; subset; subset = subset->next)
{
Expand Down
10 changes: 10 additions & 0 deletions src/ui/viewmodels/OverlayManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,16 @@ void OverlayManager::UpdateProgressTracker(ra::ui::ImageType imageType, const st
RequestRender();
}

void OverlayManager::HideOverlayImmediately()
{
// expect the emulator to be paused while the overlay is open and tell it to unpause
// as we're about to discard the overlay.
if (m_vmOverlay.CurrentState() != OverlayViewModel::State::Hidden)
ra::services::ServiceLocator::Get<ra::data::context::EmulatorContext>().Unpause();

m_vmOverlay.DeactivateImmediately();
}

int OverlayManager::QueueMessage(std::unique_ptr<PopupMessageViewModel>& pMessage)
{
if (pMessage->GetImage().Type() != ra::ui::ImageType::None)
Expand Down
5 changes: 1 addition & 4 deletions src/ui/viewmodels/OverlayManager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ public:
/// <summary>
/// Hides the overlay without animating it.
/// </summary>
void HideOverlayImmediately()
{
m_vmOverlay.DeactivateImmediately();
}
void HideOverlayImmediately();

/// <summary>
/// Determines if the overlay is completely covering the emulator screen.
Expand Down

0 comments on commit 0726e5e

Please sign in to comment.