diff --git a/stepmania/src/RageTextureManager.cpp b/stepmania/src/RageTextureManager.cpp index ffc13cf0e5..8fdfbe55e4 100644 --- a/stepmania/src/RageTextureManager.cpp +++ b/stepmania/src/RageTextureManager.cpp @@ -229,10 +229,20 @@ void RageTextureManager::ReloadAll() * associated with a different texture). Ack. */ void RageTextureManager::InvalidateTextures() { + std::map::iterator i; + for( i = m_mapPathToTexture.begin(); i != m_mapPathToTexture.end(); ++i) + { + RageTexture* pTexture = i->second; + pTexture->Invalidate(); + } + /* We're going to have to reload all loaded textures. Let's get rid * of all unreferenced textures, so we don't reload a ton of cached - * data that we're not necessarily going to use. */ - std::map::iterator i; + * data that we're not necessarily going to use. + * + * This must be done *after* we Invalidate above, to let the texture + * know its OpenGL texture number is invalid. If we don't do that, + * it'll try to free it. */ for( i = m_mapPathToTexture.begin(); i != m_mapPathToTexture.end(); ) { @@ -247,12 +257,6 @@ void RageTextureManager::InvalidateTextures() m_mapPathToTexture.erase(j); // and remove the key in the map } } - - for( i = m_mapPathToTexture.begin(); i != m_mapPathToTexture.end(); ++i) - { - RageTexture* pTexture = i->second; - pTexture->Invalidate(); - } } bool RageTextureManager::SetPrefs( int iTextureColorDepth, int iSecondsBeforeUnload, int iMaxTextureResolution )