pencil2d / pencil

Pencil2D is an easy, intuitive tool to make 2D hand-drawn animations. Pencil2D is open source and cross-platform.
http://pencil2d.org
GNU General Public License v2.0
1.48k stars 273 forks source link

Assertion failure when selection is moved with arrows #1838

Open scribblemaniac opened 6 months ago

scribblemaniac commented 6 months ago

Issue Summary

The selection can be modified using the arrow keys without using the move tool, breaking some of the assumptions of canvaspainter. ### Actual Results When a selection is made, moved with the arrow keys and then the canvas is painted on with a drawing tool, all without selecting the move tool, then [this assert](https://github.com/pencil2d/pencil/blob/d9043356b93fdc159ba5ada2c2d6f6732f9f9f0b/core_lib/src/canvaspainter.cpp#L313) will be triggered, and crash on debug builds. If the assert is ignored, as it would be in a release build, then the selection does not get applied before drawing and the drawing tool will behave as if the selection has not been transformed. This will result in some visual anomalies as the brush data conflicts with the selection data. After each stroke is finished, the program behaves as if the stroke had been drawn before the selection was transformed, and the selection remains active with a transformation. ### Expected Results It is expected that the assert does not fail obviously. Perhaps the easiest and best solution would be for the arrow key shortcuts to only transform selections while the move tool is active. It would also make sense to be able to move the selection bounds (without the content) with the arrow keys when the select tool is active. ### Steps to reproduce 1. Create a selection. 2. Switch to the pen tool. 3. Use the arrow keys to move the selection. 4. Attempt to draw through the selection with the pen tool. ### System Information + Pencil2D Version: ac11a81 + Operating System: Ubuntu 22.04 + RAM Size: 16GB + Graphics Tablet: N/A
### Developer Notes This issue was previously noted in the PR in which it was introduced (https://github.com/pencil2d/pencil/pull/1807#issuecomment-1902509450), though after it had already been merged. I have created this separate issue for tracking purposes.