Bug 452043 - KDescendantsProxyModel aborts application if source model is empty
Summary: KDescendantsProxyModel aborts application if source model is empty
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kitemmodels
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR crash
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-29 17:05 UTC by Janet Blackquill
Modified: 2022-04-18 23:29 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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