File tree 2 files changed +17
-6
lines changed
2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change 16
16
from arho_feature_template .qgis_plugin_tools .tools .i18n import setup_translation
17
17
from arho_feature_template .qgis_plugin_tools .tools .resources import plugin_name
18
18
from arho_feature_template .utils .db_utils import get_existing_database_connection_names
19
- from arho_feature_template .utils .misc_utils import (
20
- check_layer_changes ,
21
- commit_all_layer_changes ,
22
- prompt_commit_changes ,
23
- )
19
+ from arho_feature_template .utils .misc_utils import handle_unsaved_changes
24
20
25
21
if TYPE_CHECKING :
26
22
from qgis .gui import QgisInterface , QgsMapTool
@@ -187,7 +183,7 @@ def load_existing_land_use_plan(self) -> None:
187
183
QMessageBox .critical (None , "Error" , "No database connections found." )
188
184
return
189
185
190
- if check_layer_changes () and ( not prompt_commit_changes () or not commit_all_layer_changes () ):
186
+ if not handle_unsaved_changes ( ):
191
187
return
192
188
193
189
dialog = LoadPlanDialog (None , connections )
Original file line number Diff line number Diff line change @@ -40,3 +40,18 @@ def commit_all_layer_changes() -> bool:
40
40
all_committed = False
41
41
42
42
return all_committed
43
+
44
+
45
+ def handle_unsaved_changes () -> bool :
46
+ """
47
+ Wrapper function to check for unsaved changes, prompt user to commit, and commit changes if chosen.
48
+ Returns:
49
+ bool: True if changes are committed or no changes were found;
50
+ False if user does not want to commit or if commit fails.
51
+ """
52
+ if check_layer_changes ():
53
+ if not prompt_commit_changes ():
54
+ return False
55
+ if not commit_all_layer_changes ():
56
+ return False
57
+ return True
You can’t perform that action at this time.
0 commit comments