Skip to content

LayerBox: Fix the bug with layer not getting selected

Sharaf Zaman requested to merge szaman/krita:bug-462879-layer-selection into master

When a new layer was created we wouldn't select it due to selectionModel()->hasSelection() clause -- which assumed that if there was a already a layer selected then the new layer would clear selection when it shouldn't.

In addition to this, there was a bug caused by currentChanged calling setData(). This resulted in dataChanged() being called by a signal which in turn called setCurrentIndex again but this time since no selection flags were persisted this would update the selection when it shouldn't.

Now, we add a signal blocker since we're just adding a UserRole and the only calls that seem to rely on this signal are updateUI -- which gets called anyways. So, it should be safe, I assume.

Another way to fix this would be to stop the ActiveRole, since we can directly use currentIndex. But I didn't go this route since it would require quite more refactoring and I'm not fully sure if it is desirable?

Test Plan

BUG:462879

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.

Merge request reports