From b0a079c7771bd3274fa6cd106eea57e18b4009a2 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 3 Jul 2005 04:24:57 +0000 Subject: [PATCH] "Send this before making the new screen, since it might set things that will be re-set in the new screen's ctor." Don't do that--don't assume that the old LoseFocus will be called before the ctor or Init. If you're doing something that interacts with state changed by focus, do it in the first update, when you're guaranteed to have focus. Make no guarantees about who has focus when a new screen is constructed; only that LoseFocus will be sent before GainFocus, and GainFocus before the first update. --- stepmania/src/ScreenManager.cpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/stepmania/src/ScreenManager.cpp b/stepmania/src/ScreenManager.cpp index df6f5a9087..134d8a0f54 100644 --- a/stepmania/src/ScreenManager.cpp +++ b/stepmania/src/ScreenManager.cpp @@ -339,6 +339,9 @@ void ScreenManager::ClearScreenStack() /* Add a screen to m_ScreenStack. This is the only function that adds to m_ScreenStack. */ void ScreenManager::SetFromNewScreen( Screen *pNewScreen ) { + if( m_ScreenStack.size() ) + m_ScreenStack.back()->HandleScreenMessage( SM_LoseFocus ); + m_ScreenStack.push_back( pNewScreen ); RefreshCreditsMessages(); @@ -440,11 +443,6 @@ void ScreenManager::AddNewScreenToTop( const CString &sScreenName ) { m_bZeroNextUpdate = true; - /* Send this before making the new screen, since it might set things that will be re-set - * in the new screen's ctor. */ - if( m_ScreenStack.size() ) - m_ScreenStack.back()->HandleScreenMessage( SM_LoseFocus ); - Screen* pNewScreen = MakeNewScreen(sScreenName); SetFromNewScreen( pNewScreen ); } @@ -455,9 +453,6 @@ void ScreenManager::AddNewScreenToTop( const CString &sScreenName ) void ScreenManager::Prompt( ScreenMessage smSendOnPop, const CString &sText, PromptType type, PromptAnswer defaultAnswer, void(*OnYes)(void*), void(*OnNo)(void*), void* pCallbackData ) { - if( m_ScreenStack.size() ) - m_ScreenStack.back()->HandleScreenMessage( SM_LoseFocus ); - // add the new state onto the back of the array ScreenPrompt *pNewScreen = new ScreenPrompt( "ScreenPrompt" ); pNewScreen->Init(); @@ -477,9 +472,6 @@ void ScreenManager::TextEntry( bool bPassword ) { - if( m_ScreenStack.size() ) - m_ScreenStack.back()->HandleScreenMessage( SM_LoseFocus ); - // add the new state onto the back of the array Screen *pNewScreen = new ScreenTextEntry( "ScreenTextEntry", @@ -498,9 +490,6 @@ void ScreenManager::TextEntry( void ScreenManager::MiniMenu( Menu* pDef, ScreenMessage SM_SendOnOK, ScreenMessage SM_SendOnCancel ) { - if( m_ScreenStack.size() ) - m_ScreenStack.back()->HandleScreenMessage( SM_LoseFocus ); - // add the new state onto the back of the array ScreenMiniMenu *pNewScreen = new ScreenMiniMenu( pDef->sClassName ); pNewScreen->Init( pDef, SM_SendOnOK, SM_SendOnCancel );