From b0691b5a95c80ecd94867873e912e6952a2ec1b4 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Fri, 19 Nov 2010 12:45:46 +0200 Subject: QS60Style: Null pointer crash when using itemviews in some cases QS60Style attempts to use null pointer when drawing CE_ItemViewItem, if the parameter widget is provided as null. This leads to, for example, Chart example app crash in startup. Reviewed-by: Janne Anttila --- src/gui/styles/qs60style.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 5fe9050..22cb7d6 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1438,10 +1438,11 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, const QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &voptAdj, widget); QRect textRect = subElementRect(SE_ItemViewItemText, &voptAdj, widget); const QAbstractItemView *itemView = qobject_cast(widget); - const bool singleSelection = - (itemView->selectionMode() == QAbstractItemView::SingleSelection || - itemView->selectionMode() == QAbstractItemView::NoSelection); - const bool selectItems = (itemView->selectionBehavior() == QAbstractItemView::SelectItems); + + const bool singleSelection = itemView && + ((itemView->selectionMode() == QAbstractItemView::SingleSelection || + itemView->selectionMode() == QAbstractItemView::NoSelection)); + const bool selectItems = itemView && (itemView->selectionBehavior() == QAbstractItemView::SelectItems); // draw themed background for itemview unless background brush has been defined. if (vopt->backgroundBrush == Qt::NoBrush) { -- cgit v0.12