godotengine / godotengine/godot

Inheriting custom class duplicates some signals in the editor

Open
#89,359 8 comments 0 reactions 0 assignees View on GitHub
bug needs testing platform:macos topic:editor topic:gdscript topic:platforms
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in 4.2.1-stable. 4.2.2-stable, 4.3 beta1

### System information

Godot v4.2.1.stable - macOS 14.2.1 - Vulkan (Forward+) - integrated Intel(R) Iris(TM) Plus Graphics 645 - Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz (8 Threads)

### Issue description

When inheriting from a class that defines custom signals, some of the signals seem to get duplicated in the child class in the editor.

The simplest way in which this can be demonstrated is when you "override" the attached script on a node in the scene tree, but it also happens if you define a derived class (with extends and with or without class_name), and instantiate them as separate nodes.

In the examples I have been able to whittle down, it seems that all signals except the first one get duplicated.

When you connect up the signals, the duplicated signals in the list both get connected at the same time, so I suspect it's just an editor problem, nothing deeper.

Some screen shots:

The scene tree:
Scene Tree

The signals for the Droppable class (see below)
Droppable

And the signals in the derived node:
DerivedDroppable

I would have expected the `targeted` and `untargeted` signals to not be duplicated in the child class. But as I said, I am pretty sure this is only in the editor, and not anything more problematic. The test I have included in the MRP seems to confirm signals get called once.

### Steps to reproduce

Summarising:

Create a class similar to

class_name Droppable
extends Area2D

signal received_drop(node: Node2D)
signal targeted
signal untargeted

Add a node to the scene tree of this type. Attach a script to that node, which simply looks like this:

extends Droppable

Observe the signals available for the two nodes.

### Minimal reproduction project (MRP)

I have uploaded a sample project with all this information to https://github.com/mgjv/godot-4.2.1-signal-inheritance.

Some more experiments have shown that this also happens with classes derived from Node (not just Area2D)

Contributor guide

Open the contributing guide

Research direction

Start with the minimal reproduction project at https://github.com/mgjv/godot-4.2.1-signal-inheritance and reproduce the issue using the Droppable and derived scripts described in the report. Inspect the editor's available-signal list for inherited classes and confirm that each custom signal appears only once while signal connections still behave correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
game-dev, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.