From 742a3c1c264e6727d1bff74a6a7938dbacce1c52 Mon Sep 17 00:00:00 2001 From: Martin Natano Date: Sun, 12 Jun 2022 23:02:25 +0200 Subject: [PATCH] Fix ScreenSelectProfile::Finish() Unload all profiles first, so we don't end up in a situation where two players might have the same profile assigned during iteration. --- src/ScreenSelectProfile.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ScreenSelectProfile.cpp b/src/ScreenSelectProfile.cpp index e5d2171658..502038f0c5 100644 --- a/src/ScreenSelectProfile.cpp +++ b/src/ScreenSelectProfile.cpp @@ -181,13 +181,18 @@ bool ScreenSelectProfile::Finish(){ if( iUnselectedProfiles && iUsedLocalProfiles < PROFILEMAN->GetNumLocalProfiles() ) return false; - // all ok - load profiles and go to next screen + // unload all profiles, so we don't end up in a situation where two + // players might have the same profile assigned FOREACH_PlayerNumber( p ) { MEMCARDMAN->UnlockCard( p ); MEMCARDMAN->UnmountCard( p ); PROFILEMAN->UnloadProfile( p ); + } + // all ok - load profiles and go to next screen + FOREACH_PlayerNumber( p ) + { if( m_iSelectedProfiles[p] > 0 ) { PROFILEMAN->m_sDefaultLocalProfileID[p].Set( PROFILEMAN->GetLocalProfileIDFromIndex( m_iSelectedProfiles[p] - 1 ) );