diff --git a/src/Font.cpp b/src/Font.cpp index 4fd73591d2..3c3cdf1e4a 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -728,7 +728,6 @@ void Font::Load( const RString &sIniPath, RString sChars ) Font subfont; subfont.Load(fPath,""); MergeFont(subfont); - //FONT->UnloadFont(subfont); } } diff --git a/src/FontManager.cpp b/src/FontManager.cpp index 1500a78e29..380f00384b 100644 --- a/src/FontManager.cpp +++ b/src/FontManager.cpp @@ -22,7 +22,7 @@ FontManager::~FontManager() { const FontName &fn = i->first; Font* pFont = i->second; - if(pFont->m_iRefCount>0) { + if(pFont->m_iRefCount > 0) { LOG->Trace( "FONT LEAK: '%s', RefCount = %d.", fn.first.c_str(), pFont->m_iRefCount ); } delete pFont; @@ -53,14 +53,13 @@ Font* FontManager::LoadFont( const RString &sFontOrTextureFilePath, RString sCha { pFont=p->second; pFont->m_iRefCount++; - } - else { - pFont= new Font; - pFont->Load(sFontOrTextureFilePath, sChars); - g_mapPathToFont[NewName] = pFont; + return pFont; } - return pFont; + Font *f = new Font; + f->Load(sFontOrTextureFilePath, sChars); + g_mapPathToFont[NewName] = f; + return f; } Font *FontManager::CopyFont( Font *pFont ) @@ -79,16 +78,22 @@ void FontManager::UnloadFont( Font *fp ) if(i->second != fp) continue; - ASSERT_M(fp->m_iRefCount>0,"Attempting to unload a font with zero ref count!"); + ASSERT_M(fp->m_iRefCount > 0,"Attempting to unload a font with zero ref count!"); i->second->m_iRefCount--; + if( fp->m_iRefCount == 0 ) + { + delete i->second; // free the texture + g_mapPathToFont.erase( i ); // and remove the key in the map + } return; } FAIL_M( ssprintf("Unloaded an unknown font (%p)", fp) ); } +/* void FontManager::PruneFonts() { for( std::map::iterator i = g_mapPathToFont.begin();i != g_mapPathToFont.end();) { Font *fp=i->second; @@ -101,6 +106,7 @@ void FontManager::PruneFonts() { } } } +*/ /* * (c) 2001-2003 Chris Danford, Glenn Maynard diff --git a/src/FontManager.h b/src/FontManager.h index 9124d694f9..f3159ab006 100644 --- a/src/FontManager.h +++ b/src/FontManager.h @@ -15,7 +15,7 @@ public: Font* LoadFont( const RString &sFontOrTextureFilePath, RString sChars = "" ); Font *CopyFont( Font *pFont ); void UnloadFont( Font *fp ); - void PruneFonts(); + //void PruneFonts(); /* Warning: This reloads fonts completely, so all BitmapTexts need to be * reset, too. If this isn't done, best case they end up with old font diff --git a/src/NotesLoaderBMS.cpp b/src/NotesLoaderBMS.cpp index b689e9f663..025bea1d6d 100644 --- a/src/NotesLoaderBMS.cpp +++ b/src/NotesLoaderBMS.cpp @@ -842,7 +842,7 @@ static void ReadGlobalTags( const NameToData_t &mapNameToData, Song &out, Measur LOG->UserLog( "Song file", out.GetSongDir(), "references key \"%s\" that can't be found", nData.c_str() ); sWavID.MakeUpper(); // HACK: undo the MakeLower() - out.m_vsKeysoundFile.push_back( nData + "" ); + out.m_vsKeysoundFile.push_back( nData ); idToKeySoundIndexOut[ sWavID ] = out.m_vsKeysoundFile.size()-1; LOG->Trace( "Inserting keysound index %u '%s'", unsigned(out.m_vsKeysoundFile.size()-1), sWavID.c_str() ); } diff --git a/src/RageInputDevice.cpp b/src/RageInputDevice.cpp index 9421dc17b0..354baa5110 100644 --- a/src/RageInputDevice.cpp +++ b/src/RageInputDevice.cpp @@ -155,9 +155,6 @@ RString DeviceButtonToString( DeviceButton key ) if( key >= MIDI_FIRST && key <= MIDI_LAST ) return ssprintf( "Midi %d", key-MIDI_FIRST ); - if( key >= MOUSE_LEFT && key <= MOUSE_WHEELDOWN ) - return ssprintf( "Mouse %d", key-MOUSE_LEFT ); - map::const_iterator it = g_mapNamesToString.find( key ); if( it != g_mapNamesToString.end() ) return it->second; diff --git a/src/RageInputDevice.h b/src/RageInputDevice.h index 84230edd81..af28513bc2 100644 --- a/src/RageInputDevice.h +++ b/src/RageInputDevice.h @@ -321,7 +321,7 @@ public: /* Whether this button is pressed. This is level with a threshold and * debouncing applied. */ bool bDown; - + RageTimer ts; DeviceInput(): device(InputDevice_Invalid), button(DeviceButton_Invalid), level(0), x(0), y(0), bDown(false), ts(RageZeroTimer) { } diff --git a/src/ScreenManager.cpp b/src/ScreenManager.cpp index 15dcc3bc32..ed8549f05d 100644 --- a/src/ScreenManager.cpp +++ b/src/ScreenManager.cpp @@ -76,7 +76,7 @@ ScreenManager* SCREENMAN = NULL; // global and accessable from anywhere in our program static Preference g_bDelayedScreenLoad( "DelayedScreenLoad", false ); -static Preference g_bPruneFonts( "PruneFonts", true ); +//static Preference g_bPruneFonts( "PruneFonts", true ); // Screen registration static map *g_pmapRegistrees = NULL; @@ -592,9 +592,11 @@ void ScreenManager::PrepareScreen( const RString &sScreenName ) } // Prune any unused fonts now that we have had a chance to reference the fonts + /* if(g_bPruneFonts) { FONT->PruneFonts(); } + */ TEXTUREMAN->DiagnosticOutput(); } @@ -690,17 +692,19 @@ void ScreenManager::LoadDelayedScreen() * cleanup, so it doesn't get deleted by cleanup. */ bool bLoaded = ActivatePreparedScreenAndBackground( sScreenName ); - bool deletePrepared=g_setGroupedScreens.find(sScreenName) == g_setGroupedScreens.end(); - - /* It's time to delete all old prepared screens. Depending on DelayedScreenLoad, - * we can either delete the screens before or after we load the new screen. - * Either way, we must remove them from the prepared list before we prepare - * new screens. - * If DelayedScreenLoad is true, delete them now; this lowers memory - * requirements, but results in redundant loads as we unload common data. */ - if( deletePrepared && g_bDelayedScreenLoad ) { - DeletePreparedScreens(); - deletePrepared=false; + vector apActorsToDelete; + if( g_setGroupedScreens.find(sScreenName) == g_setGroupedScreens.end() ) + { + /* It's time to delete all old prepared screens. Depending on + * DelayedScreenLoad, we can either delete the screens before or after + * we load the new screen. Either way, we must remove them from the + * prepared list before we prepare new screens. + * If DelayedScreenLoad is true, delete them now; this lowers memory + * requirements, but results in redundant loads as we unload common data. */ + if( g_bDelayedScreenLoad ) + DeletePreparedScreens(); + else + GrabPreparedActors( apActorsToDelete ); } // If the screen wasn't already prepared, load it. @@ -717,9 +721,12 @@ void ScreenManager::LoadDelayedScreen() ASSERT( bLoaded ); } - if( deletePrepared ) + if( !apActorsToDelete.empty() ) { - DeletePreparedScreens(); + BeforeDeleteScreen(); + FOREACH( Actor*, apActorsToDelete, a ) + SAFE_DELETE( *a ); + AfterDeleteScreen(); } MESSAGEMAN->Broadcast( Message_ScreenChanged );