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.
This commit is contained in:
Thog 2020-01-24 18:28:14 +01:00
parent 532ccf929a
commit 203f7f3f1f
3 changed files with 17 additions and 4 deletions

View file

@ -101,6 +101,7 @@ namespace Ryujinx.Audio
}
_tracks.Clear();
_context.Dispose();
}
/// <summary>

View file

@ -107,6 +107,7 @@ namespace Ryujinx.HLE.HOS
public Keyset KeySet => Device.FileSystem.KeySet;
private bool _hasStarted;
private bool _isDisposed;
public BlitStruct<ApplicationControlProperty> ControlData { get; set; }
@ -741,8 +742,10 @@ namespace Ryujinx.HLE.HOS
protected virtual void Dispose(bool disposing)
{
if (disposing)
if (!_isDisposed && disposing)
{
_isDisposed = true;
KProcess terminationProcess = new KProcess(this);
KThread terminationThread = new KThread(this);

View file

@ -31,6 +31,8 @@ namespace Ryujinx.Ui
private static GlScreen _screen;
private static AutoResetEvent _screenExitStatus = new AutoResetEvent(false);
private static ListStore _tableStore;
private static bool _updatingGameTable;
@ -299,6 +301,8 @@ namespace Ryujinx.Ui
_emulationContext = device;
_screenExitStatus.Reset();
#if MACOS_BUILD
CreateGameWindow(device);
#else
@ -337,6 +341,8 @@ namespace Ryujinx.Ui
DiscordIntegrationModule.SwitchToMainMenu();
_screenExitStatus.Set();
Application.Invoke(delegate
{
_stopEmulation.Sensitive = false;
@ -371,12 +377,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();
@ -510,13 +521,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);
}