mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-06 23:21:16 +12:00
If shape deleted when processing then queue dispose to be executed after processing is finished
This commit is contained in:
parent
baf77a4069
commit
7b4204df10
|
@ -35,7 +35,7 @@ public abstract class BaseEffectShape : BaseShape
|
||||||
|
|
||||||
public abstract string OverlayText { get; }
|
public abstract string OverlayText { get; }
|
||||||
|
|
||||||
private bool drawCache, isEffectCaching, cachePending;
|
private bool drawCache, isEffectCaching, isCachePending, isDisposePending;
|
||||||
private Image cachedEffect;
|
private Image cachedEffect;
|
||||||
|
|
||||||
public abstract void ApplyEffect(Bitmap bmp);
|
public abstract void ApplyEffect(Bitmap bmp);
|
||||||
|
@ -44,7 +44,7 @@ public override void OnUpdate()
|
||||||
{
|
{
|
||||||
base.OnUpdate();
|
base.OnUpdate();
|
||||||
|
|
||||||
if (cachePending)
|
if (isCachePending)
|
||||||
{
|
{
|
||||||
CacheEffect();
|
CacheEffect();
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ private void CacheEffect()
|
||||||
{
|
{
|
||||||
if (!isEffectCaching)
|
if (!isEffectCaching)
|
||||||
{
|
{
|
||||||
cachePending = false;
|
isCachePending = false;
|
||||||
drawCache = true;
|
drawCache = true;
|
||||||
|
|
||||||
ClearCache();
|
ClearCache();
|
||||||
|
@ -156,19 +156,24 @@ private void CacheEffect()
|
||||||
ApplyEffect((Bitmap)cachedEffect);
|
ApplyEffect((Bitmap)cachedEffect);
|
||||||
|
|
||||||
isEffectCaching = false;
|
isEffectCaching = false;
|
||||||
|
|
||||||
|
if (isDisposePending)
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cachePending = true;
|
isCachePending = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StopDrawCache()
|
private void StopDrawCache()
|
||||||
{
|
{
|
||||||
drawCache = false;
|
drawCache = false;
|
||||||
cachePending = false;
|
isCachePending = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClearCache()
|
private void ClearCache()
|
||||||
|
@ -181,8 +186,15 @@ private void ClearCache()
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
|
{
|
||||||
|
if (isEffectCaching)
|
||||||
|
{
|
||||||
|
isDisposePending = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
ClearCache();
|
ClearCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue