https://bugs.kde.org/show_bug.cgi?id=434309

--- Comment #2 from Tiar <tamtamy.tym...@gmail.com> ---
Git commit f449392f477f21902310594f46273ec18cd10dbd by Agata Cacko.
Committed on 19/04/2021 at 22:16.
Pushed by tymond into branch 'master'.

Fix default MyPaint brush being randomly incorrect

Before this commit, if the user wanted to create a MyPaint
brush preset from scratch, they would either get the
standard round MyPaint brush (coming from the mypaintbrush.myb
file in the plugins/paintops/defaultpresets/ directory),
or a much smaller brush with very low spacing. It would be also
impossible to change various details about the brush.

This commit ensures that the user will always get the correct
brush from the .myb file and be able to change its properties.

The reason for that bug was the fact that MyPaint preset loader
would load all the bytes from the current point it peeks to
to the end. However in kis_paintop_box there is a for loop
over all paintoppresets loaders to see if they can read that specific
file. In a generic paintoppreset loader, a few first bytes would be
read, which would result in MyPaint preset loader missing first few
bytes and assuming that the json is incorrect, and hence using
its default options (that low spacing brush) instead of options
supplied in the file.

Because there was no error checking in the MyPaint preset loader,
Krita would assume everything is fine. However because MyPaint
editor handles the changes by changing the json and then supplying it
to the libmypaint brush engine, changing most of the properties wouldn't
work, because the json was always incorrect.

This commit adds moving the beginning of the bytes to read to the
beginning of the file in two locations, both the for loop for loaders
and in the MyPaint presets loader itself. Moreover it adds error
checking to the MyPaint presets loader.

---

Note: if there is no loader or no file found, the preset would not paint,
because, I assume, it takes all the options from the default
values of all the widgets and it means 0 for opacity, dabs per
second etc. It would be best if Krita in such case would use MyPaint
default options, but because Krita's MyPaint library uses the json
version all the time and because I couldn't find a way to extract the
json from a working libmypaint brush, I had to leave it as that.

M  +1    -0    libs/ui/kis_paintop_box.cc
M  +7    -3    plugins/paintops/mypaint/MyPaintPaintOpPreset.cpp

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

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to