Bug 159369

Summary: KCategorizedView segfaults without a proxy model or category drawer
Product: [Frameworks and Libraries] kdelibs Reporter: David Benjamin <davidben>
Component: kdeuiAssignee: Rafael Fernández López <ereslibre>
Status: RESOLVED FIXED    
Severity: crash CC: kdelibs-bugs
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: fix crashes when m_proxyModel is NULL
Test case for proxy model

Description David Benjamin 2008-03-15 19:34:24 UTC
Version:            (using Devel)
Installed from:    Compiled sources
OS:                Linux

I was playing with KCategorizedView and noticed that it crashes with a segfault when the supplied model is not a KCategorizedSortFilterProxyModel (and thus m_proxyModel is NULL). The crashes occur when one single-clicks an entry, or double-clicks to rename it.

(There are parts of the code that check of m_proxyModel is NULL, so I assume this usage of the class is meant to be valid.)

Patch attached below.

The same also occurs when no KCategoryDrawer is supplied, but I'm not sure how to fix that.
Comment 1 David Benjamin 2008-03-15 19:35:01 UTC
Created attachment 23910 [details]
fix crashes when m_proxyModel is NULL
Comment 2 David Benjamin 2008-03-15 19:37:05 UTC
Created attachment 23911 [details]
Test case for proxy model

Remove the drawer bit to fire off the other crash.

Steps to reproduce:
1. Click an entry

For the drawer (after the patch is applied, otherwise it crashes before you
finish this):
1. Double-click an entry
2. Type a new name
3. Press enter
Comment 3 Rafael Fernández López 2008-03-21 20:30:38 UTC
Thanks for notifying. I can't check the patches nor the problems at the moment, but I can tell some info:

- KCategorizedView is not meant to be used with a model different from a KCategorizedSortFilterProxyModel. On the other hand, it shouldn't force it to crash.

About the crashes, I am aware of some "random" crashes, that happens if you don't call, for instance: listView->setSpacing(10);

If calling to that method makes the view not to crash anymore, please close this bug. If it is still crashing, please confirm so, and I will take a look next week.

Thank you.
Comment 4 David Benjamin 2008-03-23 01:04:57 UTC
The crashes still occur for me when adding the call.
Comment 5 Rafael Fernández López 2008-06-10 13:37:27 UTC
Thanks for your observations. KCategorizedView shouldn't crash now.