Bug 176555

Summary: patch - dolphin crashes when pressing * in tree view
Product: [Unmaintained] kio Reporter: Sergio Martins <smartins>
Component: generalAssignee: David Faure <faure>
Status: RESOLVED FIXED    
Severity: crash CC: torkil
Priority: NOR    
Version: 4.1   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: patch

Description Sergio Martins 2008-11-30 17:10:21 UTC
Version:            (using Devel)
OS:                Linux
Installed from:    Compiled sources

Steps to reproduce:
1. In dolphin choose Details view
2. Go to options and make sure you have "Expanded Folders" selected

Now that you have a tree view, select a folder, and press * a couple of times (* make all the nodes expand) until dolphin crashes.

The problem is in kdelibs/kio/kio/kdirmodel.cpp inside KDirModel::rowCount

This cast isn't safe:
KDirModelDirNode* parentNode = static_cast<KDirModelDirNode *>(d->nodeForIndex(parent))

because we can't be sure if the node is a KDirModelDirNode, sometimes it isn't.


Here's a patch, please review it since i'm still a newbie in this kde qt stuff :D
Comment 1 Sergio Martins 2008-11-30 17:13:11 UTC
Created attachment 28952 [details]
patch
Comment 2 David Faure 2008-12-02 15:12:06 UTC
Very good analysis of the problem.
Your suggested patch calls nodeForIndex 3 times though, I'll change it to only call it once. Thanks.
Comment 3 David Faure 2008-12-02 15:36:01 UTC
SVN commit 891650 by dfaure:

Fix crash when rowCount is called on a file, like when typing '*' in a treeview.
BUG: 176555


 M  +5 -1      kio/kdirmodel.cpp  
 M  +4 -0      tests/kdirmodeltest.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=891650
Comment 4 Peter Penz 2008-12-02 15:41:35 UTC
*** Bug 34399 has been marked as a duplicate of this bug. ***