godotengine / godotengine/godot-cpp
Class instance variables scope clarification
- Dominant language
- C++
- Stars
- 2.7k
- Forks
- 809
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 8
Description
While going through the 'Dodge the creeps!' tutorial in C++, I noticed that signals' callbacks don't seem to observe changes made to a class instance variable:
[Hud::is_game_over](https://github.com/m4gr3d/godot_dodge_the_creeps/blob/170d2e38a314ab4d343dac8ec2b627a3575c6e2e/src/hud.h#L24) is updated in [Hud::show_game_over](https://github.com/m4gr3d/godot_dodge_the_creeps/blob/170d2e38a314ab4d343dac8ec2b627a3575c6e2e/src/hud.cpp#L36), yet when the [Hud::on_MessageTimer_timeout](https://github.com/m4gr3d/godot_dodge_the_creeps/blob/170d2e38a314ab4d343dac8ec2b627a3575c6e2e/src/hud.cpp#L53) callback is fired, the updated value of [Hud::is_game_over](https://github.com/m4gr3d/godot_dodge_the_creeps/blob/170d2e38a314ab4d343dac8ec2b627a3575c6e2e/src/hud.h#L24) is not reflected.
I validated that the callback is happening to the same object and on the same thread as when the instance variable is updated.
This is probably not a bug, and most likely just some clarifications are needed to explain why that behavior is observed (if that's the expected behavior).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.