diff --git a/Ryujinx.Audio/Renderers/OpenAL/OpenALAudioOut.cs b/Ryujinx.Audio/Renderers/OpenAL/OpenALAudioOut.cs index 30b325a51a..ea5ce62146 100644 --- a/Ryujinx.Audio/Renderers/OpenAL/OpenALAudioOut.cs +++ b/Ryujinx.Audio/Renderers/OpenAL/OpenALAudioOut.cs @@ -101,6 +101,7 @@ namespace Ryujinx.Audio } _tracks.Clear(); + _context.Dispose(); } /// diff --git a/Ryujinx.HLE/HOS/Horizon.cs b/Ryujinx.HLE/HOS/Horizon.cs index e4e0894340..6dcf581dbf 100644 --- a/Ryujinx.HLE/HOS/Horizon.cs +++ b/Ryujinx.HLE/HOS/Horizon.cs @@ -107,6 +107,7 @@ namespace Ryujinx.HLE.HOS public Keyset KeySet => Device.FileSystem.KeySet; private bool _hasStarted; + private bool _isDisposed; public BlitStruct 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); diff --git a/Ryujinx/Ui/MainWindow.cs b/Ryujinx/Ui/MainWindow.cs index f9f3657606..45e3fa7169 100644 --- a/Ryujinx/Ui/MainWindow.cs +++ b/Ryujinx/Ui/MainWindow.cs @@ -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); }