Browse Source

LibGUI: Fetch data on a Node before traversing it, instead of after

Before this it wouldn't be possible to make decisions in
Node::traverse_if_needed based on the Node data because it would be
invalid.
Adam Harald Jørgensen 1 year ago
parent
commit
4d3c06ffe3
1 changed files with 2 additions and 3 deletions
  1. 2 3
      Userland/Libraries/LibGUI/FileSystemModel.cpp

+ 2 - 3
Userland/Libraries/LibGUI/FileSystemModel.cpp

@@ -185,10 +185,9 @@ OwnPtr<FileSystemModel::Node> FileSystemModel::Node::create_child(DeprecatedStri
 
 
 void FileSystemModel::Node::reify_if_needed()
 void FileSystemModel::Node::reify_if_needed()
 {
 {
+    if (mode == 0)
+        fetch_data(full_path(), m_parent == nullptr || m_parent->m_parent_of_root);
     traverse_if_needed();
     traverse_if_needed();
-    if (mode != 0)
-        return;
-    fetch_data(full_path(), m_parent == nullptr || m_parent->m_parent_of_root);
 }
 }
 
 
 bool FileSystemModel::Node::is_symlink_to_directory() const
 bool FileSystemModel::Node::is_symlink_to_directory() const