Achievements: Populate saved credentials in ProcessStartup()

Avoids has_saved_credentials not being ready when game list is
refreshing in parallel with core thread startup.
This commit is contained in:
Stenzek
2026-06-07 17:05:11 +10:00
parent 8bf9562c3a
commit 944beca2ce
3 changed files with 12 additions and 1 deletions
+4 -1
View File
@@ -591,7 +591,7 @@ const std::string& Achievements::GetRichPresenceString()
return s_state.rich_presence_string;
}
void Achievements::Initialize()
void Achievements::ProcessStartup()
{
// Called on startup, no need to grab lock just to populate has saved credentials.
{
@@ -601,7 +601,10 @@ void Achievements::Initialize()
s_state.has_saved_credentials = (si->LookupValue("Cheevos", "Username", &username) && !username.empty() &&
si->LookupValue("Cheevos", "Token", &token) && !token.empty());
}
}
void Achievements::Initialize()
{
// No need to do anything else if we're not enabled.
if (!g_settings.achievements_enabled)
return;
+3
View File
@@ -74,6 +74,9 @@ const HashDatabaseEntry* LookupGameHash(const GameHash& hash);
/// Converts a game hash to a string for display. If the hash is nullopt, returns "[NO HASH]".
TinyString GameHashToString(const std::optional<GameHash>& hash);
/// Initializes global state.
void ProcessStartup();
/// Initializes the RetroAchievments client.
void Initialize();
+5
View File
@@ -693,6 +693,11 @@ bool Core::ProcessStartup(Error* error)
// Initialize rapidyaml before anything can use it.
SetRymlCallbacks();
// Achievements needs to know whether credentials are saved, and whether it should load
// the database/provide game icons. The refresh can happen in parallel with core init,
// so we have to initialize it here.
Achievements::ProcessStartup();
#ifdef __linux__
// Running DuckStation out of /usr is not supported and makes no sense.
if (std::memcmp(EmuFolders::AppRoot.data(), "/usr/", 5) == 0)