godotengine / godotengine/godot

Signal using Anonymous Lambda function will keep gaining connections on scene reload, doesn't happen with Callable

Open
#94,641 0 comments 0 reactions 0 assignees View on GitHub
discussion documentation topic:gdscript
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

Reproducible in Godot v4.3.beta3

### System information

Godot v4.3.beta3 - Windows 10.0.22631 - Vulkan (Forward+) - dedicated AMD Radeon RX 7900 XTX (Advanced Micro Devices, Inc.; 32.0.11021.1011) - AMD Ryzen 9 7950X 16-Core Processor (32 Threads)

### Issue description

https://github.com/user-attachments/assets/9b4e25ba-0516-494a-ae06-7b5816c22f1e

Not sure if these specific details matter, but... when using a project with a Singleton Event Bus, and connecting to a signal in a scene's ready function with a lambda callable, the issue occurs where when the scene reloads (```get_tree().reload_current_scene()```), the signals connections will keep growing and not be disconnected.

This will cause the signal to fire for each connection it has when emitted.

### Steps to reproduce

1. Create a signal and connect using a Lambda Callable.
2. Reload the current scene that belongs to the signal connection.
3. Observe the signal will keep gaining connections.
4. If using the MRP, load the project and click the "Restart Game" button, and observe the console.

### Minimal reproduction project (MRP)

[signalbugmrp.zip](https://github.com/user-attachments/files/16340346/signalbugmrp.zip)

Contributor guide

Open the contributing guide

Research direction

Open the linked minimal reproduction project and trace the scene's ready-time signal connection using the anonymous lambda Callable. Compare its behavior with the Callable case while repeatedly using get_tree().reload_current_scene(). Done means reloading no longer accumulates connections and each signal emission fires only once.

Written by the indexing model from the issue text.

Assessment

Tech stack
godot
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.