From 810088ed69c8e5eed92a260a208db61d1b48f7ac Mon Sep 17 00:00:00 2001 From: toofar Date: Fri, 9 Feb 2024 14:12:00 +1300 Subject: Fix another possible tree and widget desync while loading a session In 3ec2000b2f1c I identified a few cases where we could be asked to call into the tree structure based on a widget index with evidence that the tree and widget where out of sync. In particular where there were a different amount of items in each. Previously I had ignored desyncs during session loads but now I've found a case where the desync remains after the session was loaded, for a short time. It can be reproduced (most of the time) with: python3 -m qutebrowser -T -s tabs.tree_tabs true ":open about:blank?1" ":open -tr about:blank?2" ":open -tr about:blank?3" ":tab-focus 2" ":tree-tab-toggle-hide" ":cmd-later 200 session-save foo" ":cmd-later 300 session-load -c foo" This only happens if the last set of tabs we open is a collapsed group. There would have been no update event fired since we set the collapsed attribute. If this issue shows up again a more robust approach might be to not set the collapsed attribute in the loop, but load all the tabs visible then go and set the collapsed attribute on all the nodes that need it and fire an update. I initially reproduced this with the "Load a collapsed subtree" end2end test. --- qutebrowser/misc/sessions.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qutebrowser/misc/sessions.py b/qutebrowser/misc/sessions.py index df3b028f7..35c36f203 100644 --- a/qutebrowser/misc/sessions.py +++ b/qutebrowser/misc/sessions.py @@ -554,6 +554,13 @@ class SessionManager(QObject): child = recursive_load_node(child_uid) child.parent = root_node + # Make sure any collapsed tabs are removed from the widget. + # Since we only set the "collapsed" attribute after loading the tab, + # and the tree only gets updated in the above loop on tab loads. So if + # the last set of tabs we load is a collapsed group this children + # won't know they are support to be hidden yet. + tabbed_browser.widget.tree_tab_update() + return tab_to_focus def _load_legacy_tree_tabs(self, win, tabbed_browser): -- cgit v1.2.3-54-g00ecf