summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolonProduction <holonproduction@gmail.com>2022-10-06 19:23:34 +0200
committerHolonProduction <holonproduction@gmail.com>2022-11-29 16:16:23 +0100
commit1da0a1270570b364d5f850c71610f75eca6eda5a (patch)
treea2380fb6733d2230c8cedffabdf2020d98517c54
parent0c23a2cfe3ad897e1e49008629c135764b2c155c (diff)
Solve a bug with main window plugins.
When removing a main window plugin the bindings of the main window buttons was not changed to reflect the changed indices.
-rw-r--r--editor/editor_node.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 34c0c35b12..edb3cf2007 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -3426,7 +3426,9 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed
void EditorNode::remove_editor_plugin(EditorPlugin *p_editor, bool p_config_changed) {
if (p_editor->has_main_screen()) {
- for (int i = 0; i < singleton->main_editor_buttons.size(); i++) {
+ // Remove the main editor button and update the bindings of
+ // all buttons behind it to point to the correct main window.
+ for (int i = singleton->main_editor_buttons.size() - 1; i >= 0; i--) {
if (p_editor->get_name() == singleton->main_editor_buttons[i]->get_text()) {
if (singleton->main_editor_buttons[i]->is_pressed()) {
singleton->editor_select(EDITOR_SCRIPT);
@@ -3436,6 +3438,9 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor, bool p_config_chan
singleton->main_editor_buttons.remove_at(i);
break;
+ } else {
+ singleton->main_editor_buttons[i]->disconnect("pressed", callable_mp(singleton, &EditorNode::editor_select));
+ singleton->main_editor_buttons[i]->connect("pressed", callable_mp(singleton, &EditorNode::editor_select).bind(i - 1));
}
}