From 804939babf8304794f583f8b9ca93c7f856d4248 Mon Sep 17 00:00:00 2001 From: Jan Grulich Date: Thu, 14 May 2020 20:30:35 +0200 Subject: [PATCH] Make sure the pointer captured by lambda is not null before we work with it --- style/adwaitastyle.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/style/adwaitastyle.cpp b/style/adwaitastyle.cpp index 0fb22ea6..c50078f3 100644 --- a/style/adwaitastyle.cpp +++ b/style/adwaitastyle.cpp @@ -409,10 +409,14 @@ void Style::polish(QWidget *widget) #if QT_VERSION > 0x050000 // HACK to avoid different text color in unfocused views - if (QAbstractItemView *view = qobject_cast(widget)) { - QWindow *win = widget ? widget->window()->windowHandle() : nullptr; + if (QPointer view = qobject_cast(widget)) { + QWindow *win = widget ? widget->window()->windowHandle() : nullptr; if (win) { connect(win, &QWindow::activeChanged, this, [=] () { + if (view.isNull()) { + return; + } + QPalette pal = view->palette(); if (win->isActive()) { pal.setColor(QPalette::Inactive, QPalette::Text, pal.color(QPalette::Active, QPalette::Text));