Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOTIFICATION_THEME_CHANGED is getting called when it shouldn't #50743

Closed
AaronRecord opened this issue Jul 22, 2021 · 2 comments · Fixed by #62846
Closed

NOTIFICATION_THEME_CHANGED is getting called when it shouldn't #50743

AaronRecord opened this issue Jul 22, 2021 · 2 comments · Fixed by #62846

Comments

@AaronRecord
Copy link
Contributor

AaronRecord commented Jul 22, 2021

Godot version

883bb2f

System information

Windows 10

Issue description

See https://chat.godotengine.org/channel/devel?msg=J4SjAHxFmwZ7NHYqQ

image

When opening a project in 3.x, NOTIFICATION_THEME_CHANGED consistently gets called 8 times (or at least on the FileSystemDock and ProjectExportDialog which were what I tested. In master it's only 3 times).

When running the project manager in 3.x, NOTIFICATION_THEME_CHANGED is only called 3 times in EditorAbout (although it doesn't get called at all in master because (maybe by mistake?) NOTIFICATION_THEME_CHANGED was removed from EditorAbout in master).

NOTIFICATION_THEME_CHANGED is also called when/right before an object is destroyed it seems (or at least when closing the editor.

In master NOTIFICATION_THEME_CHANGED is only called three times.

Steps to reproduce

Insert a breakpoint in NOTIFICATION_THEME_CHANGED

Minimal reproduction project

No response

@AaronRecord AaronRecord changed the title NOTIFICATION_THEME_CHANGED is getting called an inordinate amount of times NOTIFICATION_THEME_CHANGED is getting called when it shouldn't May 24, 2022
@AaronRecord
Copy link
Contributor Author

AaronRecord commented Jun 18, 2022

So the reason it's getting called 3 times is

  1. For case NOTIFICATION_ENTER_TREE
  2. NOTIFICATION_THEME_CHANGED gets called in NOTIFICATION_ENTER_TREE
  3. NOTIFICATION_THEME_CHANGE gets propagated to all children in add_child_notify. Note this doesn't get called if the control's parent isn't also a control.

_propagate_theme is also used to set the theme_owner to nullptr in remove_child_notify, but there's no check in _propagate_theme to see if the control is being removed or added, which is why NOTIFICATION_THEME_CHANGED also gets called when the control is removed. Calling NOTIFICATION_THEME_CHANGED only really needs to be done when a control node is entering the scene tree, as none of the theme changes will be visible when the node is outside of the tree.

@AaronRecord
Copy link
Contributor Author

AaronRecord commented Jul 28, 2022

I understand why NOTIFICATION_THEME_CHANGED is called so 3 times in master, but I haven't looked into why it's getting called so much more often in 3.x (8 times instead of 3). For whatever reason the control's theme is emitting changed several times, calling _theme_changed, which is what is causing all the extra notifications.

@akien-mga akien-mga added this to the 4.0 milestone Aug 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants