Bug 439699 - Tag is reset to nothing on adding or removing a storage
Summary: Tag is reset to nothing on adding or removing a storage
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Resource Management (show other bugs)
Version: git master (please specify the git hash!)
Platform: Mint (Ubuntu based) Linux
: NOR normal
Target Milestone: ---
Assignee: Emmet O'Neill
URL:
Keywords: regression, release_blocker
Depends on:
Blocks:
 
Reported: 2021-07-09 22:13 UTC by Tiar
Modified: 2021-08-05 22:29 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Screenshot showing lack of text (selected tag) in the tag chooser combobox (43.72 KB, image/png)
2021-07-27 19:18 UTC, Tiar
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tiar 2021-07-09 22:13:28 UTC
SUMMARY
Every time Krita or the user adds or removes a storage from/to a model, the tag in tag choosers (every combobox in the resources chooser) is reset to nothing.
This particularly happens on every startup of Krita.


STEPS TO REPRODUCE
1. Open Krita.
Or
1. Open Krita.
2. Select some tag.
3. Import a new storage, delete some storage etc.

OBSERVED RESULT
All resource choosers have an empty combobox above them.

EXPECTED RESULT
The combobox should show the last used tag; if it's not possible, they should show "All".

SOFTWARE/OS VERSIONS
git hash: 13f04ca236
Comment 1 Tiar 2021-07-09 22:18:26 UTC
WHAT NEEDS TO BE DONE:
This is caused by:
'''
    beginResetModel();
    resetQuery();
    endResetModel();
'''
in both "removeStorage" and "addStorage".
There are two ways to fix it.
1) "Proper" way: avoid using resetModel(), and instead use rowsAdded(), rowsRemoved(). Con: possibly error-prone if the developer uses some assumptions about the order of tags that turn out to be untrue.
2) Implement it in every tag chooser to "remember" the last used tag and set it after every resetModel.

NOTE:
This issue is related to the issue of remembering the tag after closing Krita. It would be best if every resource chooser had its own place in configuration to remember its own tag. It is especially tricky for tags in the brush chooser popup from the toolbar and the brush chooser in Brush Presets docker.
Comment 2 Halla Rempt 2021-07-27 13:02:34 UTC
I don't see an empty tag combobox if I enable/disable a storage in the storage selctor widget?
Comment 3 Tiar 2021-07-27 19:14:14 UTC
> I don't see an empty tag combobox if I enable/disable a storage in the storage selctor widget?

That's interesting, I still see it. I opened Krita fresh on a3e9ff58d0, and on startup, tag comboboxes in any resource chooser is empty. Then I select, let's say, "All" tag. It shows up, as it should. Then I click on the storage enabling popup, and let's say enable and disable the Krita 3 bundle. The tag disappears from the combobox.
Comment 4 Tiar 2021-07-27 19:18:11 UTC
Created attachment 140358 [details]
Screenshot showing lack of text (selected tag) in the tag chooser combobox

Oh I just realized what is the confusion. It's not that the combobox has no options; no, the combobox does have all the options, hopefully even correct (respecting deactivated storages).

The problem is that the *selected tag* on the combobox is empty, which means that it looks empty if you don't click on it. I believe the filtering is "All", but the text is missing. It's the standard "nothing is selected if you reset the model" situation that we had in resource choosers before (a year ago, before Halla's big changes to models to avoid using model reset).

I attached a screenshot showing the problem.
Comment 5 Emmet O'Neill 2021-07-30 00:44:34 UTC
Git commit a51f7ee078c006eb601883529373b0c1dccccdb5 by Emmet O'Neill.
Committed on 30/07/2021 at 00:42.
Pushed by emmetoneill into branch 'master'.

Bugfix for resource chooser tag filters not reflecting active storage changes.

Tag dropdown boxes will now always correctly reflect active / inactive
resource storages.

M  +6    -4    libs/resources/KisTagFilterResourceProxyModel.cpp
M  +20   -0    libs/resources/KisTagResourceModel.cpp
M  +4    -0    libs/resources/KisTagResourceModel.h
M  +1    -1    libs/resourcewidgets/KisTagChooserWidget.h

https://invent.kde.org/graphics/krita/commit/a51f7ee078c006eb601883529373b0c1dccccdb5
Comment 6 Emmet O'Neill 2021-07-30 00:45:18 UTC
Err.. Tagged the wrong bug.
Comment 7 Emmet O'Neill 2021-07-30 04:21:25 UTC
So I've been making some progress on this bug, but there are a few problems.

First off, I've been seeing what Halla has been where the combobox is never blank, and resets to the all tag when changing active storages. This reset to all shouldn't happen though, imo, and I've begun fixing that particular issue.

So far, I've been able to get the selected tag to persist across resource changes (good) but I have run into a problem where the resources that belong to a tag don't accurately reflect active resources.

I was able to fix a related issue to this w/ bug 440315 where the TagResourceModel wouldn't update on any of the drop down options until a tag was assigned or removed. So I might be able to go about it the same way...
Comment 8 Emmet O'Neill 2021-07-30 21:58:22 UTC
Git commit 2317edd3b526eecf09487a6476f4e4aa39365c95 by Emmet O'Neill.
Committed on 30/07/2021 at 21:57.
Pushed by emmetoneill into branch 'master'.

Resource Management: Corrected TagFilter Combobox Behavior.

The combobox for selecting tags within resource chooser widgets
no longer resets when adding and removing storage bundles.

(Thanks for the help Eoin.)

M  +4    -4    libs/resources/KisTagModel.cpp
M  +13   -0    libs/resources/KisTagResourceModel.cpp
M  +4    -1    libs/resources/KisTagResourceModel.h

https://invent.kde.org/graphics/krita/commit/2317edd3b526eecf09487a6476f4e4aa39365c95
Comment 9 Emmet O'Neill 2021-07-30 22:01:32 UTC
The commit above has addressed this issue on my end, I think. 

@Tiar: Because Eoin and I were seeing something different than you on both of our machines, you might want to check and see if the issue that you were having has also been fixed. If so, please close this bug. :)
Comment 10 Tiar 2021-08-02 14:50:25 UTC
Reopened, even though it probably works most of the time; but explanation written here: https://invent.kde.org/graphics/krita/-/commit/2317edd3b526eecf09487a6476f4e4aa39365c95#note_281331 - basically it only works if the storage added or removed didn't add or remove any tags.
Comment 11 Eoin O'Neill 2021-08-02 23:15:41 UTC
Git commit 270ceaa330569bd43ce27d55d118794602bd3fbe by Eoin O'Neill.
Committed on 02/08/2021 at 23:14.
Pushed by eoinoneill into branch 'master'.

Modify how resource model is updated when adding / removing storage.

Restored tradition model reset behavior in favor of responding to changes
within the KisTagChooserWidget class itself. This should be more sane...

M  +4    -4    libs/resources/KisTagModel.cpp
M  +21   -1    libs/resourcewidgets/KisTagChooserWidget.cpp
M  +11   -0    libs/resourcewidgets/KisTagChooserWidget.h

https://invent.kde.org/graphics/krita/commit/270ceaa330569bd43ce27d55d118794602bd3fbe