mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-03 19:54:13 +13:00
Added IDisposable to ShapeManager and BaseShape
This commit is contained in:
parent
72693d46d1
commit
2a115ed205
4 changed files with 32 additions and 6 deletions
|
@ -800,6 +800,11 @@ protected override Image GetOutputImage()
|
|||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (ShapeManager != null)
|
||||
{
|
||||
ShapeManager.Dispose();
|
||||
}
|
||||
|
||||
if (bmpBackgroundImage != null)
|
||||
{
|
||||
bmpBackgroundImage.Dispose();
|
||||
|
|
|
@ -24,13 +24,14 @@ You should have received a copy of the GNU General Public License
|
|||
#endregion License Information (GPL v3)
|
||||
|
||||
using ShareX.HelpersLib;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShareX.ScreenCaptureLib
|
||||
{
|
||||
public abstract class BaseShape
|
||||
public abstract class BaseShape : IDisposable
|
||||
{
|
||||
protected const int MinimumSize = 3;
|
||||
|
||||
|
@ -272,5 +273,9 @@ public virtual void OnNodePositionUpdate()
|
|||
Manager.ResizeNodes[(int)NodePosition.BottomLeft].Position = new Point(xStart, yEnd);
|
||||
Manager.ResizeNodes[(int)NodePosition.Left].Position = new Point(xStart, yMid);
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,10 +35,7 @@ public class ImageDrawingShape : BaseDrawingShape
|
|||
|
||||
public void SetImage(Image img, Point pos)
|
||||
{
|
||||
if (Image != null)
|
||||
{
|
||||
Image.Dispose();
|
||||
}
|
||||
Dispose();
|
||||
|
||||
Image = img;
|
||||
|
||||
|
@ -52,5 +49,13 @@ public override void OnDraw(Graphics g)
|
|||
g.DrawImage(Image, Rectangle);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
if (Image != null)
|
||||
{
|
||||
Image.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
namespace ShareX.ScreenCaptureLib
|
||||
{
|
||||
internal class ShapeManager
|
||||
internal class ShapeManager : IDisposable
|
||||
{
|
||||
public List<BaseShape> Shapes { get; private set; } = new List<BaseShape>();
|
||||
|
||||
|
@ -1544,6 +1544,7 @@ private void DeleteShape(BaseShape shape)
|
|||
{
|
||||
if (shape != null)
|
||||
{
|
||||
shape.Dispose();
|
||||
Shapes.Remove(shape);
|
||||
DeselectShape(shape);
|
||||
}
|
||||
|
@ -1561,6 +1562,11 @@ private void DeleteIntersectShape()
|
|||
|
||||
private void DeleteAllShapes()
|
||||
{
|
||||
foreach (BaseShape shape in Shapes)
|
||||
{
|
||||
shape.Dispose();
|
||||
}
|
||||
|
||||
Shapes.Clear();
|
||||
DeselectCurrentShape();
|
||||
}
|
||||
|
@ -1730,5 +1736,10 @@ private void OnCurrentShapeTypeChanged(ShapeType shapeType)
|
|||
CurrentShapeTypeChanged(shapeType);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
DeleteAllShapes();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue