┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kstandarditemlistwidget.cpp
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2012-09-11 19:34:23 +0200
committerFrank Reininghaus <[email protected]>2012-09-11 19:34:23 +0200
commit7de641316a40ac1b570f66e5ca4109fe0b6f6702 (patch)
treec5670cadc85126c3e7eff3d6006235d4e597a4fa /src/kitemviews/kstandarditemlistwidget.cpp
parentf9ba9a7236a0252a54a51b2f70a04ab13c68f85b (diff)
Fix possible crash in KStandardItemListWidget::paint()
According to the backtrace in the bug report, it is possible that KStandardItemListWidget::paint() is called if the hash m_textInfo has not been initialised. The widget's index must be -1 in this case, see KStandardItemListWidget::triggerCacheRefreshing(). It looks like this can only happen if the item is about to be removed from the view, see KItemListView::slotItemsRemoved(). I could not reproduce the crash, so I'm not sure why exactly this happens, but this commit should at least prevent the crash. BUG: 306167 FIXED-IN: 4.9.2
Diffstat (limited to 'src/kitemviews/kstandarditemlistwidget.cpp')
-rw-r--r--src/kitemviews/kstandarditemlistwidget.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp
index 7ae7e2efc..72d10cf40 100644
--- a/src/kitemviews/kstandarditemlistwidget.cpp
+++ b/src/kitemviews/kstandarditemlistwidget.cpp
@@ -263,6 +263,16 @@ void KStandardItemListWidget::paint(QPainter* painter, const QStyleOptionGraphic
painter->setFont(m_customizedFont);
painter->setPen(m_isHidden ? m_additionalInfoTextColor : textColor());
const TextInfo* textInfo = m_textInfo.value("text");
+
+ if (!textInfo) {
+ // It seems that we can end up here even if m_textInfo does not contain
+ // the key "text", see bug 306167. According to triggerCacheRefreshing(),
+ // this can only happen if the index is negative. This can happen when
+ // the item is about to be removed, see KItemListView::slotItemsRemoved().
+ // TODO: try to reproduce the crash and find a better fix.
+ return;
+ }
+
painter->drawStaticText(textInfo->pos, textInfo->staticText);
bool clipAdditionalInfoBounds = false;