Commit 109c10c2 authored by David Faure's avatar David Faure

Replace assert with early return, in case the collection was deleted meanwhile.

Another comment in the same file says
 // Do not assert on invalid collections, since a collection may be deleted
 // in the meantime and deleted collections are invalid.
Therefore it looks like this is expected.
parent e4c181f2
...@@ -208,7 +208,7 @@ void CollectionStatisticsDelegate::paint(QPainter *painter, ...@@ -208,7 +208,7 @@ void CollectionStatisticsDelegate::paint(QPainter *painter,
// in initStyleOption(), which gets called by QStyledItemDelegate::paint(). // in initStyleOption(), which gets called by QStyledItemDelegate::paint().
QStyledItemDelegate::paint(painter, option, index); QStyledItemDelegate::paint(painter, option, index);
// No, we retrieve the correct style option by calling intiStyleOption from // Now, we retrieve the correct style option by calling initStyleOption from
// the superclass. // the superclass.
QStyleOptionViewItemV4 option4 = option; QStyleOptionViewItemV4 option4 = option;
QStyledItemDelegate::initStyleOption(&option4, index); QStyledItemDelegate::initStyleOption(&option4, index);
...@@ -235,10 +235,9 @@ void CollectionStatisticsDelegate::paint(QPainter *painter, ...@@ -235,10 +235,9 @@ void CollectionStatisticsDelegate::paint(QPainter *painter,
if (!collection.isValid()) { if (!collection.isValid()) {
qCCritical(AKONADIWIDGETS_LOG) << "Invalid collection: " << collection; qCCritical(AKONADIWIDGETS_LOG) << "Invalid collection: " << collection;
return;
} }
Q_ASSERT(collection.isValid()); // TODO: I seem to hit this when removing a duplicated "Personal Contacts" or "Personal Calendar"
CollectionStatistics statistics = collection.statistics(); CollectionStatistics statistics = collection.statistics();
qint64 unreadCount = qMax(0LL, statistics.unreadCount()); qint64 unreadCount = qMax(0LL, statistics.unreadCount());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment