Skip to content

Inconsistent Signal.is_connected behaviour for callables that combine bind and unbind #81118

Closed
@romlok

Description

Godot version

v4.1.1.stable.official [bd6af8e]

System information

Godot v4.1.1.stable - Debian GNU/Linux trixie/sid trixie - Vulkan (Mobile) - dedicated NVIDIA GeForce GTX 1060 (nvidia) - Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (6 Threads)

Issue description

👍 For Callables which have had bind xor unbind called on them, Signal.is_connected will return true so long as the base callable is the same.
⚠️ For Callables which have had bind and unbind called on them, Signal.is_connected seems to only return true for the exact Callable object.

I would expect is_connected to return true in the same manner for either case.

Steps to reproduce

extends Node2D

signal boop(doot)
signal beep(doot)
signal baap(doot)

func _ready():
    boop.connect(translate.bind(Vector2.ZERO))
    print(boop.is_connected(translate)) # true
    print(boop.is_connected(translate.bind(Vector2.ZERO))) # true
    boop.disconnect(translate.bind(Vector2.ZERO))

    beep.connect(translate.unbind(1))
    print(beep.is_connected(translate)) # true
    print(beep.is_connected(translate.bind(Vector2.ZERO))) # true
    print(beep.is_connected(translate.unbind(1))) # true
    beep.disconnect(translate.unbind(1))

    var handler = translate.bind(Vector2.ZERO).unbind(1)
    baap.connect(handler)
    print(baap.is_connected(translate)) # false
    print(baap.is_connected(translate.bind(Vector2.ZERO))) # false
    print(baap.is_connected(translate.unbind(1))) # false
    print(baap.is_connected(translate.bind(Vector2.ZERO).unbind(1))) # false
    print(baap.is_connected(handler)) # true
    # Attempting this `disconnect` triggers "Attempt to disconnect a nonexistent connection..."
    baap.disconnect(translate.bind(Vector2.ZERO).unbind(1))

Minimal reproduction project

Self-contained scene: test.zip

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions