QTabWidget: Guard QTabBar in documentMode
While QTabBar is created by the QTabWidget and therefore doesn't need to be guarded, QTabBarPrivate::init calls QStyle::styleHint which might result in QStyleSheetStyle querying properties on the QTabWidget while its QTabBar isn't assigned yet. Pick-to: 6.9 6.8 6.5 Change-Id: Ic832d3253c5dc54d8d718760c63f34f0b8bde000 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
parent
f9a625eb8c
commit
61c2d3f101
@ -1361,7 +1361,8 @@ void QTabWidget::setUsesScrollButtons(bool useButtons)
|
||||
bool QTabWidget::documentMode() const
|
||||
{
|
||||
Q_D(const QTabWidget);
|
||||
return d->tabs->documentMode();
|
||||
// QStyleSheetStyle could query documentMode during creation of our QTabBar.
|
||||
return d->tabs ? d->tabs->documentMode() : false;
|
||||
}
|
||||
|
||||
void QTabWidget::setDocumentMode(bool enabled)
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include <QtWidgets/QSplitter>
|
||||
#include <QtWidgets/QStyle>
|
||||
#include <QtWidgets/QStyleFactory>
|
||||
#include <QtWidgets/QTabBar>
|
||||
#include <QtWidgets/QTabWidget>
|
||||
#include <QtWidgets/QTableWidget>
|
||||
#include <QtWidgets/QToolButton>
|
||||
#include <QtWidgets/QToolTip>
|
||||
@ -115,6 +117,7 @@ private slots:
|
||||
void appStyle();
|
||||
void QTBUG11658_cachecrash();
|
||||
void styleSheetTargetAttribute();
|
||||
void tabWidgetDocumentModeCrash();
|
||||
void unpolish();
|
||||
|
||||
void highdpiImages_data();
|
||||
@ -2331,6 +2334,16 @@ void tst_QStyleSheetStyle::styleSheetTargetAttribute()
|
||||
QCOMPARE(pb.testAttribute(Qt::WA_StyleSheetTarget), false);
|
||||
}
|
||||
|
||||
void tst_QStyleSheetStyle::tabWidgetDocumentModeCrash()
|
||||
{
|
||||
// Don't crash when matching accessing documentMode of QTabWidget while styling QTabBar.
|
||||
qApp->setStyleSheet("QTabWidget[documentMode=true] QTabBar { font-size: 40pt; }");
|
||||
|
||||
QTabWidget tabWidget;
|
||||
tabWidget.setDocumentMode(true);
|
||||
QCOMPARE(FONTSIZE(*tabWidget.tabBar()), 40);
|
||||
}
|
||||
|
||||
void tst_QStyleSheetStyle::unpolish()
|
||||
{
|
||||
QWidget w;
|
||||
|
Loading…
x
Reference in New Issue
Block a user