Skip to content

(Resource Queries) Revise the fix for "Prevent infinite recursion with Qt >5.15.2"

Mathias Wein requested to merge (removed):resource-query-mapper-fix into master

I had to find out that my last fix to make the resource system work after this Qt fix (although Qt 5.15.3 unfortunately won't ever be open source it seems, but with 6.x it will catch us) was only partially working. It seems the resource tests don't catch the issue...

I wasn't aware that the query argument of KisResourceQueryMapper::variantFromResourceQuery() may basically be a singleton itself, owned by the KisAllResourcesModel, and as such is somewhat volatile.

So with the changed QSortFilterProxyModelsetSourceModel() behavior, creating a KisResourceModel in this function also changes the const QSqlQuery &query argument under our feet.

I see two ways to avoid the issues:

  • copy everything from the query before doing anything that may change its state
  • avoid calling things that may invalidate the state in the first place

Since the KisResourceModel functions called here just redirect to KisAllResourcesModel, and resourceForId() again just redirects to KisResourceLocator::instance() which is already used several times in this function, I went with the latter.

The only issue is that KisAllResourcesModel::tagsForResource() is private, while KisResourceModel::resourceForId() is public. I'm not sure if it really needs to be private, I solved this with a friend class statement.

Test Plan

Good question, the issue only arises with Qt 5.15 branch from git, that was cut off from public halfway to 5.15.3. The issues manfiested in things like resource tooltips showing the tags for the last resource in the database table instead of the one you were looking at.

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.
Edited by Mathias Wein

Merge request reports

Loading