Connecting undefined signals

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Tatuzudo
:warning: Old Version Published before Godot 3 was released.

Hello to all,

Is there a problem in connecting undefined signals?

For example:
get_node('my_node').connect( 'signal', self, 'function')
Now supose that the node my_node have no ‘signal’ defined.

I tested it and it is working fine for now (the game doesn’t crash), but is there a chance it could cause some weird problems in the future? It just seems wrong


:bust_in_silhouette: Reply From: kidscancode

This just sets up listening for that signal. If the signal isn’t defined on mynode it won’t be emitted, but nothing bad will happen, you’ll just never call function.

Though nothing bad happening could be a bad thing, since it will be hard to catch the error unless you already suspect the signal handling to be broken.

raymoo | 2017-10-19 19:07

Thanks for the answer! I asked because I will probably have to reuse the node and not all parents will emit the signal

Tatuzudo | 2017-10-21 15:06