From a06e5066e9a5ad70515992eb2c3a3fc3db1faabe Mon Sep 17 00:00:00 2001 From: Flamefire Date: Thu, 25 Sep 2014 16:22:49 +0200 Subject: [PATCH] Fix bug with removing a removed texture reference --- Vocaluxe/Lib/Draw/CDrawBase.cs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/Vocaluxe/Lib/Draw/CDrawBase.cs b/Vocaluxe/Lib/Draw/CDrawBase.cs index 78bad768..ca05c62c 100644 --- a/Vocaluxe/Lib/Draw/CDrawBase.cs +++ b/Vocaluxe/Lib/Draw/CDrawBase.cs @@ -882,24 +882,27 @@ namespace Vocaluxe.Lib.Draw { if (textureRef == null) return; - if (_MainThreadID != Thread.CurrentThread.ManagedThreadId) + if (textureRef.ID > 0) { - lock (_TextureQueue) + if (_MainThreadID != Thread.CurrentThread.ManagedThreadId) { - _TextureQueue.Enqueue(new STextureQueue(textureRef, EQueueAction.Delete, null)); + lock (_TextureQueue) + { + _TextureQueue.Enqueue(new STextureQueue(textureRef, EQueueAction.Delete, null)); + } + textureRef = null; + return; } - textureRef = null; - return; - } - lock (_Textures) - { - TTextureType t; - if (_Textures.TryGetValue(textureRef.ID, out t)) + lock (_Textures) { - _DisposeTexture(t); - _Textures.Remove(textureRef.ID); + TTextureType t; + if (_Textures.TryGetValue(textureRef.ID, out t)) + { + _DisposeTexture(t); + _Textures.Remove(textureRef.ID); + } + textureRef.SetRemoved(); } - textureRef.SetRemoved(); } textureRef = null; }