Skip to content

Fix incorrect filter logic in KisResourceModel

Mathias Wein requested to merge mwein/krita:resource-model-filter-fix into master

I noticed that after every restart, my brush preset history was missing various brushes. After investigating, it turned out the KisResourceModel used indices for its own model to query the active state of resource+storage on the source model, which won't match. (Maybe some sanity checks on index.model() wouldn't hurt, as well as using index.data(role) instead of model.data(index, role) where apropriate)

I think it's enough to just check if the mapping from source succeeds, because QSortFilterProxyModel is supposed to maintain an updated mapping if implemented correctly. But I want someone to double-check if that's really correct this way.

I modified the relevant unit test to detect the issue, and then (hopefully) fixed it in a separate commit so it's easier to test before/after the fix.

I'm also unsure about KisResourceModel::resourceForMD5(), currently it ignores the filtering rules that apply to the other resourceFor functions so I didn't touch it.

Test Plan

Well it's a bit tricky to test other than running the enhanced TestResourceModel unit test before and after the fix. Which resources are affected in Krita depends on which bundles and/or resources are set inactive.

Formalities Checklist

  • I confirmed this builds.
  • I confirmed Krita ran and the relevant functions work.
  • I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!)
  • I made sure my commits build individually and have good descriptions as per KDE guidelines.
  • I made sure my code conforms to the standards set in the HACKING file.
  • I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.

Merge request reports