I noticed the bug because I couldn't switch from fullscreen to windowed mode anymore with the latest SVN.
I found out, that in the Dispose function of GUITextureManager the CachedTexture objects from the "_cache"-list are disposed without previously removing the event handler from the objects. During disposing of the CachedTexture objects the Disposed event gets fired and is catched by the GUITextureManager itself. At the event handler the object gets removed from the "_cache"-list.
Because currently we are iterating the "_cache"-list, this results in an Exception thrown by the "foreach" loop because the "_cache"-list has changed.
A little bit hard to explain in words but if you look at the code it's quit easy to understand why the exception is thrown and the toggling from fullscreen to windowed mode wasn't possible anymore.
So the only thing that has to be done to fix this is add the removing of the event handler before disposing the CachedTexture object. Here it is:
I attached a patch file for easy applying.
Keep up the good work everyone!
Maik
I found out, that in the Dispose function of GUITextureManager the CachedTexture objects from the "_cache"-list are disposed without previously removing the event handler from the objects. During disposing of the CachedTexture objects the Disposed event gets fired and is catched by the GUITextureManager itself. At the event handler the object gets removed from the "_cache"-list.
Because currently we are iterating the "_cache"-list, this results in an Exception thrown by the "foreach" loop because the "_cache"-list has changed.
A little bit hard to explain in words but if you look at the code it's quit easy to understand why the exception is thrown and the toggling from fullscreen to windowed mode wasn't possible anymore.
So the only thing that has to be done to fix this is add the removing of the event handler before disposing the CachedTexture object. Here it is:
Code:
private static void dispose(bool disposing)
{
Log.Debug("TextureManager: Dispose()");
_packer.Dispose();
if (disposing)
{
foreach (CachedTexture cached in _cache)
{
[COLOR="Red"] cached.Disposed -= new EventHandler(cachedTexture_Disposed);[/COLOR]
cached.Dispose();
}
_cache.Clear();
}
_cacheDownload.Clear();
...
I attached a patch file for easy applying.
Keep up the good work everyone!
Maik