From 6340eee4488d9a2d51a5cb29cc9d34e6f984aa23 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 29 Nov 2016 09:33:27 +0100 Subject: [PATCH] Handle invalid text layout when drawing tab --- qutebrowser/mainwindow/tabwidget.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index c43b805c6..de65fa280 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -27,7 +27,7 @@ from PyQt5.QtWidgets import (QTabWidget, QTabBar, QSizePolicy, QCommonStyle, QStyle, QStylePainter, QStyleOptionTab) from PyQt5.QtGui import QIcon, QPalette, QColor -from qutebrowser.utils import qtutils, objreg, utils, usertypes +from qutebrowser.utils import qtutils, objreg, utils, usertypes, log from qutebrowser.config import config @@ -607,6 +607,10 @@ class TabBarStyle(QCommonStyle): widget: QWidget """ layouts = self._tab_layout(opt) + if layouts is None: + log.misc.warning("Could not get layouts for tab!") + return + if element == QStyle.CE_TabBarTab: # We override this so we can control TabBarTabShape/TabBarTabLabel. self.drawControl(QStyle.CE_TabBarTabShape, opt, p, widget) @@ -692,8 +696,11 @@ class TabBarStyle(QCommonStyle): indicator_padding = config.get('tabs', 'indicator-padding') text_rect = QRect(opt.rect) + if not text_rect.isValid(): + # This happens sometimes according to crash reports, but no idea + # why... + return None - qtutils.ensure_valid(text_rect) text_rect.adjust(padding.left, padding.top, -padding.right, -padding.bottom)