@@ -91,8 +91,8 @@ def __init__(self):
91
91
self .new_feature_dock .hide ()
92
92
93
93
# Initialize digitize tools
94
- self .digitize_map_tool = PlanDigitizeMapTool (iface .mapCanvas (), iface .cadDockWidget ())
95
- self .digitize_map_tool .digitizingCompleted .connect (self ._plan_geom_digitized )
94
+ self .plan_digitize_map_tool = PlanDigitizeMapTool (iface .mapCanvas (), iface .cadDockWidget ())
95
+ self .plan_digitize_map_tool .digitizingCompleted .connect (self ._plan_geom_digitized )
96
96
97
97
self .feature_digitize_map_tool = None
98
98
self .initialize_feature_digitize_map_tool ()
@@ -103,6 +103,10 @@ def __init__(self):
103
103
)
104
104
self .inspect_plan_feature_tool .edit_feature_requested .connect (self .edit_plan_feature )
105
105
106
+ # Initialize lambda service
107
+ self .lambda_service = LambdaService ()
108
+ self .lambda_service .jsons_received .connect (self .save_plan_jsons )
109
+
106
110
def toggle_identify_plan_features (self , activate : bool ): # noqa: FBT001
107
111
if activate :
108
112
self .previous_map_tool = iface .mapCanvas ().mapTool ()
@@ -152,8 +156,8 @@ def add_new_plan(self):
152
156
self .set_active_plan (None )
153
157
154
158
plan_layer .startEditing ()
155
- self .digitize_map_tool .setLayer (plan_layer )
156
- iface .mapCanvas ().setMapTool (self .digitize_map_tool )
159
+ self .plan_digitize_map_tool .setLayer (plan_layer )
160
+ iface .mapCanvas ().setMapTool (self .plan_digitize_map_tool )
157
161
158
162
def edit_plan (self ):
159
163
plan_layer = PlanLayer .get_from_project ()
@@ -306,8 +310,6 @@ def get_plan_json(self):
306
310
QMessageBox .critical (None , "Virhe" , "Ei aktiivista kaavaa." )
307
311
return
308
312
309
- self .lambda_service = LambdaService ()
310
- self .lambda_service .jsons_received .connect (self .save_plan_jsons )
311
313
self .lambda_service .serialize_plan (plan_id )
312
314
313
315
def save_plan_jsons (self , plan_json , outline_json ):
@@ -342,6 +344,30 @@ def create_new_regulation_group(self):
342
344
else :
343
345
save_regulation_group (new_regulation_group_form .model )
344
346
347
+ def unload (self ):
348
+ # Lambda service
349
+ self .lambda_service .jsons_received .disconnect (self .save_plan_jsons )
350
+ self .lambda_service .deleteLater ()
351
+
352
+ # Feature digitize tool
353
+ if self .feature_digitize_map_tool :
354
+ self .feature_digitize_map_tool .digitizingCompleted .disconnect ()
355
+ self .feature_digitize_map_tool .digitizingFinished .disconnect ()
356
+ self .feature_digitize_map_tool .deleteLater ()
357
+
358
+ # Plan digitize tool
359
+ self .plan_digitize_map_tool .digitizingCompleted .disconnect (self ._plan_geom_digitized )
360
+ self .plan_digitize_map_tool .deleteLater ()
361
+
362
+ # Inspect plan feature tool
363
+ self .inspect_plan_feature_tool .edit_feature_requested .disconnect (self .edit_plan_feature )
364
+ self .inspect_plan_feature_tool .deleteLater ()
365
+
366
+ # New feature dock
367
+ self .new_feature_dock .tool_activated .disconnect (self .add_new_plan_feature )
368
+ iface .removeDockWidget (self .new_feature_dock )
369
+ self .new_feature_dock .deleteLater ()
370
+
345
371
346
372
def regulation_group_library_from_active_plan () -> RegulationGroupLibrary :
347
373
category_features = list (PlanRegulationGroupTypeLayer .get_features ())
0 commit comments