From anonymous, 5 Months ago, written in Diff-output.
Embed
  1. diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py
  2. index ac81eba29..320e6d5dd 100644
  3. --- a/qutebrowser/mainwindow/tabwidget.py
  4. +++ b/qutebrowser/mainwindow/tabwidget.py
  5. @@ -109,6 +109,7 @@ class TabWidget(QTabWidget):
  6.  
  7.          bar.set_tab_data(idx, 'pinned', pinned)
  8.          tab.data.pinned = pinned
  9. +
  10.          self.update_tab_favicon(tab)
  11.          self.update_tab_title(idx)
  12.  
  13. @@ -154,6 +155,7 @@ class TabWidget(QTabWidget):
  14.          # a size recalculation which is slow.
  15.          if tabbar.tabText(idx) != title:
  16.              tabbar.setTabText(idx, title)
  17. +            tabbar._pinned_statistics.cache_clear()
  18.  
  19.          # always show only plain title in tooltips
  20.          tabbar.setTabToolTip(idx, fields['title'])
  21. @@ -217,6 +219,7 @@ class TabWidget(QTabWidget):
  22.          """Update all texts."""
  23.          for idx in range(self.count()):
  24.              self.update_tab_title(idx)
  25. +        self.tabBar()._pinned_statistics.cache_clear()
  26.  
  27.      def tabInserted(self, idx):
  28.          """Update titles when a tab was inserted."""
  29. @@ -325,6 +328,8 @@ class TabWidget(QTabWidget):
  30.              if config.val.tabs.tabs_are_windows:
  31.                  self.window().setWindowIcon(self.window().windowIcon())
  32.  
  33. +        self.tabBar()._pinned_statistics.cache_clear()
  34. +
  35.  
  36.  class TabBar(QTabBar):
  37.  
  38. @@ -390,6 +395,7 @@ class TabBar(QTabBar):
  39.                        "tabs.indicator.width",
  40.                        "tabs.min_width",
  41.                        "tabs.pinned.shrink"]:
  42. +            self._pinned_statistics.cache_clear()
  43.              self._minimum_tab_size_hint_helper.cache_clear()
  44.  
  45.      def _on_show_switching_delay_changed(self):
  46. @@ -467,6 +473,7 @@ class TabBar(QTabBar):
  47.          self._set_icon_size()
  48.          # clear tab size cache
  49.          self._minimum_tab_size_hint_helper.cache_clear()
  50. +        self._pinned_statistics.cache_clear()
  51.  
  52.      def _set_icon_size(self):
  53.          """Set the tab bar favicon size."""
  54. @@ -564,6 +571,7 @@ class TabBar(QTabBar):
  55.              width = max(min_width, width)
  56.          return QSize(width, height)
  57.  
  58. +    @functools.lru_cache(maxsize=1)
  59.      def _pinned_statistics(self) -> (int, int):
  60.          """Get the number of pinned tabs and the total width of pinned tabs."""
  61.          pinned_list = [idx for idx in range(self.count())
  62. diff --git a/qutebrowser/misc/utilcmds.py b/qutebrowser/misc/utilcmds.py
  63. index 4b55eb04e..d9173ec82 100644
  64. --- a/qutebrowser/misc/utilcmds.py
  65. +++ b/qutebrowser/misc/utilcmds.py
  66. @@ -187,12 +187,15 @@ def debug_cache_stats():
  67.      # pylint: disable=protected-access
  68.      tab_bar = tabbed_browser.widget.tabBar()
  69.      tabbed_browser_info = tab_bar._minimum_tab_size_hint_helper.cache_info()
  70. +    tabbed_browser_pinned = tab_bar._pinned_statistics.cache_info()
  71.      # pylint: enable=protected-access
  72.  
  73.      log.misc.debug('is_valid_prefix: {}'.format(prefix_info))
  74.      log.misc.debug('_render_stylesheet: {}'.format(render_stylesheet_info))
  75.      log.misc.debug('history: {}'.format(history_info))
  76.      log.misc.debug('tab width cache: {}'.format(tabbed_browser_info))
  77. +    log.misc.debug('pinned tab statistic cache: {}'
  78. +                   .format(tabbed_browser_pinned))
  79.  
  80.  
  81.  @cmdutils.register(debug=True)
  82.