aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/list
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/list')
-rw-r--r--src/modules/list/ListWindow.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/modules/list/ListWindow.cpp b/src/modules/list/ListWindow.cpp
index ce760e5ba..4621393c5 100644
--- a/src/modules/list/ListWindow.cpp
+++ b/src/modules/list/ListWindow.cpp
@@ -112,9 +112,20 @@ ChannelTreeWidgetItemDelegate::~ChannelTreeWidgetItemDelegate()
QSize ChannelTreeWidgetItemDelegate::sizeHint( const QStyleOptionViewItem &sovItem, const QModelIndex &index) const
{
ChannelTreeWidget* treeWidget = (ChannelTreeWidget*)parent();
- ChannelTreeWidgetItem * item = (ChannelTreeWidgetItem*)treeWidget->itemFromIndex(index);
int iHeight=treeWidget->fontMetrics().lineSpacing();
+ // Model-View-Delegate-Crappiness...
+ //
+ // This function is called when items aren't fully constructed. In particular
+ // when the ChannelTreeWidgetItem constructor calls the base class constructor
+ // this function is sometimes called with the newly inserted item which is not
+ // a ChannelTreeWidgetItem yet.
+
+ ChannelTreeWidgetItem * item = dynamic_cast<ChannelTreeWidgetItem*>(treeWidget->itemFromIndex(index));
+
+ if(!item)
+ return QSize(100,iHeight);
+
QFontMetrics fm(sovItem.font);
switch(index.column())
{