]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix possible crash in KStandardItemListWidget::paint()
authorFrank Reininghaus <frank78ac@googlemail.com>
Tue, 11 Sep 2012 17:34:23 +0000 (19:34 +0200)
committerFrank Reininghaus <frank78ac@googlemail.com>
Tue, 11 Sep 2012 17:34:23 +0000 (19:34 +0200)
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

src/kitemviews/kstandarditemlistwidget.cpp

index 7ae7e2efcffc2f68c72a05cdbc3b29abc4c3aff4..72d10cf40e29059731e2338d2c8c699f54c21eaf 100644 (file)
@@ -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;