From d9c295de46c143f9f7aa35de362a8eb2161ade9f Mon Sep 17 00:00:00 2001 From: Lennon Donaghy Date: Mon, 2 Aug 2021 20:14:15 +0100 Subject: [PATCH] HackStudio: Moved code closing project from open_project to own method Take the code which closes the current project out of open_project method and move it into its own method. --- .../DevTools/HackStudio/HackStudioWidget.cpp | 25 +++++++++++-------- .../DevTools/HackStudio/HackStudioWidget.h | 1 + 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 080029b324..17b7363ba4 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -194,16 +194,7 @@ void HackStudioWidget::open_project(const String& root_path) exit(1); } if (m_project) { - m_editors_splitter->remove_all_children(); - m_all_editor_wrappers.clear(); - m_open_files.clear(); - m_open_files_vector.clear(); - add_new_editor(*m_editors_splitter); - m_find_in_files_widget->reset(); - m_todo_entries_widget->clear(); - m_terminal_wrapper->clear_including_history(); - stop_debugger_if_running(); - update_gml_preview(); + close_current_project(); } m_project = Project::open_with_root_path(root_path); VERIFY(m_project); @@ -1169,6 +1160,20 @@ void HackStudioWidget::stop_debugger_if_running() } } +void HackStudioWidget::close_current_project() +{ + m_editors_splitter->remove_all_children(); + m_all_editor_wrappers.clear(); + m_open_files.clear(); + m_open_files_vector.clear(); + add_new_editor(*m_editors_splitter); + m_find_in_files_widget->reset(); + m_todo_entries_widget->clear(); + m_terminal_wrapper->clear_including_history(); + stop_debugger_if_running(); + update_gml_preview(); +} + HackStudioWidget::~HackStudioWidget() { stop_debugger_if_running(); diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.h b/Userland/DevTools/HackStudio/HackStudioWidget.h index 0ba6c42b38..94a166c43b 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.h +++ b/Userland/DevTools/HackStudio/HackStudioWidget.h @@ -104,6 +104,7 @@ private: void handle_external_file_deletion(const String& filepath); void stop_debugger_if_running(); + void close_current_project(); void create_open_files_view(GUI::Widget& parent); void create_toolbar(GUI::Widget& parent);