Skip to content

Fix no canvas resources interface set on a preset

Before this commit, presets with gradient brush tips wouldn't work correctly because the gradient was null, because the canvas resources interface would be null (see KisBrushOptionProperties::readOptionSettingResourceImpl where it attempts to set a gradient, but doesn't do it if the interface is null). This commit sets the canvas resources interface to the preset before it can be selected as the current preset, which makes it possible to set a gradient.

Course of action that led to empty interface (to get a crash log, put an assert in KisBrushOptionProperties::readOptionSettingResourceImpl)

  1. KisPaintopBox::setCurrentPaintop
  2. KisCanvasResourceProvider::setPaintOpPreset
    • (this commit adds setting the interface here)
  3. KoResourceManager::setResource
  4. KoResourceManager::notifyResourceChangeAttempted
  5. KoResourceManager::notifyDerivedResourcesChangeAttempted
  6. KoDerivedResourceConverter::readFromSource
  7. KisSizeResourceConverter::fromSource
  8. KisBrushBasedPaintOpSettings::paintOpSize
  9. KisBrushBasedPaintOpSettings::brush
  10. BrushReader::BrushReader
  11. KisPaintopPropertiesCanvasResourcesBase::readOptionSetting
  12. KisBrushOptionProperties::readOptionSettingResourceImpl
    • (here would be the assert, but without it, it just never goes to the 13. step. This commit fixes it so it can reach it).
  13. KisBrush::setGradient

BUG:446088

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

Test Plan

  1. Select for example m)_RGBA_06_Rock.kpp brush preset.
  2. Change the brush tip option from Lightness Map to Gradient.
  3. See that before this MR it would paint in red, and after this MR, it would paint in the current color (since the default gradient is foreground to transparent). If you change the gradient to be more interesting, it will also change in the brush. So, finally it works! :)

Formalities Checklist

  • I confirmed this builds.
  • I confirmed Krita ran and the relevant functions work.
  • I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!)
  • I made sure my commits build individually and have good descriptions as per KDE guidelines.
  • I made sure my code conforms to the standards set in the HACKING file.
  • I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.
Edited by Agata Cacko

Merge request reports

Loading