[.Net] Handle is not initialized.
when assigning TweenMethod
to a later-disposed Tween
#100691
Open
Description
opened on Dec 21, 2024
Tested versions
v4.3.stable.mono.official [77dcf97]
System information
Godot v4.3.stable.mono - Windows 10.0.19044 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4060 Ti (NVIDIA; 32.0.15.6603) - AMD Ryzen 9 5900X 12-Core Processor (24 Threads)
Issue description
Assigning TweenMethod
to a Tween
that will be disposed later will result in the following counterintuitive error.
ERROR: System.InvalidOperationException: Handle is not initialized.
at System.Runtime.InteropServices.GCHandle.FromIntPtr(IntPtr value)
at Godot.Bridge.ScriptManagerBridge.SetGodotObjectPtr(IntPtr gcHandlePtr, IntPtr newPtr) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs:line 295
at: void Godot.NativeInterop.ExceptionUtils.LogException(System.Exception) (/root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/ExceptionUtils.cs:113)
Steps to reproduce
Run the following code:
using Godot;
public partial class Main : Node
{
public override void _Process(double delta)
{
for (var i = 0; i < 1000; i++)
{
var node = new Node2D();
using var tween = node.CreateTween();
tween.TweenMethod(
new(node, CanvasItem.MethodName.SetModulate),
Colors.Black,
Colors.White,
0.1f
);
AddChild(node);
}
}
}
Please note that removing the using
keyword stops the issue from happening.
Activity