summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorBrandon Scott <xeons@users.noreply.github.com>2019-09-17 02:26:10 -0500
committerAndreas Kling <awesomekling@gmail.com>2019-09-17 09:26:10 +0200
commita4d52b122d9de5ae53bb70a42251680a0973ff15 (patch)
tree10af478006afbc210e74759c89447a0619a6e45f /Applications
parentcaf1b37e757ab47a17750da4d594e3d4ae2bc6ae (diff)
downloadserenity-a4d52b122d9de5ae53bb70a42251680a0973ff15.zip
FileManager+LibGUI: Fix two folder-related crashes (#569)
Fix a crash when opening a folder, and another one when trying to open a newly created folder. It was not safe to modify a GModelSelection while it's being iterated over. Fixes #536.
Diffstat (limited to 'Applications')
-rw-r--r--Applications/FileManager/main.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp
index 14361c69b7..312f67ded3 100644
--- a/Applications/FileManager/main.cpp
+++ b/Applications/FileManager/main.cpp
@@ -104,6 +104,20 @@ int main(int argc, char** argv)
if (rc < 0) {
GMessageBox::show(String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window);
} else {
+ file_system_model->update();
+
+ auto current_path = directory_view->path();
+
+ // not exactly sure why i have to reselect the root node first, but the index() fails if I dont
+ auto root_index = file_system_model->index(file_system_model->root_path());
+ tree_view->selection().set(root_index);
+
+ // reselect the existing folder in the tree
+ auto new_index = file_system_model->index(current_path);
+ tree_view->selection().set(new_index);
+ tree_view->scroll_into_view(new_index, Orientation::Vertical);
+ tree_view->update();
+
directory_view->refresh();
}
}