catch glib unhandled exceptions

This commit is contained in:
Xpl0itR 2019-11-22 19:24:42 +00:00 committed by unknown
commit 3f4ac1cc5d
No known key found for this signature in database
GPG key ID: 91798184109676AD
2 changed files with 16 additions and 19 deletions

View file

@ -18,6 +18,7 @@ namespace Ryujinx
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
GLib.ExceptionManager.UnhandledException += Glib_UnhandledException;
Profile.Initialize(); Profile.Initialize();
@ -30,11 +31,7 @@ namespace Ryujinx
MainWindow.CreateErrorDialog($"Key file was not found. Please refer to `KEYS.md` for more info"); MainWindow.CreateErrorDialog($"Key file was not found. Please refer to `KEYS.md` for more info");
} }
Application gtkApplication = new Application("Ryujinx.Ryujinx", GLib.ApplicationFlags.None); MainWindow mainWindow = new MainWindow();
MainWindow mainWindow = new MainWindow(gtkApplication);
gtkApplication.Register(GLib.Cancellable.Current);
gtkApplication.AddWindow(mainWindow);
mainWindow.Show(); mainWindow.Show();
if (args.Length == 1) if (args.Length == 1)
@ -61,5 +58,17 @@ namespace Ryujinx
Logger.Shutdown(); Logger.Shutdown();
} }
} }
private static void Glib_UnhandledException(GLib.UnhandledExceptionArgs e)
{
Exception exception = e.ExceptionObject as Exception;
Logger.PrintError(LogClass.Application, $"Unhandled exception caught: {exception}");
if (e.IsTerminating)
{
Logger.Shutdown();
}
}
} }
} }

View file

@ -45,8 +45,6 @@ namespace Ryujinx.UI
private static GlScreen _screen; private static GlScreen _screen;
private static Application _gtkApplication;
private static ListStore _tableStore; private static ListStore _tableStore;
private static bool _updatingGameTable; private static bool _updatingGameTable;
@ -99,9 +97,9 @@ namespace Ryujinx.UI
#pragma warning restore CS0649 #pragma warning restore CS0649
#pragma warning restore IDE0044 #pragma warning restore IDE0044
public MainWindow(Application gtkApplication) : this(new Builder("Ryujinx.Ui.MainWindow.glade"), gtkApplication) { } public MainWindow() : this(new Builder("Ryujinx.Ui.MainWindow.glade")) { }
private MainWindow(Builder builder, Application gtkApplication) : base(builder.GetObject("_mainWin").Handle) private MainWindow(Builder builder) : base(builder.GetObject("_mainWin").Handle)
{ {
builder.Autoconnect(this); builder.Autoconnect(this);
@ -115,8 +113,6 @@ namespace Ryujinx.UI
_device = new HLE.Switch(_renderer, _audioOut); _device = new HLE.Switch(_renderer, _audioOut);
_gtkApplication = gtkApplication;
_treeView = _gameTable; _treeView = _gameTable;
Configuration.Load(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json")); Configuration.Load(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json"));
@ -608,10 +604,6 @@ namespace Ryujinx.UI
private void Settings_Pressed(object sender, EventArgs args) private void Settings_Pressed(object sender, EventArgs args)
{ {
SwitchSettings settingsWin = new SwitchSettings(_device); SwitchSettings settingsWin = new SwitchSettings(_device);
_gtkApplication.Register(GLib.Cancellable.Current);
_gtkApplication.AddWindow(settingsWin);
settingsWin.Show(); settingsWin.Show();
} }
@ -632,10 +624,6 @@ namespace Ryujinx.UI
private void About_Pressed(object sender, EventArgs args) private void About_Pressed(object sender, EventArgs args)
{ {
AboutWindow aboutWin = new AboutWindow(); AboutWindow aboutWin = new AboutWindow();
_gtkApplication.Register(GLib.Cancellable.Current);
_gtkApplication.AddWindow(aboutWin);
aboutWin.Show(); aboutWin.Show();
} }