summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2020-07-11 18:28:06 -0400
committerAndreas Kling <kling@serenityos.org>2020-07-13 14:27:23 +0200
commit366d7e6d0560607fd86256a282678087f2ee7d8f (patch)
tree7caf9637eabefccac48a52030a92675c72977e84 /Libraries
parentf1bbc39148cad2c3bb51cca0b6282378ecc9bfe6 (diff)
downloadserenity-366d7e6d0560607fd86256a282678087f2ee7d8f.zip
LibGUI: Only report toggled directories once on subtree collapse/expansion
This prevents redundant calls to on_toggle for the same indices when subtrees are collapsed or expanded.
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibGUI/TreeView.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/Libraries/LibGUI/TreeView.cpp b/Libraries/LibGUI/TreeView.cpp
index c3bbda16f9..76b5022f04 100644
--- a/Libraries/LibGUI/TreeView.cpp
+++ b/Libraries/LibGUI/TreeView.cpp
@@ -110,13 +110,16 @@ void TreeView::doubleclick_event(MouseEvent& event)
void TreeView::set_open_state_of_all_in_subtree(const ModelIndex& root, bool open)
{
- if (root.is_valid())
+ if (root.is_valid()) {
ensure_metadata_for_index(root).open = open;
+ if (model()->row_count(root)) {
+ if (on_toggle)
+ on_toggle(root, open);
+ }
+ }
int row_count = model()->row_count(root);
int column = model()->tree_column();
for (int row = 0; row < row_count; ++row) {
- if (on_toggle)
- on_toggle(root, open);
auto index = model()->index(row, column, root);
set_open_state_of_all_in_subtree(index, open);
}