summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Kittler <mariuskittler@gmx.de>2024-04-12 10:26:33 +0200
committerMarius Kittler <mariuskittler@gmx.de>2024-04-22 14:48:50 +0000
commit30061e8960eb9d8abb8a98270e3e92beef60d7d3 (patch)
treef15b0818891704754eeb4e125a00964764b81af0
parent840cc2a6d8d19b3c96996dd0d471a43a84987e53 (diff)
Avoid crash with Windows 11 style when no widget passed
The documentation of `QStyle::drawControl()` states that "The widget argument is optional" so it must not be used unconditionally. Pick-to: 6.7 Change-Id: I8b5a8ed421c0ae2c667925e448c9a029b6deedfd Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
-rw-r--r--src/plugins/styles/modernwindows/qwindows11style.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp
index 51efdc24a0..a79aac76ef 100644
--- a/src/plugins/styles/modernwindows/qwindows11style.cpp
+++ b/src/plugins/styles/modernwindows/qwindows11style.cpp
@@ -1629,7 +1629,7 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
if ((vopt->state & State_Selected || vopt->state & State_MouseOver) && !(isTreeView && vopt->state & State_MouseOver) && vopt->showDecorationSelected) {
painter->setBrush(WINUI3Colors[colorSchemeIndex][subtleHighlightColor]);
- QWidget *editorWidget = view->indexWidget(view->currentIndex());
+ QWidget *editorWidget = view ? view->indexWidget(view->currentIndex()) : nullptr;
if (editorWidget) {
QPalette pal = editorWidget->palette();
QColor editorBgColor = vopt->backgroundBrush == Qt::NoBrush ? vopt->palette.color(widget->backgroundRole()) : vopt->backgroundBrush.color();
@@ -1682,7 +1682,7 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
vopt->icon.paint(painter, iconRect, vopt->decorationAlignment, mode, state);
painter->setPen(QPen(option->palette.buttonText().color()));
- if (!view->isPersistentEditorOpen(vopt->index))
+ if (!view || !view->isPersistentEditorOpen(vopt->index))
d->viewItemDrawText(painter, vopt, textRect);
if (vopt->state & State_Selected
&& (vopt->viewItemPosition == QStyleOptionViewItem::Beginning