Bug 444975

Summary: Resources > Workspaces: Can't overwrite different workspace of the same name.
Product: [Applications] krita Reporter: Emmet O'Neill <emmetoneill.pdx>
Component: Resource ManagementAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: ghevan, tamtamy.tymona
Priority: NOR Keywords: release_blocker
Version: 5.0.0-beta2   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Error dialog

Description Emmet O'Neill 2021-11-04 19:38:00 UTC
SUMMARY

When testing "import a different resource file with the same filename", I wasn't able to import a second resource with the same filename as an existing resource. 

STEPS TO REPRODUCE
1. Copy an existing workspace from Krita's resources folder to another directory.
2. Try to import in Krita's resource manager

OBSERVED RESULT

Despite being a valid resource, I was shown a "the following files couldn't be opened as resources" error dialog. 

EXPECTED RESULT

I would expect this to simply overwrite the existing resource, otherwise it should produce a more clear error message.

ADDITIONAL INFO

krita/5.0 branch, resource testing day.
Comment 1 Tiar 2021-11-05 00:32:41 UTC
Did you use the Window -> Workspaces menu or the toolbar button for importing? Or does it happen in both?
Comment 2 vanyossi 2021-11-06 14:33:33 UTC
Created attachment 143280 [details]
Error dialog

This happens in Resource Manager, I had the same issue importing same-name brush tips and presets. Despite the preset beign a valid one there is an error message showing. (attached)

Importing from "Predefined brush tips" works as expected.
Comment 3 Emmet O'Neill 2021-11-08 22:16:30 UTC
Something must have changed behind the scenes because I can't reproduce this bug anymore. 

Now i'm getting even more confusing behavior where it prompts to overwrite and then doesn't?
I have to look into it more...
Comment 4 Tiar 2021-11-09 01:26:12 UTC
I dunno, maybe it is possible to make it work with PSDs too. But then it's a wishlist item.
Comment 5 Tiar 2021-11-09 13:15:17 UTC
Uhh ignore my previous comment...
Comment 6 Emmet O'Neill 2021-11-11 05:23:25 UTC
I've observed 2 pretty strange behaviors here:

Strange behavior 1:

If you copy "Default.kws" to another location, and rename it to "Storyboarding.kws" *without changing the workspace's internal "name" attribute* it will, for some reason, appear in the workspaces list as a second workspace called "Animation" upon import with overwrite prompt.

This new workspace, that should be named "default" (based on the internal name) OR "storyboard" (based on the filename), while looking like the default workspace, actually looks like the OLD (pre-5.0) "animation" workspace...

After restarting Krita, this seems to resolve itself. Specifically, from the GUI you can only see 1 "animation" workspace (that looks as it should), 2 "default" workspaces (based on the shared internal workspace name XML attribute) that both correctly look like they should. Finally, there is no longer any "storyboarding" workspace. That's also expected.

-------------------------------------------------------------------------------------------------------------------

Strange behavior 2:

This is similar, but slightly different.

If you copy "Default.kws" to another location, and rename it to "Animation.kws", *and then change the workspace's internal "name" XML attribute to "Animation"*, and import, it will prompt and overwrite, as you'd expect. There will still be only 1 workspace named "Animation" in the list.

However, the "Animation" workspace, which should look like the default workspace that we copied, will for some reason look like the OLD (pre-5.0) animation workspace instead!

After restarting Krita, this also seems to resolve itself! Specifically, there will be only 1 "Animation" workspace in the list, and it will correctly look like the default layout that we copied.

-------------------------------------------------------------------------------------------------------------------

These are probably the same or similar bug[s].
Comment 7 Emmet O'Neill 2021-11-11 05:30:58 UTC
Just a quick addendum to the last post:

If you copy "Default.kws" to another location, and rename it to "Big Paint.kws", *and then change the workspace's internal "name" XML attribute to "Big_Paint"*, and import, it will prompt and overwrite, as you'd expect.

BUT.....

There will then be 2 "Animation" workspaces, with one looking like the new Krita 5.0 animation workspace, and the other looking like the old (pre-5.0) animation workspace.

This is kind of the missing link between the two behaviors mentioned above.
Comment 8 Eoin O'Neill 2021-11-15 22:45:48 UTC
Git commit e715c2676cfa97e72e9e0bd869359d827524d2f4 by Eoin O'Neill.
Committed on 15/11/2021 at 22:43.
Pushed by eoinoneill into branch 'master'.

