Repository: qutebrowser/qutebrowser

Issue:
Empty space after the last tab
<!-- If this is a bug report, please remember to mention your version info from
the `qute:version` page or `qutebrowser --version` -->
Right after the last tab there's an empty space (occupying as much space as a single tab).  
It doesn't exist when there are fewer tabs (right now I have 48 open).

I just opened 50 empty tabs in a new window and there is no space there. Perhaps the tab-icons mess up here (because they force a minimal width for a tab, while the browser thinks a tab is e.g. 4px wide)?

I can post a screenshot but it seems unnecesarry for just an empty silver box.


Discussion:
I've seen this some while back, but only with a few pixels. Please post a screenshot so we can be sure we're talking about the same thing.

Also, does it change colors when you change `colors -> tabs.bg.bar`? Can you reproduce it with `--temp-basedir`?
![img](https://cloud.githubusercontent.com/assets/11772321/21596382/0ebe9e7e-d143-11e6-88bb-e37494bfabd4.png)
![img](https://cloud.githubusercontent.com/assets/11772321/21596381/0ebe2426-d143-11e6-9d8b-e89ac2c6e2ea.png)
The same happens with `--temp-basedir`.

**But**  
[[ running with --temp-basedir ]] if I change the startpage to e.g. "blank", the blank space doesn't show up even with 60 tabs (all of them showing "host blank not found" or something). If the startpage is duckduck, the space appears when I open the 35th tab. As soon as the number of tabs is <=34, it disappears (all the tabs running duckduck)

If I resize the window and make it shorter the blank space appears on the 27th tab. If it matters, according to xprop the window is 800 pixels wide.
I think I found something interesting. If I open e.g. 20 clones of the `:help` page and then start opening duckduck-s, the blank space appears even further - on the 52th tab. (fullscreen)  
I think this helps because the help-tabs are much shorter due to the lack of icons there:
![image](https://cloud.githubusercontent.com/assets/11772321/21596751/398b2a50-d148-11e6-939a-fd71c783078a.png)  

(with --temp-basedir)
Yep, I've definitely seen this happen for a while, and at least back then I wasn't able to figure out what's causing it. I should probably take another look some time with a bit more Qt experience now.
Closing this in favor of #2746, as that has more information about why this happens.

Resolving patch:
diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py
--- a/qutebrowser/mainwindow/tabwidget.py
+++ b/qutebrowser/mainwindow/tabwidget.py
@@ -760,6 +760,19 @@ def subElementRect(self, sr, opt, widget=None):
             rct = super().subElementRect(sr, opt, widget)
             return rct
         else:
+            try:
+                # We need this so the left scroll button is aligned properly.
+                # Otherwise, empty space will be shown after the last tab even
+                # though the button width is set to 0
+                #
+                # In older PyQt-versions (5.2.1) QStyle does not have this
+                # attribute.
+                if sr == QStyle.SE_TabBarScrollLeftButton:
+                    return super().subElementRect(sr, opt, widget)
+
+            except AttributeError:
+                pass
+
             return self._style.subElementRect(sr, opt, widget)
 
     def _tab_layout(self, opt):


Test patch: