WIP: Resources: Workspace Overwriting
This patch is meant to address this bug: https://bugs.kde.org/show_bug.cgi?id=444975 ("Resources > Workspaces: Can't overwrite different workspace of the same name.")
Bug recap:
Trying to overwrite a workspace by importing a different workspace with the same name causes unexpected behavior (wrong workspace names appearing in the list of workspaces, as well as wrong workspaces loading when selected) until Krita is restarted.
Notes:
Originally, Krita's resource chooser was inserting new rows into the model (using beginInsertRows
and endInsertRows
)regardless of whether the intent was to add a new workspace or overwrite an existing one.
The first thing we tried was to reset the model (using beginResetModel
and endResetModel
) instead of the insert methods. While this would show the correct names and would no longer load the incorrect resource (a different resource), it would continue to show the pre-updated resource until reboot.
The solution we have here, which seems to be working but probably requires more testing, is to first check if there will be an overwrite, and if so, we updateResource()
, otherwise, we insert.
Questions:
- By default and with fresh resources, Krita has 2 copies of most workspaces. For example, when browsing the database and filtering the resources table for ".kws" files, you can see 2 rows describing "Animation" workspaces that both reference "Animation.kws". If I understand correctly, this is because most of the workspace exist in both Krita 5's default 'bundle' as well as the Krita 3 default bundle.
What's the expected behavior when a user uploads a new "Animation.kws" workspace? Which of the 2 entries in the database are supposed to change? Both?
- The "Animation" workspace in Krita 3's bundle is different from the new one that's to be included with Krita 5. So (ignoring that the old one is obsolete and shouldn't be used anymore), shouldn't the old one still be visible and selectable in the GUI? How do we know which "Animation" workspace to prioritize when multiple are present?