Fix workspace import overwrite issues.

Resolution to MR1155. Patch file by tiar. Tested and seems to work appropriately.

M  +2    -1    libs/resources/KisResourceCacheDb.cpp
M  +1    -0    libs/resources/KisResourceCacheDb.h
M  +6    -2    libs/resources/KisResourceLocator.cpp
M  +32   -2    libs/resources/KisResourceModel.cpp

https://invent.kde.org/graphics/krita/commit/e715c2676cfa97e72e9e0bd869359d827524d2f4
Comment 9 Eoin O'Neill 2021-11-15 22:46:52 UTC
Git commit 88a68a54190b34617b6c688e0c9eee7135a0cec2 by Eoin O'Neill.
Committed on 15/11/2021 at 22:46.
Pushed by eoinoneill into branch 'krita/5.0'.

Fix workspace import overwrite issues.

Resolution to MR1155. Patch file by tiar. Tested and seems to work appropriately.
(cherry picked from commit e715c2676cfa97e72e9e0bd869359d827524d2f4)

M  +2    -1    libs/resources/KisResourceCacheDb.cpp
M  +1    -0    libs/resources/KisResourceCacheDb.h
M  +6    -2    libs/resources/KisResourceLocator.cpp
M  +32   -2    libs/resources/KisResourceModel.cpp

https://invent.kde.org/graphics/krita/commit/88a68a54190b34617b6c688e0c9eee7135a0cec2
Comment 10 Tiar 2021-11-19 05:21:43 UTC
Git commit 9db2dc681aade8d87fcc2b2a0366a6f4022d5938 by Agata Cacko, on behalf of Eoin O'Neill.
Committed on 19/11/2021 at 04:32.
Pushed by tymond into branch 'master'.

Additional changes made to file importing to acommodate for MR1162.

Should now work correctly with empty string syntax.

M  +0    -1    libs/resources/KisResourceCacheDb.cpp
M  +7    -11   libs/resources/KisResourceModel.cpp

https://invent.kde.org/graphics/krita/commit/9db2dc681aade8d87fcc2b2a0366a6f4022d5938
Comment 11 Tiar 2021-11-19 05:21:51 UTC
Git commit b1c5f6d6da5cb3d1896c03066e0172beb6377dca by Agata Cacko.
Committed on 19/11/2021 at 04:47.
Pushed by tymond into branch 'master'.

Change null strings to empty in CacheDb queries

Before this commit, CacheDb queries could sometimes
fail because the string supplied was null instead of empty
(most common in storages, where an empty string indicates
the resource folder).
Null strings in queries cause issues because comparison with a null
is always string.

This commit ensures that null strings are converted to empty strings
before being used in in WHERE part in an sql query.

M  +23   -13   libs/resources/KisResourceCacheDb.cpp

https://invent.kde.org/graphics/krita/commit/b1c5f6d6da5cb3d1896c03066e0172beb6377dca
Comment 12 Tiar 2021-11-19 05:47:50 UTC
Git commit a250a25dfd8307b4cad5f68ef014859a30e13254 by Agata Cacko.
Committed on 19/11/2021 at 05:32.
Pushed by tymond into branch 'krita/5.0'.

Change null strings to empty in CacheDb queries

Before this commit, CacheDb queries could sometimes
fail because the string supplied was null instead of empty
(most common in storages, where an empty string indicates
the resource folder).
Null strings in queries cause issues because comparison with a null
is always string.

This commit ensures that null strings are converted to empty strings
before being used in in WHERE part in an sql query.

M  +23   -13   libs/resources/KisResourceCacheDb.cpp

https://invent.kde.org/graphics/krita/commit/a250a25dfd8307b4cad5f68ef014859a30e13254
Comment 13 Tiar 2021-11-19 05:47:58 UTC
Git commit def99efd67a6884ea17f27e0729e6c8ff5b6c079 by Agata Cacko, on behalf of Eoin O'Neill.
Committed on 19/11/2021 at 05:31.
Pushed by tymond into branch 'krita/5.0'.

Additional changes made to file importing to acommodate for MR1162.

Should now work correctly with empty string syntax.

M  +0    -1    libs/resources/KisResourceCacheDb.cpp
M  +7    -11   libs/resources/KisResourceModel.cpp

https://invent.kde.org/graphics/krita/commit/def99efd67a6884ea17f27e0729e6c8ff5b6c079