From 54c3402a1f26da8ae4869344ecd92b6d7143841d Mon Sep 17 00:00:00 2001 From: Vahid Mohammadi Gahrooei Date: Fri, 29 Oct 2021 17:35:32 +0200 Subject: [PATCH] fix: do not create already existing transitions --- source/rafcon/core/states/container_state.py | 25 +++++++++++--------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/source/rafcon/core/states/container_state.py b/source/rafcon/core/states/container_state.py index f971c5851..f7cf60b35 100644 --- a/source/rafcon/core/states/container_state.py +++ b/source/rafcon/core/states/container_state.py @@ -1042,22 +1042,25 @@ def substitute_state(self, state_id, state): act_output_data_port_by_name = {op.name: op for op in state.output_data_ports.values()} for t in related_transitions['external']['self']: - new_t_id = self.add_transition(state_id, t.from_outcome, state_id, t.to_outcome, t.transition_id) - re_create_io_going_t_ids.append(new_t_id) - assert new_t_id == t.transition_id + if t.transition_id not in self._transitions: + new_t_id = self.add_transition(state_id, t.from_outcome, state_id, t.to_outcome, t.transition_id) + re_create_io_going_t_ids.append(new_t_id) + assert new_t_id == t.transition_id for t in related_transitions['external']['ingoing']: - new_t_id = self.add_transition(t.from_state, t.from_outcome, state_id, t.to_outcome, t.transition_id) - re_create_io_going_t_ids.append(new_t_id) - assert new_t_id == t.transition_id - - for t in related_transitions['external']['outgoing']: - from_outcome = act_outcome_ids_by_name.get(old_outcome_names[t.from_outcome], None) - if from_outcome is not None: - new_t_id = self.add_transition(state_id, from_outcome, t.to_state, t.to_outcome, t.transition_id) + if t.transition_id not in self._transitions: + new_t_id = self.add_transition(t.from_state, t.from_outcome, state_id, t.to_outcome, t.transition_id) re_create_io_going_t_ids.append(new_t_id) assert new_t_id == t.transition_id + for t in related_transitions['external']['outgoing']: + if t.transition_id not in self._transitions: + from_outcome = act_outcome_ids_by_name.get(old_outcome_names[t.from_outcome], None) + if from_outcome is not None: + new_t_id = self.add_transition(state_id, from_outcome, t.to_state, t.to_outcome, t.transition_id) + re_create_io_going_t_ids.append(new_t_id) + assert new_t_id == t.transition_id + for old_ip in old_input_data_ports.values(): ip = act_input_data_port_by_name.get(old_input_data_ports[old_ip.data_port_id].name, None) if ip is not None and ip.data_type == old_input_data_ports[old_ip.data_port_id].data_type: