From 08d9a0267b699d95e5b9c56aa108155ce7556bde Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Thu, 12 Apr 2018 13:18:23 -0400 Subject: [PATCH] Guard code to avoid deleting a turn twice (see #4968, #4928) --- modules/ui/fields/restrictions.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/ui/fields/restrictions.js b/modules/ui/fields/restrictions.js index 32e6e9790..e11189ca1 100644 --- a/modules/ui/fields/restrictions.js +++ b/modules/ui/fields/restrictions.js @@ -355,6 +355,7 @@ export function uiFieldRestrictions(field, context) { return; } else if (datum.restrictionID && !datum.only) { // NO -> ONLY + var seen = {}; var datumOnly = _cloneDeep(datum); datumOnly.only = true; restrictionType = restrictionType.replace(/^no/, 'only'); @@ -365,10 +366,14 @@ export function uiFieldRestrictions(field, context) { extraActions = []; _oldTurns = []; for (i = 0; i < turns.length; i++) { - if (turns[i].direct && turns[i].path[1] === datum.path[1]) { - turns[i].restrictionType = osmInferRestriction(vgraph, turns[i], projection); - _oldTurns.push(turns[i]); - extraActions.push(actionUnrestrictTurn(turns[i])); + var turn = turns[i]; + if (seen[turn.restrictionID]) continue; // avoid deleting the turn twice (#4968, #4928) + + if (turn.direct && turn.path[1] === datum.path[1]) { + seen[turns[i].restrictionID] = true; + turn.restrictionType = osmInferRestriction(vgraph, turn, projection); + _oldTurns.push(turn); + extraActions.push(actionUnrestrictTurn(turn)); } }