Skip to content

Commit

Permalink
fixing crash when deleting the last lane refs #457
Browse files Browse the repository at this point in the history
git-svn-id: file:///home/behr_mi/git/sumo_synched/trunk@20962 afbd958f-9f77-42d5-a016-97a22340ccf4
  • Loading branch information
namdre committed Jun 14, 2016
1 parent e884ab0 commit 9d90f1a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
5 changes: 4 additions & 1 deletion sumo/src/netedit/GNEEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,13 +725,16 @@ GNEEdge::addLane(GNELane* lane, const NBEdge::Lane& laneAttrs) {

void
GNEEdge::removeLane(GNELane* lane) {
if (myLanes.size() == 0) {
throw ProcessError("Should not remove the last lane from an edge\n");
}
if (lane == 0) {
lane = myLanes.back();
}
myNBEdge.deleteLane(lane->getIndex());
lane->decRef("GNEEdge::removeLane");
myLanes.erase(myLanes.begin() + lane->getIndex());
if (myLanes.back()->unreferenced()) {
if (lane->unreferenced()) {
delete lane;
}
// udate indices
Expand Down
37 changes: 21 additions & 16 deletions sumo/src/netedit/GNENet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,24 +315,29 @@ GNENet::deleteEdge(GNEEdge* edge, GNEUndoList* undoList) {

void
GNENet::deleteLane(GNELane* lane, GNEUndoList* undoList) {
undoList->p_begin("delete lane");
GNEEdge* edge = &lane->getParentEdge();
const NBEdge::Lane& laneAttrs = edge->getNBEdge()->getLaneStruct(lane->getIndex());
const bool sidewalk = laneAttrs.permissions == SVC_PEDESTRIAN;
undoList->add(new GNEChange_Lane(edge, lane, laneAttrs, false), true);
if (gSelected.isSelected(GLO_LANE, lane->getGlID())) {
std::set<GUIGlID> deselected;
deselected.insert(lane->getGlID());
undoList->add(new GNEChange_Selection(std::set<GUIGlID>(), deselected, true), true);
}
if (sidewalk) {
edge->getSource()->removeFromCrossings(edge, undoList);
edge->getDest()->removeFromCrossings(edge, undoList);
edge->getSource()->setLogicValid(false, undoList);
edge->getDest()->setLogicValid(false, undoList);
if (edge->getNBEdge()->getNumLanes() == 1) {
// remove the whole edge instead
deleteEdge(edge, undoList);
} else {
undoList->p_begin("delete lane");
const NBEdge::Lane& laneAttrs = edge->getNBEdge()->getLaneStruct(lane->getIndex());
const bool sidewalk = laneAttrs.permissions == SVC_PEDESTRIAN;
undoList->add(new GNEChange_Lane(edge, lane, laneAttrs, false), true);
if (gSelected.isSelected(GLO_LANE, lane->getGlID())) {
std::set<GUIGlID> deselected;
deselected.insert(lane->getGlID());
undoList->add(new GNEChange_Selection(std::set<GUIGlID>(), deselected, true), true);
}
if (sidewalk) {
edge->getSource()->removeFromCrossings(edge, undoList);
edge->getDest()->removeFromCrossings(edge, undoList);
edge->getSource()->setLogicValid(false, undoList);
edge->getDest()->setLogicValid(false, undoList);
}
requireRecompute();
undoList->p_end();
}
requireRecompute();
undoList->p_end();
}


Expand Down

0 comments on commit 9d90f1a

Please sign in to comment.