summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-11-02 22:36:49 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-11-02 22:36:49 +0100
commitc9e0d787fe49af72fcf84d6a54c073985d8a1851 (patch)
tree7ebbe6bcc8b681544a62b14c683d7fac3b29926a /scene
parente5950c5c1cd8f2f35fa9c496378761667f0c3004 (diff)
parentfb8588e68e99f927a1237e4f74431254851f8f69 (diff)
Merge pull request #67928 from YeldhamDev/we_really_need_a_callback_for_after_children_is_removed
Fix problems with `tab_changed` signal when removing multiple tabs at once
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/tab_container.cpp8
-rw-r--r--scene/gui/tab_container.h2
2 files changed, 5 insertions, 5 deletions
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index ab4808d312..9105267ad3 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -345,7 +345,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 || control == child_removing) {
+ if (!control || control->is_set_as_top_level() || control == tab_bar || children_removing.has(control)) {
continue;
}
@@ -584,10 +584,10 @@ void TabContainer::remove_child_notify(Node *p_child) {
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;
+ // As the child hasn't been removed yet, keep track of it so when the "tab_changed" signal is fired it can be ignored.
+ children_removing.push_back(c);
tab_bar->remove_tab(idx);
- child_removing = nullptr;
+ children_removing.erase(c);
_update_margins();
if (get_tab_count() == 0) {
diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h
index b552aa459b..60961e02d3 100644
--- a/scene/gui/tab_container.h
+++ b/scene/gui/tab_container.h
@@ -46,7 +46,7 @@ class TabContainer : public Container {
bool drag_to_rearrange_enabled = false;
bool use_hidden_tabs_for_min_size = false;
bool theme_changing = false;
- Node *child_removing = nullptr;
+ Vector<Control *> children_removing;
struct ThemeCache {
int side_margin = 0;