From: Janet Blackquill Date: Thu, 3 Mar 2022 15:57:53 +0000 (-0500) Subject: KItemListHeaderWidget: don't crash if widget == nullptr X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/e8dc49e4b24f5805d0664fcf842ab7b94af4a013 KItemListHeaderWidget: don't crash if widget == nullptr BUG: 449238 --- diff --git a/src/kitemviews/private/kitemlistheaderwidget.cpp b/src/kitemviews/private/kitemlistheaderwidget.cpp index 5fb929e52..329e1da56 100644 --- a/src/kitemviews/private/kitemlistheaderwidget.cpp +++ b/src/kitemviews/private/kitemlistheaderwidget.cpp @@ -417,12 +417,14 @@ void KItemListHeaderWidget::paintRole(QPainter* painter, int orderIndex, QWidget* widget) const { + const auto direction = widget ? widget->layoutDirection() : qApp->layoutDirection(); + // The following code is based on the code from QHeaderView::paintSection(). // SPDX-FileCopyrightText: 2011 Nokia Corporation and/or its subsidiary(-ies). QStyleOptionHeader option; - option.direction = widget->layoutDirection(); + option.direction = direction; option.textAlignment = - widget->layoutDirection() == Qt::LeftToRight + direction == Qt::LeftToRight ? Qt::AlignLeft : Qt::AlignRight;