Skip to content

Commit 90d1116

Browse files
committed
Merge remote-tracking branch 'origin/main' into no-normals-problems
2 parents 850b9bc + 5ca9a02 commit 90d1116

File tree

5 files changed

+152
-115
lines changed

5 files changed

+152
-115
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
##### Fixes :wrench:
66

7+
- Fixed a bug that could cause a crash on AppDomain reloads.
78
- Fixed a bug that could cause a crash or incorrect textures when multiple `Cesium3DTileset` tiles referenced the same image by URL.
89
- Fixed a bug that could cause incorrect colors in a model that did have vertex colors but did not have normals.
910
- Fixed a bug that could cause a hang when attempting to load a model with UINT16 indices where generating flat normals required more than 2^16 vertices.
11+
- Fixed a bug in the Abseil vcpkg overlay port that could cause linker errors on some systems.
1012

1113
## v1.14.0 - 2024-12-02
1214

Reinterop~/CSharpObjectHandleUtility.cs

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,15 @@ public static IntPtr CopyHandle(IntPtr handle)
3737
return handle;
3838
3939
// Allocate a new GCHandle pointing to the same object.
40-
GCHandle gcHandle = GCHandle.FromIntPtr(handle);
41-
return GCHandle.ToIntPtr(GCHandle.Alloc(gcHandle.Target));
40+
try
41+
{
42+
GCHandle gcHandle = GCHandle.FromIntPtr(handle);
43+
return GCHandle.ToIntPtr(GCHandle.Alloc(gcHandle.Target));
44+
}
45+
catch (Exception)
46+
{
47+
return IntPtr.Zero;
48+
}
4249
}
4350
4451
public static void FreeHandle(IntPtr handle)
@@ -50,14 +57,13 @@ public static void FreeHandle(IntPtr handle)
5057
{
5158
GCHandle.FromIntPtr(handle).Free();
5259
}
53-
catch (ArgumentException e)
60+
catch (Exception)
5461
{
5562
// The "GCHandle value belongs to a different domain" exception tends
5663
// to happen on AppDomain reload, which is common in Unity.
5764
// Catch the exception to prevent it propagating through our native
5865
// code and blowing things up.
5966
// See: https://github.com/CesiumGS/cesium-unity/issues/18
60-
System.Console.WriteLine(e.ToString());
6167
}
6268
}
6369
@@ -66,18 +72,32 @@ public static object GetObjectFromHandle(IntPtr handle)
6672
if (handle == IntPtr.Zero)
6773
return null;
6874
69-
return GCHandle.FromIntPtr(handle).Target;
75+
try
76+
{
77+
return GCHandle.FromIntPtr(handle).Target;
78+
}
79+
catch (Exception)
80+
{
81+
return null;
82+
}
7083
}
7184
7285
public static object GetObjectAndFreeHandle(IntPtr handle)
7386
{
7487
if (handle == IntPtr.Zero)
7588
return null;
7689
77-
GCHandle gcHandle = GCHandle.FromIntPtr(handle);
78-
object result = gcHandle.Target;
79-
gcHandle.Free();
80-
return result;
90+
try
91+
{
92+
GCHandle gcHandle = GCHandle.FromIntPtr(handle);
93+
object result = gcHandle.Target;
94+
gcHandle.Free();
95+
return result;
96+
}
97+
catch (Exception)
98+
{
99+
return null;
100+
}
81101
}
82102
83103
public static void ResetHandleObject(IntPtr handle, object newValue)

0 commit comments

Comments
 (0)