diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-09 09:22:08 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-09 09:22:08 +0100 |
commit | 2db593ac2fc3aa8c8fd36c72e35a9f8a592668f1 (patch) | |
tree | b6a00885143c525bef59ee690e8e46c74a688273 /editor | |
parent | 6a86dfad29d5475aa6be4510b0823e834a8e85ed (diff) | |
parent | 5c498f714dafc3bcbb7601c5665b518513b353cb (diff) |
Merge pull request #70580 from timothyqiu/drop-extern
Fix error when dropping script into script editor
Diffstat (limited to 'editor')
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 61bf51b6dc..628ed44aa1 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -2954,15 +2954,18 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co Ref<Resource> res = open_file(file); if (res.is_valid()) { - if (tab_container->get_tab_count() > num_tabs_before) { + const int num_tabs = tab_container->get_tab_count(); + if (num_tabs > num_tabs_before) { tab_container->move_child(tab_container->get_tab_control(tab_container->get_tab_count() - 1), new_index); - num_tabs_before = tab_container->get_tab_count(); - } else { /* Maybe script was already open */ + num_tabs_before = num_tabs; + } else if (num_tabs > 0) { /* Maybe script was already open */ tab_container->move_child(tab_container->get_tab_control(tab_container->get_current_tab()), new_index); } } } - tab_container->set_current_tab(new_index); + if (tab_container->get_tab_count() > 0) { + tab_container->set_current_tab(new_index); + } _update_script_names(); } } |