What do you mean by it? I can think of two possibilities:
- Saving the size of the last used brush when Krita closes, and setting as such on the next session.
- Remembering the size of every brush used and restoring it on the next session.
What do you mean by it? I can think of two possibilities:
IIRC, in ThreeSlots’ case, it would just save the size of the last used brush for each particular slot. But this functionality might be out of scope for an eraser tool plugin and may be better as optional behavior or as a separate plugin.
This plugin crashes on opening a new document in 5.2 git 5d13870:
File "/home/name/.local/share/krita/pykrita/EraserTool/__init__.py", line 53, in conectado
plugin.connecting()
File "/home/name/.local/share/krita/pykrita/EraserTool/EraserTool.py", line 186, in connecting
obj2 = obj1.findChild(QListView,'ResourceItemview')
AttributeError: 'NoneType' object has no attribute 'findChild'
It doesn’t crash Krita completely, but slots will no longer change brushes from what they were originally set.
I’m not sure if something like this would be that difficult to add natively in the form of action shortcuts (what’s the benefit in generating a brush list instead of having a few config values that save the particular preset as long as it satisfies the slot properties?), so I may or may not consider looking into that later.
Thanks for the report.
It was a simple fix, but I might delay a new version a couple of days (at most) to deal in a more ‘elegant’ way with these unexpected but predictable errors.
As for your questions:
I’m not sure I understand what you mean by actions shortcuts. However the way this tool works is by a theoretical 2-step process, that is a result of my understanding of a (type of) Eraser Tool:
This should be done without any additional user input.
For now Krita don’t have a Python class that signals when (and which) brushes were selected. So I ‘hacked’ the Preset Docker to capture an internal signal from it and use it in my plugin. (This was the source of this new bug, the internal name of the Preset Docker changed so my plugin couldn’t find it)
This signal just warns me when a brush changes, not which brush it is or its properties. This is where the Krita 5.2 requirement and the brush list comes around, which leads me to your second question.
The brush list is just a performance benefit. Until Krita 5.2 one couldn’t take the current brush preset and see more than a handful of ‘superficial’ information about the brush. Unless you made a brush resource reader/parser yourself to read the inner-works of the preset.
In Krita 5.2 onward we have the python class Preset. This class has a method to parse a brush resource to XML, so one can easily read and manipulate a brush information.
Sure, you could do this reading on the fly but the process is quite slow and would cause annoying stutter every time you changed brushes.
Making a list was the more simple way I found to approach this.
Cheers.
FYI: This plugin seems to have stopped functioning in latest builds of 5.2/5.3, as after adding a new brush, there’s some sort of XML parse error. This is a bit of a recurring problem with implementing functionality as a third-party plugin, as they always seem to eventually break apart in my case.
I used the above breakage as motivation for Add explicit actions for selecting the remembered presets for the pen stylus and eraser stylus (!1871) · Merge requests · Graphics / Krita · GitLab, which adds a couple shortcuts for selecting the brush preset and eraser preset, respectively, for Krita 5.3. They’ll also activate the freehand brush tool by default as I felt that would be most overall comfortable. However, compared to this plugin, it won’t automatically switch the “slots” if an eraser preset is selected from the brush chooser.
These two actions differ from @freyalupen’s “Toggle eraser preset” action in 5.2 in that these are explicit select actions (“Select brush preset” and “Select eraser preset”) rather than a singular toggle action. Toggle actions are rather different in terms of muscle memory and sometimes bring some ambiguity to what state you’re in. The toggle action also doesn’t select the freehand brush tool by default.
Thanks for the heads up. The plugin really stopped working, I just don’t think it is Krita or my plugin at fault.
I tried opening the test build from Krita 5.2 Wet Blend Mode, I believe a package from 04/2023 and I see the same error.
Apparently the error is from the XMLparser native from Python (xml.etree.ElementTree).
I only have Linux that it is where I tested. Are you too using a Linux machine?
I will see what else I can do here, maybe search for a alternative for parsing the brushes as XML.
Also do you have my Oils bundle installed? In specific the brush Oils Fine Details?
Cheers.
I use Linux and I don’t have your bundle installed.
When I leave only the default bundles (Krita 4 Default, Krita SeExpr, Krita RGBA) the plugin don’t crash on boot-up and I can use it without any problem.
Which lead me to believe that something about the users created brushes aren’t playing nice with the new version of the library ElementTree.
This surely is annoying and frustrating.
I took a look inside some brush presets that trigger the error (just by printing the brushXML variable from the plugin’s code), it seems like the Texture/Pattern/PatternMD5
is causing the issue.
With the error ‘xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 133, column 71’, here’s line 133 of:
Original preset (no error):
<param name="Texture/Pattern/PatternMD5" type="bytearray">oyx1rPa1Aa0UzFcc5yviLw==</param>
Modified copy of the preset (error):
<param name="Texture/Pattern/PatternMD5" type="string"><![CDATA[XXX]]></param>
Pretend the XXX is a bunch of untypeable characters. I’m guessing the XML parser doesn’t like those.
So the next question is, why the difference?
Hello everyone,
Thanks again @tom for the heads-up, and @freyalupen for finding specifically what the problem really was.
I just updated the plugin to the Version 0.4 with a simple hotfix. It should make the plugin fully functional again, and prevent similar problems from this nature again.
Thanks and let me now if anything unexpected arises again.
Cheers.
Hello everyone,
After more than a year I’m reviving this post. I found some energy to try, and improve this little project.
Now you have a third shortcut that will swap between the Brush Slot, and the Eraser slot. All other functions of the plugins remain unchanged.
Let me know if someone find any problem, or if has some suggestion to further improve it.
Cheers and see you all soon!