If shape deleted when processing then queue dispose to be executed after processing is finished

This commit is contained in:
Jaex 2017-11-18 12:33:51 +03:00
parent baf77a4069
commit 7b4204df10

View file

@ -35,7 +35,7 @@ public abstract class BaseEffectShape : BaseShape
public abstract string OverlayText { get; }
private bool drawCache, isEffectCaching, cachePending;
private bool drawCache, isEffectCaching, isCachePending, isDisposePending;
private Image cachedEffect;
public abstract void ApplyEffect(Bitmap bmp);
@ -44,7 +44,7 @@ public override void OnUpdate()
{
base.OnUpdate();
if (cachePending)
if (isCachePending)
{
CacheEffect();
}
@ -140,7 +140,7 @@ private void CacheEffect()
{
if (!isEffectCaching)
{
cachePending = false;
isCachePending = false;
drawCache = true;
ClearCache();
@ -156,19 +156,24 @@ private void CacheEffect()
ApplyEffect((Bitmap)cachedEffect);
isEffectCaching = false;
if (isDisposePending)
{
Dispose();
}
});
}
}
else
{
cachePending = true;
isCachePending = true;
}
}
private void StopDrawCache()
{
drawCache = false;
cachePending = false;
isCachePending = false;
}
private void ClearCache()
@ -182,7 +187,14 @@ private void ClearCache()
public override void Dispose()
{
ClearCache();
if (isEffectCaching)
{
isDisposePending = true;
}
else
{
ClearCache();
}
}
}
}