From 41edacd10c4cd4241ad0cc735034e9df86bf32da Mon Sep 17 00:00:00 2001 From: Szymon Tomasz Stefanek Date: Wed, 9 Feb 2011 22:42:27 +0000 Subject: Maybe fix #1093 git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5443 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/modules/list/ListWindow.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') 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(treeWidget->itemFromIndex(index)); + + if(!item) + return QSize(100,iHeight); + QFontMetrics fm(sovItem.font); switch(index.column()) { -- cgit v1.3.1-10-gc9f91