Fix a crash when closing the main UI (#904)

* Fix a crash when closing the main Ui

Also make sure to dispose the OpenAL context to not leak memory when
unloading the emulation context.

* Improve keys and 'game already running' dialogs

* Make sure to dispose the page table and ThreadContext

Less memory leaks!

* Fix tests

* Address gdk's comments
This commit is contained in:
Thog 2020-02-06 12:38:24 +01:00 committed by GitHub
parent f2b9a9c2b0
commit a906f2071c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 40 additions and 10 deletions

View file

@ -32,6 +32,8 @@ namespace Ryujinx.Ui
private static GlScreen _screen;
private static AutoResetEvent _screenExitStatus = new AutoResetEvent(false);
private static ListStore _tableStore;
private static bool _updatingGameTable;
@ -278,7 +280,7 @@ namespace Ryujinx.Ui
{
if (_gameLoaded)
{
GtkDialog.CreateErrorDialog("A game has already been loaded. Please close the emulator and try again");
GtkDialog.CreateDialog("Ryujinx", "A game has already been loaded", "Please close it first and try again.");
}
else
{
@ -347,6 +349,8 @@ namespace Ryujinx.Ui
_emulationContext = device;
_screenExitStatus.Reset();
#if MACOS_BUILD
CreateGameWindow(device);
#else
@ -393,6 +397,8 @@ namespace Ryujinx.Ui
DiscordIntegrationModule.SwitchToMainMenu();
_screenExitStatus.Set();
Application.Invoke(delegate
{
_stopEmulation.Sensitive = false;
@ -432,12 +438,17 @@ namespace Ryujinx.Ui
if (device != null)
{
UpdateGameMetadata(device.System.TitleIdText);
if (_screen != null)
{
_screen.Exit();
_screenExitStatus.WaitOne();
}
}
Dispose();
Profile.FinishProfiling();
device?.Dispose();
DiscordIntegrationModule.Exit();
Logger.Shutdown();
Application.Quit();
@ -584,13 +595,11 @@ namespace Ryujinx.Ui
private void Exit_Pressed(object sender, EventArgs args)
{
_screen?.Exit();
End(_emulationContext);
}
private void Window_Close(object sender, DeleteEventArgs args)
{
_screen?.Exit();
End(_emulationContext);
}