Skip to content

Commit 6c8bf4b

Browse files
committed
Revert to previous plan if new plan cancelled
1 parent 84f707f commit 6c8bf4b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

arho_feature_template/core/plan_manager.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,11 @@ def add_new_plan(self):
5656
plan_layer = PlanLayer.get_from_project()
5757
if not plan_layer:
5858
return
59+
self.previously_editable = plan_layer.isEditable()
5960

6061
self.set_active_plan(None)
6162

62-
self.previously_editable = plan_layer.isEditable()
63-
if not plan_layer.isEditable():
64-
plan_layer.startEditing()
65-
63+
plan_layer.startEditing()
6664
self.digitize_map_tool.setLayer(plan_layer)
6765
iface.mapCanvas().setMapTool(self.digitize_map_tool)
6866

@@ -77,12 +75,14 @@ def _plan_geom_digitized(self, feature: QgsFeature):
7775
plan_attributes = attribute_form.get_plan_attributes()
7876
plan_attributes.geom = feature.geometry()
7977
feature = save_plan(plan_attributes)
80-
plan_layer = PlanLayer.get_from_project()
81-
if plan_layer.isEditable():
82-
plan_layer.commitChanges()
83-
self.set_active_plan(feature["id"])
84-
if self.previously_editable:
85-
plan_layer.startEditing()
78+
plan_to_be_activated = feature["id"]
79+
else:
80+
plan_to_be_activated = self.previous_active_plan_id
81+
82+
self.set_active_plan(plan_to_be_activated)
83+
84+
if self.previously_editable:
85+
plan_layer.startEditing()
8686

8787
iface.mapCanvas().setMapTool(self.previous_map_tool)
8888

0 commit comments

Comments
 (0)