Merge pull request #70581 from timothyqiu/drop-extern-3.x
[3.x] Fix error when dropping script into script editor
This commit is contained in:
commit
085490fa06
1 changed files with 7 additions and 4 deletions
|
@ -2613,15 +2613,18 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
|
||||||
Ref<Script> scr = ResourceLoader::load(file);
|
Ref<Script> scr = ResourceLoader::load(file);
|
||||||
if (scr.is_valid()) {
|
if (scr.is_valid()) {
|
||||||
edit(scr);
|
edit(scr);
|
||||||
if (tab_container->get_child_count() > num_tabs_before) {
|
const int num_tabs = tab_container->get_child_count();
|
||||||
|
if (num_tabs > num_tabs_before) {
|
||||||
tab_container->move_child(tab_container->get_child(tab_container->get_child_count() - 1), new_index);
|
tab_container->move_child(tab_container->get_child(tab_container->get_child_count() - 1), new_index);
|
||||||
num_tabs_before = tab_container->get_child_count();
|
num_tabs_before = num_tabs;
|
||||||
} else { /* Maybe script was already open */
|
} else if (num_tabs > 0) { /* Maybe script was already open */
|
||||||
tab_container->move_child(tab_container->get_child(tab_container->get_current_tab()), new_index);
|
tab_container->move_child(tab_container->get_child(tab_container->get_current_tab()), new_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (tab_container->get_child_count() > 0) {
|
||||||
tab_container->set_current_tab(new_index);
|
tab_container->set_current_tab(new_index);
|
||||||
|
}
|
||||||
_update_script_names();
|
_update_script_names();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue