From 8d489a40e46f95af252cb8c5bd3d2046787a6f9c Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 30 Sep 2018 21:53:19 +0200 Subject: [PATCH] Simplify toggle_visibility --- qutebrowser/mainwindow/tabwidget.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 5a70304db..e221a8c24 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -216,7 +216,7 @@ class TabWidget(QTabWidget): return fields @contextlib.contextmanager - def _toggle_visibility(self, force_toggle=False): + def _toggle_visibility(self): """Toggle visibility while running. Every single call to setTabText calls the size hinting functions for @@ -224,18 +224,15 @@ class TabWidget(QTabWidget): the tab's titles, we can delay this processing by making the tab non-visible. To avoid flickering, disable repaint updates whlie we work. - - Args: - force_toggle: Whether to always force the toggle, or only do it - if we have enough tabs for it to matter """ - if self.count() > 10: - force_toggle = True - if force_toggle: + toggle = self.count() > 10 + if toggle: self.setUpdatesEnabled(False) self.setVisible(False) + yield - if force_toggle: + + if toggle: self.setVisible(True) self.setUpdatesEnabled(True)