Mercurial > repos > IBBoard.WarFoundry.GUI.QtSharp
comparison Main.cs @ 22:ff011053ec3f
Re #242: Create Qt# UI for WarFoundry
* Try resolving SIGSEGV crashes
* Add more logging
* Add dialog on major crash so that user gets a message somewhere other than the log file
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 21 Feb 2010 14:55:23 +0000 |
parents | f1be1b509134 |
children | d1259ec9d089 |
comparison
equal
deleted
inserted
replaced
21:d6e95d51b9a4 | 22:ff011053ec3f |
---|---|
14 namespace IBBoard.WarFoundry.GUI.QtSharp | 14 namespace IBBoard.WarFoundry.GUI.QtSharp |
15 { | 15 { |
16 class MainClass | 16 class MainClass |
17 { | 17 { |
18 private static ILog logger = LogManager.GetLogger(typeof(MainClass)); | 18 private static ILog logger = LogManager.GetLogger(typeof(MainClass)); |
19 static MainWindow win; | |
19 | 20 |
20 public static void Main (string[] args) | 21 public static void Main(string[] args) |
21 { | 22 { |
22 try | 23 try |
23 { | 24 { |
24 new QApplication (args); | 25 logger.InfoFormat("Starting application with args: {0}", args.ToString()); |
26 new QApplication(args); | |
25 | 27 |
26 SetUpWarFoundryEnvironment (); | 28 SetUpWarFoundryEnvironment(); |
27 | 29 |
28 MainWindow win = new MainWindow (); | 30 win = new MainWindow(); |
29 win.Show (); | 31 win.Show(); |
30 | 32 logger.Debug("Starting exec"); |
31 QApplication.Exec (); | 33 QApplication.Exec(); |
34 logger.Info("Closing application"); | |
32 } | 35 } |
33 catch(Exception ex) | 36 catch(Exception ex) |
34 { | 37 { |
35 logger.Fatal(ex); | 38 logger.Fatal(ex); |
36 QMessageBox.Critical(null, "Unhandled exception", ex.Message+"\n\nPlease see log for more details"); | 39 QMessageBox.Critical(null, "Unhandled exception", ex.Message+"\n\nPlease see log for more details"); |
37 } | 40 } |
38 | 41 |
39 } | 42 } |
40 | 43 |
41 private static void SetUpWarFoundryEnvironment () | 44 private static void SetUpWarFoundryEnvironment() |
42 { | 45 { |
46 logger.Debug("Creating application environment"); | |
43 //FIXME: Temporary hack to add paths and factories before we get preferences and plugins | 47 //FIXME: Temporary hack to add paths and factories before we get preferences and plugins |
44 WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Path.Combine(Constants.ExecutablePath, "data"))); | 48 WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Path.Combine(Constants.ExecutablePath, "data"))); |
45 WarFoundryLoader.GetDefault().RegisterFactory(WarFoundryXmlFactory.GetFactory()); | 49 WarFoundryLoader.GetDefault().RegisterFactory(WarFoundryXmlFactory.GetFactory()); |
46 WarFoundryLoader.GetDefault().FileLoadingFinished += FileLoadingFinished; | 50 WarFoundryLoader.GetDefault().FileLoadingFinished += FileLoadingFinished; |
47 WarFoundrySaver.SetFileSaver(new WarFoundryXmlSaver()); | 51 WarFoundrySaver.SetFileSaver(new WarFoundryXmlSaver()); |
48 } | 52 } |
49 | 53 |
50 private static void FileLoadingFinished (List<FileLoadFailure> failures) | 54 private static void FileLoadingFinished(List<FileLoadFailure> failures) |
51 { | 55 { |
52 foreach(FileLoadFailure failure in failures) | 56 foreach(FileLoadFailure failure in failures) |
53 { | 57 { |
54 logger.Warn("Failed to load " + failure.FailedFile.FullName + ": " + failure.Message); | 58 logger.Warn("Failed to load " + failure.FailedFile.FullName + ": " + failure.Message); |
55 } | 59 } |