mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 10:47:02 -07:00
Fixing a cleanup / reentrant problem by closing the current CaptureForm if a new is opened and disposing the capture before exiting MakeCapture().
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1614 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
299a4fba72
commit
d4e9b70161
2 changed files with 20 additions and 0 deletions
|
@ -47,6 +47,7 @@ namespace Greenshot.Forms {
|
|||
private static Brush GreenOverlayBrush = new SolidBrush(Color.FromArgb(50, Color.MediumSeaGreen));
|
||||
private static Brush RedOverlayBrush = new SolidBrush(Color.FromArgb(50, Color.DarkRed));
|
||||
private static Pen OverlayPen = new Pen(Color.FromArgb(50, Color.Black));
|
||||
private static CaptureForm currentForm = null;
|
||||
|
||||
private int mX;
|
||||
private int mY;
|
||||
|
@ -81,6 +82,20 @@ namespace Greenshot.Forms {
|
|||
}
|
||||
|
||||
public CaptureForm(ICapture capture, List<WindowDetails> windows) {
|
||||
if (currentForm != null) {
|
||||
LOG.Debug("Found currentForm, Closing already opened CaptureForm");
|
||||
currentForm.Close();
|
||||
currentForm = null;
|
||||
Application.DoEvents();
|
||||
}
|
||||
currentForm = this;
|
||||
|
||||
// clean up
|
||||
this.FormClosed += delegate {
|
||||
currentForm = null;
|
||||
LOG.Debug("Remove CaptureForm from currentForm");
|
||||
};
|
||||
|
||||
this.capture = capture;
|
||||
this.windows = windows;
|
||||
captureMode = capture.CaptureDetails.CaptureMode;
|
||||
|
|
|
@ -297,6 +297,11 @@ namespace Greenshot.Helpers {
|
|||
LOG.Warn("Unknown capture mode: " + captureMode);
|
||||
break;
|
||||
}
|
||||
|
||||
if (capture != null) {
|
||||
LOG.Debug("Disposing capture");
|
||||
capture.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue