#Cannot access a disposed object

7 messages · Page 1 of 1 (latest)

thick crest
#

Every once in a while, I haven't found a good repro yet, but the code isn't that complicated so I don't understand why I'd get this error.

Object name: 'IconTooltip'.
   at Godot.GodotObject.GetPtr(GodotObject instance) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotObject.base.cs:line 78
   at Godot.GodotObject.IsQueuedForDeletion() in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Generated/GodotObjects/GodotObject.cs:line 995```

And this is where it happens, on the IsQueuedForDeletion check.
```    private void _OnHideTooltip(int identifier)
    {
        if (m_currentTooltip != null)
        {
            HoverIndicator.Stop();
            var tooltipControl = m_currentTooltip as Control;
            var tween = CreateTween();
            tween.TweenProperty(tooltipControl, "modulate:a", 0, 0.25);
            tween.TweenCallback(Callable.From(() => 
            {
                if (tooltipControl != null && !tooltipControl.IsQueuedForDeletion())
                    tooltipControl.QueueFree();
                tooltipControl = null;
                m_currentTooltip = null;
            }));
        }
    }```

I can't check if tooltip is dispoed, it doesn't expose those methods, I would have thought that a null check is enough.
Any thoughts?
native cave
thick crest
#
Object name: 'IconTooltip'.
   at Godot.GodotObject.GetPtr(GodotObject instance) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotObject.base.cs:line 78
   at Godot.Tween.TweenProperty(GodotObject object, NodePath property, Variant finalVal, Double duration) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Generated/GodotObjects/Tween.cs:line 199
   at TooltipHandler._OnHideTooltip(Int32 identifier) in V:\dev\godot\unamed-deck-builder-sharp\utils\tooltip\source\TooltipHandler.cs:line 75```
#

Slightly different and happens more often without me assigning them with null.

#

it feels like it manages to arrive into this method a second time in the .25s it takes for the tween to finish and set the tooltip to null.

#
        {
            HoverIndicator.Stop();
            var tooltipControl = m_currentTooltip as Control;
            var tween = CreateTween();
            tween.TweenProperty(tooltipControl, "modulate:a", 0, 0.25);
            tween.TweenCallback(Callable.From(() => 
            {
                if (tooltipControl != null && !tooltipControl.IsQueuedForDeletion())
                    tooltipControl.QueueFree();
                tooltipControl = null;
                
            }));
            
            m_currentTooltip = null;
        }```
#

this seems to solve it