summaryrefslogtreecommitdiff
path: root/Userland/DevTools/HackStudio
diff options
context:
space:
mode:
authorLennon Donaghy <donaghylennon@gmail.com>2021-08-03 00:01:07 +0100
committerAndreas Kling <kling@serenityos.org>2021-08-22 10:30:06 +0200
commitd454c63bde89c1d476981acb66d81fce14c11ebe (patch)
tree3da0e056bcf56ed2c31293d93ca1e7fae29a4261 /Userland/DevTools/HackStudio
parentd9c295de46c143f9f7aa35de362a8eb2161ade9f (diff)
downloadserenity-d454c63bde89c1d476981acb66d81fce14c11ebe.zip
HackStudio: Fix GitWidget issues with switching between projects
GitWidget no longer crashes upon trying to create a repository for a new project, and it correctly updates after opening a different project. A new method, change_repo, has been added to make this work, which changes m_repo_root and resets most of the widget's state in order to make this work.
Diffstat (limited to 'Userland/DevTools/HackStudio')
-rw-r--r--Userland/DevTools/HackStudio/Git/GitWidget.cpp8
-rw-r--r--Userland/DevTools/HackStudio/Git/GitWidget.h1
-rw-r--r--Userland/DevTools/HackStudio/HackStudioWidget.cpp4
3 files changed, 13 insertions, 0 deletions
diff --git a/Userland/DevTools/HackStudio/Git/GitWidget.cpp b/Userland/DevTools/HackStudio/Git/GitWidget.cpp
index 7579177f9d..2245e6f460 100644
--- a/Userland/DevTools/HackStudio/Git/GitWidget.cpp
+++ b/Userland/DevTools/HackStudio/Git/GitWidget.cpp
@@ -164,4 +164,12 @@ void GitWidget::show_diff(const LexicalPath& file_path)
VERIFY(original_content.has_value() && diff.has_value());
m_view_diff_callback(original_content.value(), diff.value());
}
+
+void GitWidget::change_repo(LexicalPath const& repo_root)
+{
+ m_repo_root = repo_root;
+ m_git_repo = nullptr;
+ m_unstaged_files->set_model(nullptr);
+ m_staged_files->set_model(nullptr);
+}
}
diff --git a/Userland/DevTools/HackStudio/Git/GitWidget.h b/Userland/DevTools/HackStudio/Git/GitWidget.h
index 7bb852022b..d9a8cd300f 100644
--- a/Userland/DevTools/HackStudio/Git/GitWidget.h
+++ b/Userland/DevTools/HackStudio/Git/GitWidget.h
@@ -24,6 +24,7 @@ public:
void refresh();
void set_view_diff_callback(ViewDiffCallback callback);
bool initialized() const { return !m_git_repo.is_null(); };
+ void change_repo(LexicalPath const& repo_root);
private:
explicit GitWidget(const LexicalPath& repo_root);
diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp
index 17b7363ba4..9ef2f5dc7a 100644
--- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp
+++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp
@@ -202,6 +202,10 @@ void HackStudioWidget::open_project(const String& root_path)
m_project_tree_view->set_model(m_project->model());
m_project_tree_view->update();
}
+ if (m_git_widget) {
+ m_git_widget->change_repo(LexicalPath(root_path));
+ m_git_widget->refresh();
+ }
if (Debugger::is_initialized()) {
auto& debugger = Debugger::the();
debugger.reset_breakpoints();