_handle track fix
Some checks failed
Build Android / Game (Android, Release ARM64) (push) Has been cancelled
Build iOS / Game (iOS, Release ARM64) (push) Has been cancelled
Build Linux / Editor (Linux, Development x64) (push) Has been cancelled
Build Linux / Game (Linux, Release x64) (push) Has been cancelled
Build macOS / Editor (Mac, Development ARM64) (push) Has been cancelled
Build macOS / Game (Mac, Release ARM64) (push) Has been cancelled
Build Windows / Editor (Windows, Development x64) (push) Has been cancelled
Build Windows / Game (Windows, Release x64) (push) Has been cancelled
Cooker / Cook (Mac) (push) Has been cancelled
Tests / Tests (Linux) (push) Has been cancelled
Tests / Tests (Windows) (push) Has been cancelled

This commit is contained in:
2025-12-15 18:59:43 +02:00
parent 88f8bb1e29
commit 9a22bf965d

View File

@@ -364,8 +364,8 @@ namespace FlaxEngine.Interop
private GCHandle handle;
private static HashSet<IntPtr> _weakHandles = new HashSet<nint>();
private static Dictionary<IntPtr, string> _handles = new();
private static Dictionary<IntPtr, string> _handles2 = new();
private static ConcurrentDictionary<IntPtr, string> _handles = new();
private static ConcurrentDictionary<IntPtr, string> _handles2 = new();
private ManagedHandle(IntPtr handle) => this.handle = GCHandle.FromIntPtr(handle);
@@ -379,14 +379,14 @@ namespace FlaxEngine.Interop
if (type == GCHandleType.Weak || type == GCHandleType.WeakTrackResurrection)
_weakHandles.Add((IntPtr)handle);
else if (_handles.Count < 14000)
_handles.Add((IntPtr)handle, value?.GetType().FullName ?? "");
_handles.TryAdd((IntPtr)handle, value?.GetType().FullName ?? "");
else
{
if (_handles2.Count > 12)
type = type;
if (value?.GetType() == typeof(string))
type = type;
_handles2.Add((IntPtr)handle, value?.GetType().FullName ?? "");
_handles2.TryAdd((IntPtr)handle, value?.GetType().FullName ?? "");
}
}
#else
@@ -414,11 +414,11 @@ namespace FlaxEngine.Interop
handle = handle;
handle = handle;
}
else if (_handles.Remove((IntPtr)handle))
else if (_handles.Remove((IntPtr)handle, out _))
{
handle = handle;
}
else if (_handles2.Remove((IntPtr)handle))
else if (_handles2.Remove((IntPtr)handle, out _))
{
handle = handle;
}