From b589d756d6f29a1c260fb68f1bfd6316d0f7c834 Mon Sep 17 00:00:00 2001 From: RKrom Date: Fri, 10 Aug 2012 14:32:11 +0000 Subject: [PATCH] Fixed memory leak when closing the destination picker by using the keyboard (e.g. ESC or Alt+F4). This might solve bug #3556050, if nothing else is reported. git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1983 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- Greenshot/Destinations/PickerDestination.cs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Greenshot/Destinations/PickerDestination.cs b/Greenshot/Destinations/PickerDestination.cs index f050497eb..bda6cb7df 100644 --- a/Greenshot/Destinations/PickerDestination.cs +++ b/Greenshot/Destinations/PickerDestination.cs @@ -63,15 +63,18 @@ namespace Greenshot.Destinations { ContextMenuStrip menu = new ContextMenuStrip(); menu.Closing += delegate(object source, ToolStripDropDownClosingEventArgs eventArgs) { LOG.DebugFormat("Close reason: {0}", eventArgs.CloseReason); - switch (eventArgs.CloseReason) { - case ToolStripDropDownCloseReason.ItemClicked: - case ToolStripDropDownCloseReason.CloseCalled: - case ToolStripDropDownCloseReason.Keyboard: - break; - default: - eventArgs.Cancel = true; - break; - } + switch (eventArgs.CloseReason) { + case ToolStripDropDownCloseReason.ItemClicked: + case ToolStripDropDownCloseReason.CloseCalled: + break; + case ToolStripDropDownCloseReason.Keyboard: + // Dispose as the close is clicked + surface.Dispose(); + break; + default: + eventArgs.Cancel = true; + break; + } }; foreach (IDestination destination in destinations) { // Fix foreach loop variable for the delegate