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:
parent
532ccf929a
commit
203f7f3f1f
3 changed files with 17 additions and 4 deletions
|
@ -101,6 +101,7 @@ namespace Ryujinx.Audio
|
||||||
}
|
}
|
||||||
|
|
||||||
_tracks.Clear();
|
_tracks.Clear();
|
||||||
|
_context.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -107,6 +107,7 @@ namespace Ryujinx.HLE.HOS
|
||||||
public Keyset KeySet => Device.FileSystem.KeySet;
|
public Keyset KeySet => Device.FileSystem.KeySet;
|
||||||
|
|
||||||
private bool _hasStarted;
|
private bool _hasStarted;
|
||||||
|
private bool _isDisposed;
|
||||||
|
|
||||||
public BlitStruct<ApplicationControlProperty> ControlData { get; set; }
|
public BlitStruct<ApplicationControlProperty> ControlData { get; set; }
|
||||||
|
|
||||||
|
@ -741,8 +742,10 @@ namespace Ryujinx.HLE.HOS
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (!_isDisposed && disposing)
|
||||||
{
|
{
|
||||||
|
_isDisposed = true;
|
||||||
|
|
||||||
KProcess terminationProcess = new KProcess(this);
|
KProcess terminationProcess = new KProcess(this);
|
||||||
|
|
||||||
KThread terminationThread = new KThread(this);
|
KThread terminationThread = new KThread(this);
|
||||||
|
|
|
@ -31,6 +31,8 @@ namespace Ryujinx.Ui
|
||||||
|
|
||||||
private static GlScreen _screen;
|
private static GlScreen _screen;
|
||||||
|
|
||||||
|
private static AutoResetEvent _screenExitStatus = new AutoResetEvent(false);
|
||||||
|
|
||||||
private static ListStore _tableStore;
|
private static ListStore _tableStore;
|
||||||
|
|
||||||
private static bool _updatingGameTable;
|
private static bool _updatingGameTable;
|
||||||
|
@ -299,6 +301,8 @@ namespace Ryujinx.Ui
|
||||||
|
|
||||||
_emulationContext = device;
|
_emulationContext = device;
|
||||||
|
|
||||||
|
_screenExitStatus.Reset();
|
||||||
|
|
||||||
#if MACOS_BUILD
|
#if MACOS_BUILD
|
||||||
CreateGameWindow(device);
|
CreateGameWindow(device);
|
||||||
#else
|
#else
|
||||||
|
@ -337,6 +341,8 @@ namespace Ryujinx.Ui
|
||||||
|
|
||||||
DiscordIntegrationModule.SwitchToMainMenu();
|
DiscordIntegrationModule.SwitchToMainMenu();
|
||||||
|
|
||||||
|
_screenExitStatus.Set();
|
||||||
|
|
||||||
Application.Invoke(delegate
|
Application.Invoke(delegate
|
||||||
{
|
{
|
||||||
_stopEmulation.Sensitive = false;
|
_stopEmulation.Sensitive = false;
|
||||||
|
@ -371,12 +377,17 @@ namespace Ryujinx.Ui
|
||||||
if (device != null)
|
if (device != null)
|
||||||
{
|
{
|
||||||
UpdateGameMetadata(device.System.TitleIdText);
|
UpdateGameMetadata(device.System.TitleIdText);
|
||||||
|
|
||||||
|
if (_screen != null)
|
||||||
|
{
|
||||||
|
_screen.Exit();
|
||||||
|
_screenExitStatus.WaitOne();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Dispose();
|
Dispose();
|
||||||
|
|
||||||
Profile.FinishProfiling();
|
Profile.FinishProfiling();
|
||||||
device?.Dispose();
|
|
||||||
DiscordIntegrationModule.Exit();
|
DiscordIntegrationModule.Exit();
|
||||||
Logger.Shutdown();
|
Logger.Shutdown();
|
||||||
Application.Quit();
|
Application.Quit();
|
||||||
|
@ -510,13 +521,11 @@ namespace Ryujinx.Ui
|
||||||
|
|
||||||
private void Exit_Pressed(object sender, EventArgs args)
|
private void Exit_Pressed(object sender, EventArgs args)
|
||||||
{
|
{
|
||||||
_screen?.Exit();
|
|
||||||
End(_emulationContext);
|
End(_emulationContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_Close(object sender, DeleteEventArgs args)
|
private void Window_Close(object sender, DeleteEventArgs args)
|
||||||
{
|
{
|
||||||
_screen?.Exit();
|
|
||||||
End(_emulationContext);
|
End(_emulationContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue