Consistently test for nullptr
m_view might be nullptr, which is checked before setting up the palette, so don't set the QTextCharFormat up without checking first as well. Fixes static analyzer warning 0ef07dd07bebe04b93d1fc802eddb57a Pick-to: 6.1 Change-Id: Ia1c92eb4183c9e368e92875775cff90e2883ddaf Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
This commit is contained in:
parent
735466ed2b
commit
e38b55c47c
@ -1111,16 +1111,17 @@ QTextCharFormat QCalendarModel::formatForCell(int row, int col) const
|
|||||||
{
|
{
|
||||||
QPalette pal;
|
QPalette pal;
|
||||||
QPalette::ColorGroup cg = QPalette::Active;
|
QPalette::ColorGroup cg = QPalette::Active;
|
||||||
|
QTextCharFormat format;
|
||||||
|
|
||||||
if (m_view) {
|
if (m_view) {
|
||||||
pal = m_view->palette();
|
pal = m_view->palette();
|
||||||
if (!m_view->isEnabled())
|
if (!m_view->isEnabled())
|
||||||
cg = QPalette::Disabled;
|
cg = QPalette::Disabled;
|
||||||
else if (!m_view->isActiveWindow())
|
else if (!m_view->isActiveWindow())
|
||||||
cg = QPalette::Inactive;
|
cg = QPalette::Inactive;
|
||||||
|
format.setFont(m_view->font());
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextCharFormat format;
|
|
||||||
format.setFont(m_view->font());
|
|
||||||
bool header = (m_weekNumbersShown && col == HeaderColumn)
|
bool header = (m_weekNumbersShown && col == HeaderColumn)
|
||||||
|| (m_horizontalHeaderFormat != QCalendarWidget::NoHorizontalHeader && row == HeaderRow);
|
|| (m_horizontalHeaderFormat != QCalendarWidget::NoHorizontalHeader && row == HeaderRow);
|
||||||
format.setBackground(pal.brush(cg, header ? QPalette::AlternateBase : QPalette::Base));
|
format.setBackground(pal.brush(cg, header ? QPalette::AlternateBase : QPalette::Base));
|
||||||
|
Loading…
Reference in New Issue
Block a user