Bug 453340 - beginRemoveRows called with invalid index in KisAllResourcesModel::beginExternalResourceRemov
Summary: beginRemoveRows called with invalid index in KisAllResourcesModel::beginExter...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Resource Management (show other bugs)
Version: git master (please specify the git hash!)
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Tiar
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-03 14:03 UTC by Alvin Wong
Modified: 2022-06-28 11:35 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alvin Wong 2022-05-03 14:03:13 UTC
https://invent.kde.org/-/snippets/2176

Applying the patch will reveal a couple of invalid indices when running kis_psd_test. This is the cause of the freebsd CI failure.
Comment 1 Tiar 2022-05-20 14:38:09 UTC
I fixed it here: https://invent.kde.org/tymond/krita/-/commits/tiar/fix_invalid_indexes_on_externalRemove_in_KisResourceModel but I don't see any improvements in how many tests pass on CI... https://invent.kde.org/tymond/krita/-/pipelines/178840/test_report

Note that "I fixed it" involves "I ignore the invalid indexes" since that's the correct approach since the indexes can be invalid if the resources are deduplicated, which is what happens in that test.
Comment 2 Alvin Wong 2022-05-20 15:26:03 UTC
Well, it did seem to fix `plugins_impex_psd_kis_psd_test`. The count itself isn't a solid indicator because currently some tests do fail randomly.
Comment 3 Tiar 2022-05-20 16:09:52 UTC
Ah ok! Then I will just push it to master :)
Comment 4 Bug Janitor Service 2022-06-27 14:01:54 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1492
Comment 5 Tiar 2022-06-27 21:09:41 UTC
Git commit 1efcf547f30daf37e84fc017ce571493ccba2b39 by Agata Cacko.
Committed on 27/06/2022 at 19:29.
Pushed by nalvarez into branch 'master'.

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.

M  +17   -3    libs/resources/KisResourceModel.cpp

https://invent.kde.org/graphics/krita/commit/1efcf547f30daf37e84fc017ce571493ccba2b39
Comment 6 Tiar 2022-06-28 11:35:31 UTC
Git commit 84fa30520fabaf2a5a4435f3cecedbb2ecfd15c5 by Agata Cacko.
Committed on 28/06/2022 at 11:35.
Pushed by tymond into branch 'krita/5.1'.

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.


(cherry picked from commit 1efcf547f30daf37e84fc017ce571493ccba2b39)

M  +17   -3    libs/resources/KisResourceModel.cpp

https://invent.kde.org/graphics/krita/commit/84fa30520fabaf2a5a4435f3cecedbb2ecfd15c5