Refactor KoColorSet to Change Its Data Structure
Needs ReviewPublic

Authored by mzhou on Feb 14 2019, 12:24 AM.


Group Reviewers

Changing the data structure from string list + hash table to a list of KisSwatchGroup. This would make the logic in this class clearer and more efficient.

There is also minor interface change in KisPaletteModel, KisPaletteView and KisDlgPaletteEditor, as KoColorset now has a getGroups() method which is clearer than the original getGroupNames() method.

Also, fixed 2 issues related to file I/O of the palette.

One is that Krita crashes if a palette file it wants to load is corrupted. It is changed so that Krita aborts loading that file instead of crashing.

The other is that Krita would fail to store a kpl palette if multiple color profiles used in this palette are from one same profile file. This is fixed by saving one profile file only once.

Test Plan

I am trying to come up with a better inferface for KoColorset. I will provide unit tests once it is done. For now, I think testing renaming, reordering, adding and removing swatch groups manually in the GUI palette docker would be enough.

For the crashing issue when loading a corrupted file, try to let Krita load a corrupted palette file, like an empty file. Krita would crash before this fix. This should not happen after this fix.

For the saving multiple profile issue, before this fix, if in a palette there are 2 colors using different color profiles from one same profile file, Krita would fail to store that palette, causing the file its stores the palette to be empty. 2 colors that are close to each other on the advanced color picker are likely to cause this problem. This should not happen after this fix, either.

Diff Detail

R37 Krita
Lint Skipped
Unit Tests Skipped
mzhou requested review of this revision.Feb 14 2019, 12:24 AM
mzhou created this revision.
rempt added a subscriber: rempt.Feb 21 2019, 2:31 PM

Have you also checked what needs to be done to bring the Python API in line with these changes?

mzhou added a comment.Feb 21 2019, 4:35 PM

Have you also checked what needs to be done to bring the Python API in line with these changes?

Ah I didn't. I will have a look.

rempt requested changes to this revision.Mar 11 2019, 3:37 PM

Mark as request changes so it's out of my queue

This revision now requires changes to proceed.Mar 11 2019, 3:37 PM
mzhou added a comment.EditedApr 20 2019, 12:55 AM

I modified the Python palette docker that it is can now show the palettes correctly. I am thinking disabling it from editting color palettes for now might be a good idea, as all the editting can be done using the C++ docker and it will be easier to bring all the functionalities of the Python docker back when the interfaces to the backend of palettes are more stable.

Actually I do not really understand why we need the Python palette docker. I feel it makes development harder but does not really bring any new functionality to the software.

mzhou updated this revision to Diff 56607.Apr 20 2019, 12:57 AM

The Python palette docker are now able to show palettes, but they cannot edit them yet.

The point was to demonstrate how to use python to export/import/edit/generate resources.