Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect copying of SelectedPointIndex and SelectedShapeIndex wh… #235

Merged
merged 1 commit into from
Oct 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions Pinta.Tools/Editable/EditEngines/BaseEditEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1580,9 +1580,16 @@ protected void ResetShapes ()
if (correspondingTool != null && PintaCore.Tools.CurrentTool != correspondingTool) {
ShapeTool? oldTool = PintaCore.Tools.CurrentTool as ShapeTool;

int oldToolSPI = -1;
int oldToolSSI = -1;
//SetCurrentTool sets oldTool's SelectedPointIndex and SelectedShapeIndex to -1 so their value has to be saved before this happens.
if (oldTool != null && oldTool.IsEditableShapeTool && permanentSwitch) {
oldToolSPI = oldTool.EditEngine.SelectedPointIndex;
oldToolSSI = oldTool.EditEngine.SelectedShapeIndex;
}

//The active tool needs to be switched to the corresponding tool.
PintaCore.Tools.SetCurrentTool (correspondingTool);

var newTool = (ShapeTool?) PintaCore.Tools.CurrentTool;

// This shouldn't be possible, but we need a null check.
Expand All @@ -1593,8 +1600,8 @@ protected void ResetShapes ()
if (oldTool != null && oldTool.IsEditableShapeTool) {
if (permanentSwitch) {
//Set the new tool's active shape and point to the old shape and point.
newTool.EditEngine.SelectedPointIndex = oldTool.EditEngine.SelectedPointIndex;
newTool.EditEngine.SelectedShapeIndex = oldTool.EditEngine.SelectedShapeIndex;
newTool.EditEngine.SelectedPointIndex = oldToolSPI;
newTool.EditEngine.SelectedShapeIndex = oldToolSSI;

//Make sure neither tool thinks it is drawing anything.
newTool.EditEngine.is_drawing = false;
Expand Down