Skip to content

Fix invalid indexes on external Remove in ResourceModel

Before this commit, if the index was invalid, KisResourceModel would still try to use it to remove resources from the model. Considering that the index can be invalid in a correct state of Krita, when the resource has been deduplicated in SQL query so it doesn't appear in the model, this commit just ignores invalid indexes.

Before this commit there was also always just one endRemoveRows() called despite that beginRemoveRows() could be called multiple times. Qt needs the endRemoveRows() to be called the same amount of times as beginRemoveRows(), so this commit makes sure that the amounts of calls for both functions match.

BUG:453340

Test Plan

See the result of test kis_psd_test.

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 Agata Cacko

Merge request reports

Loading