@@ -2057,45 +2057,7 @@ void EditorNode::try_autosave() {
20572057}
20582058
20592059void EditorNode::restart_editor (bool p_goto_project_manager) {
2060- exiting = true ;
2061-
2062- if (project_run_bar->is_playing ()) {
2063- project_run_bar->stop_playing ();
2064- }
2065-
2066- String to_reopen;
2067- if (!p_goto_project_manager && get_tree ()->get_edited_scene_root ()) {
2068- to_reopen = get_tree ()->get_edited_scene_root ()->get_scene_file_path ();
2069- }
2070-
2071- _exit_editor (EXIT_SUCCESS);
2072-
2073- List<String> args;
2074- for (const String &a : Main::get_forwardable_cli_arguments (Main::CLI_SCOPE_TOOL)) {
2075- args.push_back (a);
2076- }
2077-
2078- if (p_goto_project_manager) {
2079- args.push_back (" --project-manager" );
2080-
2081- // Setup working directory.
2082- const String exec_dir = OS::get_singleton ()->get_executable_path ().get_base_dir ();
2083- if (!exec_dir.is_empty ()) {
2084- args.push_back (" --path" );
2085- args.push_back (exec_dir);
2086- }
2087- } else {
2088- args.push_back (" --path" );
2089- args.push_back (ProjectSettings::get_singleton ()->get_resource_path ());
2090-
2091- args.push_back (" -e" );
2092- }
2093-
2094- if (!to_reopen.is_empty ()) {
2095- args.push_back (to_reopen);
2096- }
2097-
2098- OS::get_singleton ()->set_restart_on_exit (true , args);
2060+ _menu_option_confirm (p_goto_project_manager ? PROJECT_QUIT_TO_PROJECT_MANAGER : PROJECT_RELOAD_CURRENT_PROJECT, false );
20992061}
21002062
21012063void EditorNode::_save_all_scenes () {
@@ -3480,10 +3442,10 @@ void EditorNode::_discard_changes(const String &p_str) {
34803442
34813443 } break ;
34823444 case PROJECT_QUIT_TO_PROJECT_MANAGER: {
3483- restart_editor (true );
3445+ _restart_editor (true );
34843446 } break ;
34853447 case PROJECT_RELOAD_CURRENT_PROJECT: {
3486- restart_editor ();
3448+ _restart_editor ();
34873449 } break ;
34883450 }
34893451}
@@ -5508,11 +5470,11 @@ bool EditorNode::has_scenes_in_session() {
55085470}
55095471
55105472void EditorNode::undo () {
5511- trigger_menu_option (FILE_UNDO, true );
5473+ _menu_option_confirm (FILE_UNDO, true );
55125474}
55135475
55145476void EditorNode::redo () {
5515- trigger_menu_option (FILE_REDO, true );
5477+ _menu_option_confirm (FILE_REDO, true );
55165478}
55175479
55185480bool EditorNode::ensure_main_scene (bool p_from_native) {
@@ -5680,6 +5642,48 @@ bool EditorNode::_is_closing_editor() const {
56805642 return tab_closing_menu_option == FILE_QUIT || tab_closing_menu_option == PROJECT_QUIT_TO_PROJECT_MANAGER || tab_closing_menu_option == PROJECT_RELOAD_CURRENT_PROJECT;
56815643}
56825644
5645+ void EditorNode::_restart_editor (bool p_goto_project_manager) {
5646+ exiting = true ;
5647+
5648+ if (project_run_bar->is_playing ()) {
5649+ project_run_bar->stop_playing ();
5650+ }
5651+
5652+ String to_reopen;
5653+ if (!p_goto_project_manager && get_tree ()->get_edited_scene_root ()) {
5654+ to_reopen = get_tree ()->get_edited_scene_root ()->get_scene_file_path ();
5655+ }
5656+
5657+ _exit_editor (EXIT_SUCCESS);
5658+
5659+ List<String> args;
5660+ for (const String &a : Main::get_forwardable_cli_arguments (Main::CLI_SCOPE_TOOL)) {
5661+ args.push_back (a);
5662+ }
5663+
5664+ if (p_goto_project_manager) {
5665+ args.push_back (" --project-manager" );
5666+
5667+ // Setup working directory.
5668+ const String exec_dir = OS::get_singleton ()->get_executable_path ().get_base_dir ();
5669+ if (!exec_dir.is_empty ()) {
5670+ args.push_back (" --path" );
5671+ args.push_back (exec_dir);
5672+ }
5673+ } else {
5674+ args.push_back (" --path" );
5675+ args.push_back (ProjectSettings::get_singleton ()->get_resource_path ());
5676+
5677+ args.push_back (" -e" );
5678+ }
5679+
5680+ if (!to_reopen.is_empty ()) {
5681+ args.push_back (to_reopen);
5682+ }
5683+
5684+ OS::get_singleton ()->set_restart_on_exit (true , args);
5685+ }
5686+
56835687void EditorNode::_scene_tab_closed (int p_tab) {
56845688 current_menu_option = SCENE_TAB_CLOSE;
56855689 tab_closing_idx = p_tab;
0 commit comments