Browse Source

C#: Add null check before calling `UnregisterGodotObject`

RedworkDE 2 years ago
parent
commit
693e6e036b

+ 4 - 1
modules/mono/glue/GodotSharp/GodotSharp/Core/GodotObject.base.cs

@@ -125,7 +125,10 @@ namespace Godot
                 NativePtr = IntPtr.Zero;
                 NativePtr = IntPtr.Zero;
             }
             }
 
 
-            DisposablesTracker.UnregisterGodotObject(this, _weakReferenceToSelf);
+            if (_weakReferenceToSelf != null)
+            {
+                DisposablesTracker.UnregisterGodotObject(this, _weakReferenceToSelf);
+            }
         }
         }
 
 
         /// <summary>
         /// <summary>