@@ -56,13 +56,11 @@ def add_new_plan(self):
56
56
plan_layer = PlanLayer .get_from_project ()
57
57
if not plan_layer :
58
58
return
59
+ self .previously_editable = plan_layer .isEditable ()
59
60
60
61
self .set_active_plan (None )
61
62
62
- self .previously_editable = plan_layer .isEditable ()
63
- if not plan_layer .isEditable ():
64
- plan_layer .startEditing ()
65
-
63
+ plan_layer .startEditing ()
66
64
self .digitize_map_tool .setLayer (plan_layer )
67
65
iface .mapCanvas ().setMapTool (self .digitize_map_tool )
68
66
@@ -77,12 +75,14 @@ def _plan_geom_digitized(self, feature: QgsFeature):
77
75
plan_attributes = attribute_form .get_plan_attributes ()
78
76
plan_attributes .geom = feature .geometry ()
79
77
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 ()
86
86
87
87
iface .mapCanvas ().setMapTool (self .previous_map_tool )
88
88
0 commit comments