diff Main.cs @ 26:55d4f16c982b

Fixes #250: QtSharp app doesn't always quit properly * Override Close event to dispose of file dialogs (open and save) * Remove unnecessary event handler hooked to close * Change app initialisation to match pattern used by Synapse * Create file dialogs without specifying "this" as parent - seems to be main fix, for some reason.
author IBBoard <dev@ibboard.co.uk>
date Sat, 31 Jul 2010 16:03:14 +0000
parents d1259ec9d089
children
line wrap: on
line diff
--- a/Main.cs	Sat Mar 06 15:23:40 2010 +0000
+++ b/Main.cs	Sat Jul 31 16:03:14 2010 +0000
@@ -16,7 +16,6 @@
 	class MainClass
 	{
 		private static ILog logger = LogManager.GetLogger(typeof(MainClass));
-		static MainWindow win;
 		static QApplication app;
 		
 		public static void Main(string[] args)
@@ -24,17 +23,19 @@
 			try
 			{
 				logger.InfoFormat("Starting application with args: {0}", args.ToString());
-				app = new QApplication(args);
-				
-				SetUpWarFoundryEnvironment();
+				app = new QApplication(args, true);
+				app.QuitOnLastWindowClosed = true;
+				logger.Debug("Starting exec");
+				QApplication.Invoke(delegate
+				{
+					SetUpWarFoundryEnvironment();
 				
-				win = new MainWindow();
-				win.Show();
-				logger.Debug("Starting exec");
-				int result = QApplication.Exec ();
-				logger.Info("Closing application");
-				Environment.Exit(result);
-				logger.Info("Exited");
+					MainWindow win = new MainWindow();
+					win.Show();
+					QApplication.SetActiveWindow(win);
+				});
+				int result = QApplication.Exec();
+				logger.InfoFormat("Closing application - exit code {0}", result);
 			}
 			catch(Exception ex)
 			{