diff options
-rw-r--r-- | qutebrowser/mainwindow/tabwidget.py | 4 | ||||
-rw-r--r-- | qutebrowser/mainwindow/treetabwidget.py | 29 |
2 files changed, 14 insertions, 19 deletions
diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 4dfdb541b..2ac7cb6d4 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -54,6 +54,7 @@ class TabWidget(QTabWidget): def __init__(self, win_id, parent=None): super().__init__(parent) + self._tabbed_browser = parent bar = TabBar(win_id, self) self.setStyle(TabBarStyle()) self.setTabBar(bar) @@ -140,6 +141,9 @@ class TabWidget(QTabWidget): if self._tab_title_update_disabled: return + if self._tabbed_browser.is_shutting_down: + return + assert idx != -1 tab = self._tab_by_idx(idx) assert tab is not None diff --git a/qutebrowser/mainwindow/treetabwidget.py b/qutebrowser/mainwindow/treetabwidget.py index 83a409b2a..8534a6283 100644 --- a/qutebrowser/mainwindow/treetabwidget.py +++ b/qutebrowser/mainwindow/treetabwidget.py @@ -39,25 +39,16 @@ class TreeTabWidget(TabWidget): rendered_tree = self.tree_root.render() - # We can be called when the count of tabs in the widget is different - # to the size of the rendered tree. This is known to happen when - # hiding a tree group with multiple tabs in it. render() will reflect - # the final state right away but we get called for every removal or - # insertion from the tab widget while update_tree_tab_visibility() is - # traversing through the tree group to update the widget. - # There may be other cases when this happens that we would be - # swallowing here. To avoid that, since we get called via - # update_tab_titles() possibly it would be cleanest to add an - # attribute to TabWidget (or a context manager) to disabled tab title - # updates and set that while calling - # update_tree_tab_{visibility,positions} in tree_tab_update(). - miscount = len(rendered_tree) - 1 - self.count() - if miscount < 0: - log.misc.error(f"Less nodes in tree than widget. Are we collapsing tabs? {idx=} {miscount=} {fields['current_url']=}") - return fields - elif miscount > 0: - log.misc.error(f"More nodes in tree than widget. Are we revealing tabs? {idx=} {miscount=} {fields['current_url']=}") - return fields + # We are getting called with an index into the tab bar. If we have a + # different amount of nodes in the tree than the tab bar that + # indicates a logic error. + difference = len(rendered_tree) - 1 - self.count() + if difference != 0: + tabs = [str(self.widget(idx)) for idx in range(self.count())] + assert difference == 0, ( + "Different amount of nodes in tree than widget. " + f"difference={difference} tree={rendered_tree[1:]} tabs={tabs}" + ) # we remove the first two chars because every tab is child of tree # root and that gets rendered as well |