From e746325d9e4f1dc1d56155eb487436bcaa4f19e3 Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Thu, 27 Sep 2018 20:22:16 -0700 Subject: [PATCH] Turn off visibility of tabs while updating titles Improves performance dramatically when all titles change at once, such as when the first tab is removed. --- qutebrowser/mainwindow/tabwidget.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 751a294c3..928f1079a 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -216,8 +216,17 @@ class TabWidget(QTabWidget): def update_tab_titles(self): """Update all texts.""" + # Every single call to setTabText calls the size hinting functions for + # every single tab, which are slow. Since we know we are updating all + # the tab's titles, we can delay this processing by making the tab + # non-visible. To avoid flickering, disable repaint updates whlie we + # work. + self.setUpdatesEnabled(False) + self.setVisible(False) for idx in range(self.count()): self.update_tab_title(idx) + self.setVisible(True) + self.setUpdatesEnabled(True) def tabInserted(self, idx): """Update titles when a tab was inserted."""