Skip to content

Commit

Permalink
Make sure the pointer captured by lambda is not null before we work w…
Browse files Browse the repository at this point in the history
…ith it
  • Loading branch information
grulja committed May 14, 2020
1 parent 06cfac2 commit 804939b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions style/adwaitastyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QAbstractItemView *>(widget)) {
QWindow *win = widget ? widget->window()->windowHandle() : nullptr;
if (QPointer<QAbstractItemView> view = qobject_cast<QAbstractItemView *>(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));
Expand Down

0 comments on commit 804939b

Please sign in to comment.