mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-12 22:58:01 +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.CallbackHandle> CallbackHandles = new List<SteamNative.CallbackHandle>();
|
||||||
private List<SteamNative.CallResult> CallResults = new List<SteamNative.CallResult>();
|
private List<SteamNative.CallResult> CallResults = new List<SteamNative.CallResult>();
|
||||||
|
protected bool disposed = false;
|
||||||
|
|
||||||
|
|
||||||
protected BaseSteamworks( uint appId )
|
protected BaseSteamworks( uint appId )
|
||||||
@ -39,8 +40,15 @@ namespace Facepunch.Steamworks
|
|||||||
System.Environment.SetEnvironmentVariable("SteamGameId", AppId.ToString());
|
System.Environment.SetEnvironmentVariable("SteamGameId", AppId.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~BaseSteamworks()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void Dispose()
|
public virtual void Dispose()
|
||||||
{
|
{
|
||||||
|
if ( disposed ) return;
|
||||||
|
|
||||||
Callbacks.Clear();
|
Callbacks.Clear();
|
||||||
|
|
||||||
foreach ( var h in CallbackHandles )
|
foreach ( var h in CallbackHandles )
|
||||||
@ -81,6 +89,7 @@ namespace Facepunch.Steamworks
|
|||||||
|
|
||||||
System.Environment.SetEnvironmentVariable("SteamAppId", null );
|
System.Environment.SetEnvironmentVariable("SteamAppId", null );
|
||||||
System.Environment.SetEnvironmentVariable("SteamGameId", null );
|
System.Environment.SetEnvironmentVariable("SteamGameId", null );
|
||||||
|
disposed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void SetupCommonInterfaces()
|
protected void SetupCommonInterfaces()
|
||||||
|
@ -135,6 +135,11 @@ namespace Facepunch.Steamworks
|
|||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~Client()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Should be called at least once every frame
|
/// Should be called at least once every frame
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -163,6 +168,8 @@ namespace Facepunch.Steamworks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
|
if ( disposed ) return;
|
||||||
|
|
||||||
if ( Voice != null )
|
if ( Voice != null )
|
||||||
{
|
{
|
||||||
Voice = null;
|
Voice = null;
|
||||||
|
@ -83,6 +83,11 @@ namespace Facepunch.Steamworks
|
|||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~Server()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Should be called at least once every frame
|
/// Should be called at least once every frame
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -256,6 +261,8 @@ namespace Facepunch.Steamworks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
|
if ( disposed ) return;
|
||||||
|
|
||||||
if ( Query != null )
|
if ( Query != null )
|
||||||
{
|
{
|
||||||
Query = null;
|
Query = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user