Browse Source

Merge pull request #79151 from RedworkDE/net-unregister-godotobject-check

C#: Add null check before calling `UnregisterGodotObject`
Rémi Verschelde 2 years ago
parent
commit
c3b0a92c3c
1 changed files with 4 additions and 1 deletions
  1. 4 1
      modules/mono/glue/GodotSharp/GodotSharp/Core/GodotObject.base.cs

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

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