From 96732256484b2760495746039d137134fb6fadb2 Mon Sep 17 00:00:00 2001 From: whitequark Date: Wed, 16 Nov 2016 02:19:09 +0000 Subject: [PATCH] Fix a crash when adding a symmetric constraint on a line. This is the same problem as in ffd9c62. --- src/constraint.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/constraint.cpp b/src/constraint.cpp index d33e67b..24634c0 100644 --- a/src/constraint.cpp +++ b/src/constraint.cpp @@ -379,9 +379,13 @@ void Constraint::MenuConstrain(Command id) { ((gs.workplanes == 1 && gs.n == 2) || (gs.n == 1))) { - int i = SK.GetEntity(gs.entity[0])->IsWorkplane() ? 1 : 0; - Entity *line = SK.GetEntity(gs.entity[i]); - c.entityA = gs.entity[1-i]; + Entity *line; + if(SK.GetEntity(gs.entity[0])->IsWorkplane()) { + line = SK.GetEntity(gs.entity[1]); + c.entityA = gs.entity[0]; + } else { + line = SK.GetEntity(gs.entity[0]); + } c.ptA = line->point[0]; c.ptB = line->point[1]; c.type = Type::SYMMETRIC;