Fixed NRE in inventory result dispose

This commit is contained in:
Garry Newman 2018-02-15 14:03:28 +00:00
parent 2ee5fa4a5d
commit c4617c5884

View File

@ -14,7 +14,7 @@ public class Result : IDisposable
internal static Dictionary< int, Result > Pending;
internal Inventory inventory;
private SteamNative.SteamInventoryResult_t Handle { get; set; }
private SteamNative.SteamInventoryResult_t Handle { get; set; } = -1;
/// <summary>
/// Called when result is successfully returned
@ -169,8 +169,12 @@ internal unsafe byte[] Serialize()
public void Dispose()
{
inventory.inventory.DestroyResult( Handle );
Handle = -1;
if ( Handle != -1 && inventory != null )
{
inventory.inventory.DestroyResult( Handle );
Handle = -1;
}
inventory = null;
}
}