Don't crash after right-clicking on derived entities.

pull/4/head
whitequark 2016-04-17 01:16:47 +00:00
parent a4a353f01b
commit b3df595769
1 changed files with 19 additions and 25 deletions

View File

@ -573,33 +573,27 @@ void GraphicsWindow::MouseRightUp(double x, double y) {
} }
if(gs.comments > 0 || gs.points > 0) { if(gs.comments > 0 || gs.points > 0) {
AddContextMenuItem("Snap to Grid", CMNU_SNAP_TO_GRID); AddContextMenuItem("Snap to Grid", CMNU_SNAP_TO_GRID);
if(gs.points == 1) {
hRequest hr = gs.point[0].request();
if(hr.v != 0) {
Request *r = SK.GetRequest(hr);
int index = r->IndexOfPoint(gs.point[0]);
if((r->type == Request::CUBIC && (index > 1 && index < r->extraPoints + 2)) ||
r->type == Request::CUBIC_PERIODIC) {
AddContextMenuItem("Remove Spline Point", CMNU_REMOVE_SPLINE_PT);
}
}
}
} }
if(gs.entities == 1) {
hRequest hr = gs.entity[0].request(); if(gs.points == 1 && gs.point[0].isFromRequest()) {
if(hr.v != 0) { Request *r = SK.GetRequest(gs.point[0].request());
Request *r = SK.GetRequest(hr); int index = r->IndexOfPoint(gs.point[0]);
if(r->type == Request::CUBIC || r->type == Request::CUBIC_PERIODIC) { if((r->type == Request::CUBIC && (index > 1 && index < r->extraPoints + 2)) ||
Entity *e = SK.GetEntity(gs.entity[0]); r->type == Request::CUBIC_PERIODIC) {
e->GetDistance(Point2d::From(x, y)); AddContextMenuItem("Remove Spline Point", CMNU_REMOVE_SPLINE_PT);
addAfterPoint = e->dogd.data; }
if(addAfterPoint == -1) oops(); }
// Skip derivative point. if(gs.entities == 1 && gs.entity[0].isFromRequest()) {
if(r->type == Request::CUBIC) addAfterPoint++; Request *r = SK.GetRequest(gs.entity[0].request());
AddContextMenuItem("Add Spline Point", CMNU_ADD_SPLINE_PT); if(r->type == Request::CUBIC || r->type == Request::CUBIC_PERIODIC) {
} Entity *e = SK.GetEntity(gs.entity[0]);
e->GetDistance(Point2d::From(x, y));
addAfterPoint = e->dogd.data;
if(addAfterPoint == -1) oops();
// Skip derivative point.
if(r->type == Request::CUBIC) addAfterPoint++;
AddContextMenuItem("Add Spline Point", CMNU_ADD_SPLINE_PT);
} }
} }