Skip to content

Commit

Permalink
Disconnect tabMoved signal for performance
Browse files Browse the repository at this point in the history
tree-tab-collapse in particular was very slow because update_tab_titles
was called undreds of times for large trees.
  • Loading branch information
pinusc committed May 14, 2019
1 parent a05d82a commit b8d9622
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions qutebrowser/mainwindow/tabwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ def __init__(self, win_id, parent=None):
self.setStyle(TabBarStyle())
self.setTabBar(bar)
bar.tabCloseRequested.connect(self.tabCloseRequested)
bar.tabMoved.connect(functools.partial(
QTimer.singleShot, 0, self.update_tab_titles))
bar.tabMoved.connect(self.update_tab_titles)
bar.currentChanged.connect(self._on_current_changed)
bar.new_tab_requested.connect(self._on_new_tab_requested)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
Expand Down Expand Up @@ -249,6 +248,7 @@ def _toggle_visibility(self):

def update_tab_titles(self):
"""Update all texts."""
log.misc.debug('update_tab_titles')
with self._toggle_visibility():
for idx in range(self.count()):
self.update_tab_title(idx)
Expand Down
3 changes: 2 additions & 1 deletion qutebrowser/mainwindow/treetabwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, win_id, parent=None):
# root of the tab tree, common for all tabs in the window
self.tree_root = Node(None)
super().__init__(win_id, parent)
self.tabBar().tabMoved.disconnect(self.update_tab_titles)

def _init_config(self):
super()._init_config()
Expand Down Expand Up @@ -72,8 +73,8 @@ def update_tree_tab_positions(self):

def tree_tab_update(self):
"""Update titles and positions."""
self.update_tab_titles()
self.update_tree_tab_positions()
self.update_tab_titles()

def tabRemoved(self, idx):
"""Call tree_tab_update after super().tabRemoved."""
Expand Down

0 comments on commit b8d9622

Please sign in to comment.