mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-02-03 17:20:45 +03:00
Added finalizer, less chance of crashing with unity editor stop plays missing dispose
This commit is contained in:
parent
6982d05042
commit
bf2a074547
@ -26,6 +26,7 @@ namespace Facepunch.Steamworks
|
||||
|
||||
private List<SteamNative.CallbackHandle> CallbackHandles = new List<SteamNative.CallbackHandle>();
|
||||
private List<SteamNative.CallResult> CallResults = new List<SteamNative.CallResult>();
|
||||
protected bool disposed = false;
|
||||
|
||||
|
||||
protected BaseSteamworks( uint appId )
|
||||
@ -39,8 +40,15 @@ namespace Facepunch.Steamworks
|
||||
System.Environment.SetEnvironmentVariable("SteamGameId", AppId.ToString());
|
||||
}
|
||||
|
||||
~BaseSteamworks()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
if ( disposed ) return;
|
||||
|
||||
Callbacks.Clear();
|
||||
|
||||
foreach ( var h in CallbackHandles )
|
||||
@ -81,6 +89,7 @@ namespace Facepunch.Steamworks
|
||||
|
||||
System.Environment.SetEnvironmentVariable("SteamAppId", null );
|
||||
System.Environment.SetEnvironmentVariable("SteamGameId", null );
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
protected void SetupCommonInterfaces()
|
||||
|
@ -135,6 +135,11 @@ namespace Facepunch.Steamworks
|
||||
Update();
|
||||
}
|
||||
|
||||
~Client()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Should be called at least once every frame
|
||||
/// </summary>
|
||||
@ -163,6 +168,8 @@ namespace Facepunch.Steamworks
|
||||
/// </summary>
|
||||
public override void Dispose()
|
||||
{
|
||||
if ( disposed ) return;
|
||||
|
||||
if ( Voice != null )
|
||||
{
|
||||
Voice = null;
|
||||
|
@ -83,6 +83,11 @@ namespace Facepunch.Steamworks
|
||||
Update();
|
||||
}
|
||||
|
||||
~Server()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Should be called at least once every frame
|
||||
/// </summary>
|
||||
@ -256,6 +261,8 @@ namespace Facepunch.Steamworks
|
||||
/// </summary>
|
||||
public override void Dispose()
|
||||
{
|
||||
if ( disposed ) return;
|
||||
|
||||
if ( Query != null )
|
||||
{
|
||||
Query = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user