Skip to content

Ensure pen mode brush is selected on new document (alt. solution)

R. B. requested to merge tomtomtom/krita:tomtomtom/inputdeviceeraser into master

This MR attempts to fix the issue noted in !1870 (merged) without introducing regressive behavior as noted in https://bugs.kde.org/show_bug.cgi?id=472730.

While the first MR made it so that a new view reads the LastPreset_[currentTabletId] config setting instead of the LastPreset setting, it neglected to also write to the relevant config setting on view close. As a result, selecting a new preset, closing the document, then opening a document would read from an outdated LastPreset_[currentTabletId] setting.

At first I wanted to resolve this along with the original issue by adding more code from KisPaintopBox to KisViewManager. While this redundant solution seemed to work at first, it didn't resolve the original issue for multi-window setups.

Instead, this MR removes the related LastPreset code from KisViewManager so there isn't any collision with KisPaintopBox. From my tests, this solution resolves the original issue for both single-window and multi-window sessionss, and I haven't noticed any new regressions.

Testing note: If your stylus lacks an eraser mode, you can use the Toggle Eraser Preset action from !1689 (merged) or the recent Select Brush/Eraser Preset actions from !1871 (merged).

Side-notes:

There seems to be an already existing issue where new views from new windows in multi-window sessions use outdated presets on new view, but that shouldn't be related to this MR, as said behavior also occurs in 5.1.5/latest 5.2. I'll make a report for it later.

A comment from the removed code claimed the related codeblock would also restore last used foreground/background color, but that was already moved elsewhere in KisViewManager.

KisPaintopBox has relied on LastPreset_? instead of LastPreset since 2021: f703e306

Test Plan

  • Ensure that the original issue is fixed, by closing Krita while in eraser stylus mode and opening a new document. The pen stylus brush should be selected.
  • Ensure that the regressive behavior that occured with the previous MR no longer occurs with this MR, by closing and reopening documents after selecting new presets. The new preset should be selected, not the originally selected preset.
  • Ensure that both the correct eraser stylus brush and the correct pen stylus brush are remembered across new views, reopened views, and restarted Krita sessions.
  • Ensure that the proper fallback measures are taken in the case of missing/invalid config values and/or resource server.
  • Ensure there aren't any regressions with new and removed views in multi-window sessions.
  • If possible, check what occurs with different types of input devices.

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.

Reminder: the reviewer is responsible for merging the patch, this is to ensure at the least two people can build the patch. In case a patch breaks the build, both the author and the reviewer should be contacted to fix the build. If this is not possible, the commits shall be reverted, and a notification with the reasoning and any relevant logs shall be sent to the mailing list, kimageshop@kde.org.

Edited by R. B.

Merge request reports