diff options
author | Jay Kamat <jaygkamat@gmail.com> | 2017-10-20 16:35:11 -0400 |
---|---|---|
committer | Florian Bruhin <git@the-compiler.org> | 2017-10-31 07:06:55 +0100 |
commit | 0045af8738525a9618b863d141ec76736ee72b6c (patch) | |
tree | b9c82e4c0f1367c7ed2faf3bc263e4ed36e940e3 | |
parent | 7dc82407e8237ff9dc92d0d1873103cb3bc67c03 (diff) | |
download | qutebrowser-0045af8738525a9618b863d141ec76736ee72b6c.tar.gz qutebrowser-0045af8738525a9618b863d141ec76736ee72b6c.zip |
Clear cache on config changes
(cherry picked from commit fde4495bc795699aa413892fe30b5390b8592f99)
-rw-r--r-- | qutebrowser/mainwindow/tabwidget.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 56f5fd91f..ab261f1d6 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -310,7 +310,7 @@ class TabBar(QTabBar): return self.parent().currentWidget() @pyqtSlot(str) - def _on_config_changed(self, option): + def _on_config_changed(self, option: str): if option == 'fonts.tabs': self._set_font() elif option == 'tabs.favicons.scale': @@ -325,6 +325,12 @@ class TabBar(QTabBar): if option.startswith('colors.tabs.'): self.update() + # Clear _minimum_tab_size_hint_helper cache when appropriate + if option in ["tabs.indicator_padding", + "tabs.padding", + "tabs.width.indicator"]: + self._minimum_tab_size_hint_helper.cache_clear() + def _on_show_switching_delay_changed(self): """Set timer interval when tabs.show_switching_delay got changed.""" self._auto_hide_timer.setInterval(config.val.tabs.show_switching_delay) @@ -442,7 +448,12 @@ class TabBar(QTabBar): def _minimum_tab_size_hint_helper(self, tab_text: str, icon, ellipsis: bool) -> QSize: - """Helper function to cache tab results.""" + """Helper function to cache tab results. + + Acessing config values in here should be added to _on_config_changed to + ensure cache is flushed when needed. + """ + print("running!") text = '\u2026' if ellipsis else tab_text # Don't ever shorten if text is shorter than the ellipsis text_width = min(self.fontMetrics().width(text), |