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
This commit is contained in:
RKrom 2012-08-10 14:32:11 +00:00
commit b589d756d6

View file

@ -63,15 +63,18 @@ namespace Greenshot.Destinations {
ContextMenuStrip menu = new ContextMenuStrip(); ContextMenuStrip menu = new ContextMenuStrip();
menu.Closing += delegate(object source, ToolStripDropDownClosingEventArgs eventArgs) { menu.Closing += delegate(object source, ToolStripDropDownClosingEventArgs eventArgs) {
LOG.DebugFormat("Close reason: {0}", eventArgs.CloseReason); LOG.DebugFormat("Close reason: {0}", eventArgs.CloseReason);
switch (eventArgs.CloseReason) { switch (eventArgs.CloseReason) {
case ToolStripDropDownCloseReason.ItemClicked: case ToolStripDropDownCloseReason.ItemClicked:
case ToolStripDropDownCloseReason.CloseCalled: case ToolStripDropDownCloseReason.CloseCalled:
case ToolStripDropDownCloseReason.Keyboard: break;
break; case ToolStripDropDownCloseReason.Keyboard:
default: // Dispose as the close is clicked
eventArgs.Cancel = true; surface.Dispose();
break; break;
} default:
eventArgs.Cancel = true;
break;
}
}; };
foreach (IDestination destination in destinations) { foreach (IDestination destination in destinations) {
// Fix foreach loop variable for the delegate // Fix foreach loop variable for the delegate