diff options
author | Rindbee <idleman@yeah.net> | 2022-07-18 19:56:23 +0800 |
---|---|---|
committer | Rindbee <idleman@yeah.net> | 2022-07-18 20:06:21 +0800 |
commit | c47ac206207e4be5d4694d3e2796583069a79a64 (patch) | |
tree | c4b4d44d9477dd62cbec4dc92afe0e5f599609dd /scene/gui/tab_container.cpp | |
parent | ecc86afc00c6ace07bfc05ea6ebe8a971d40934b (diff) |
Fix getting outdated tab controls
Diffstat (limited to 'scene/gui/tab_container.cpp')
-rw-r--r-- | scene/gui/tab_container.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index fa929344d4..08db07c425 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -312,7 +312,7 @@ Vector<Control *> TabContainer::_get_tab_controls() const { Vector<Control *> controls; for (int i = 0; i < get_child_count(); i++) { Control *control = Object::cast_to<Control>(get_child(i)); - if (!control || control->is_set_as_top_level() || control == tab_bar) { + if (!control || control->is_set_as_top_level() || control == tab_bar || control == child_removing) { continue; } @@ -549,7 +549,12 @@ void TabContainer::remove_child_notify(Node *p_child) { return; } - tab_bar->remove_tab(get_tab_idx_from_control(c)); + int idx = get_tab_idx_from_control(c); + + // Before this, the tab control has not changed; after this, the tab control has changed. + child_removing = p_child; + tab_bar->remove_tab(idx); + child_removing = nullptr; _update_margins(); if (get_tab_count() == 0) { |