From f84b227d4781624e304c24aedd4a36de9e2a3bbe Mon Sep 17 00:00:00 2001 From: RKrom Date: Fri, 30 Jul 2010 16:05:44 +0000 Subject: [PATCH] Merge from branch for Exit problems git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@743 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- Greenshot/Forms/MainForm.cs | 41 +++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs index b9a0adb52..07297a399 100644 --- a/Greenshot/Forms/MainForm.cs +++ b/Greenshot/Forms/MainForm.cs @@ -537,23 +537,34 @@ namespace Greenshot { /// Exit/cleanup /// public void exit() { - // Inform all registed plugins - PluginHelper.instance.Shutdown(); - - // Make the Greenshot icon invisible - notifyIcon.Visible = false; - - conf.Store(); - HotkeyHelper.UnregisterHotkeys((int)this.Handle); - SoundHelper.Deinitialize(); - if (applicationMutex != null) { - try { - applicationMutex.ReleaseMutex(); - } catch (Exception ex) { - LOG.Error("Error releasing Mutex!", ex); + try { + // Make sure hotkeys are disabled + HotkeyHelper.UnregisterHotkeys((int)this.Handle); + + // Now the sound isn't needed anymore + SoundHelper.Deinitialize(); + + // Making sure all Windows are closed, gracefull shutdown + Application.Exit(); + + // Inform all registed plugins + PluginHelper.instance.Shutdown(); + + // Store any open configuration changes + conf.Store(); + } finally { + // Remove the application mutex + if (applicationMutex != null) { + try { + applicationMutex.ReleaseMutex(); + } catch (Exception ex) { + LOG.Error("Error releasing Mutex!", ex); + } } + + // make the icon invisible otherwise it stays even after exit!! + notifyIcon.Visible = false; } - Application.Exit(); } } }