From 28b1e66b51ec7b4552a12ac5ee37ecd6b96d4541 Mon Sep 17 00:00:00 2001 From: Lennon Donaghy Date: Sun, 1 Aug 2021 05:00:19 +0100 Subject: [PATCH] HackStudio: Properly close previous project when opening a new one Previously files in the open files view would stay open from the previous project, and files in the new project with the same name as files in the old one would be inaccessible, with the old ones showing up instead. Now all files and open editors are closed before a new project is opened. Fixes #9103 --- Userland/DevTools/HackStudio/HackStudioWidget.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 7720f5b9536..0bff5357255 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -192,6 +192,13 @@ void HackStudioWidget::open_project(const String& root_path) perror("chdir"); 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_project = Project::open_with_root_path(root_path); VERIFY(m_project); if (m_project_tree_view) {