summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-05-16 15:10:27 +0200
committerGitHub <noreply@github.com>2022-05-16 15:10:27 +0200
commitfa2b3269aec8b0c09f89f3a961200b505e3f798a (patch)
treefc5ac5423b5e336367c92673ecbac9e522d1bc63 /scene/gui
parenteaa4e864332878779ff31341a2887a1f4375e61f (diff)
parent249d6a4225ed8fc6c0375496c5bfc99e056a4b45 (diff)
Merge pull request #59231 from Sauermann/fix-top-level-identification
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/control.cpp24
1 files changed, 7 insertions, 17 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 54fa726260..a0104387c9 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -712,35 +712,25 @@ void Control::_notification(int p_notification) {
data.parent_window = Object::cast_to<Window>(get_parent());
data.is_rtl_dirty = true;
- Node *parent = this; //meh
+ CanvasItem *node = this;
Control *parent_control = nullptr;
- bool subwindow = false;
-
- while (parent) {
- parent = parent->get_parent();
+ while (!node->is_set_as_top_level()) {
+ CanvasItem *parent = Object::cast_to<CanvasItem>(node->get_parent());
if (!parent) {
break;
}
- CanvasItem *ci = Object::cast_to<CanvasItem>(parent);
- if (ci && ci->is_set_as_top_level()) {
- subwindow = true;
- break;
- }
-
parent_control = Object::cast_to<Control>(parent);
-
if (parent_control) {
break;
- } else if (ci) {
- } else {
- break;
}
+
+ node = parent;
}
- if (parent_control && !subwindow) {
- //do nothing, has a parent control and not top_level
+ if (parent_control) {
+ // Do nothing, has a parent control.
if (data.theme.is_null() && parent_control->data.theme_owner) {
data.theme_owner = parent_control->data.theme_owner;
notification(NOTIFICATION_THEME_CHANGED);