Bug 452043

Summary: KDescendantsProxyModel aborts application if source model is empty
Product: [Frameworks and Libraries] frameworks-kitemmodels Reporter: Janet Blackquill <uhhadd>
Component: generalAssignee: kdelibs bugs <kdelibs-bugs-null>
Status: RESOLVED FIXED    
Severity: crash    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Janet Blackquill 2022-03-29 17:05:15 UTC
KDescendantsProxyModel has many asserts in the code to ensure that the source model isn't empty, resulting in app crashes when it is empty.
Comment 1 Janet Blackquill 2022-04-18 23:29:06 UTC
Git commit e9156500e2f1fdc84d2307a9ac6e5dda3e82ee6e by Jan Blackquill, on behalf of Tino Lorenz.
Committed on 18/04/2022 at 23:29.
Pushed by cblack into branch 'master'.

Fix assertions in KDescendantsProxyModel

Remove assertions in `kdescendantsproxymodel.cpp` that will make the program crash when the model is empty.

Note: if `hasChildren` returns true, it doesn't mean that `rowCount` for the same index must be >0.
For example, KDirModel's `hasChildren` returns true for directories with >=1 children, but its `rowCount` doesn't list
the children and just returns 0 if they weren't already listed.

M  +49   -2    autotests/kdescendantsproxymodeltest.cpp
M  +7    -15   src/core/kdescendantsproxymodel.cpp

https://invent.kde.org/frameworks/kitemmodels/commit/e9156500e2f1fdc84d2307a9ac6e5dda3e82ee6e