From 7ae9dd164052f0cc0651bd5f38df43821e96d8ef Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Thu, 10 Oct 2024 14:34:59 +0700 Subject: [PATCH] Avoid needless save when adding a child to a parent that is already part of its dataset --- .../ordered_relation_editor.qml | 18 +++++++++--------- .../relationeditors/relation_editor.qml | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/qml/editorwidgets/relationeditors/ordered_relation_editor.qml b/src/qml/editorwidgets/relationeditors/ordered_relation_editor.qml index b668476d17..b33b1a7506 100644 --- a/src/qml/editorwidgets/relationeditors/ordered_relation_editor.qml +++ b/src/qml/editorwidgets/relationeditors/ordered_relation_editor.qml @@ -131,7 +131,7 @@ EditorWidgetBase { repeat: false onTriggered: { - let saved = save(); + let saved = form.state === 'Add' ? save() : true; if (ProjectUtils.transactionMode(qgisProject) !== Qgis.TransactionMode.Disabled) { // When a transaction mode is enabled, we must fallback to saving the parent feature to have provider-side issues if (!saved) { @@ -375,6 +375,14 @@ EditorWidgetBase { } } + BusyIndicator { + id: busyIndicator + anchors.centerIn: parent + width: 36 + height: 36 + running: orderedRelationModel.isLoading + } + Dialog { id: deleteDialog parent: mainWindow.contentItem @@ -414,14 +422,6 @@ EditorWidgetBase { } } - BusyIndicator { - id: busyIndicator - anchors.centerIn: parent - width: 36 - height: 36 - running: orderedRelationModel.isLoading - } - EmbeddedFeatureForm { id: embeddedPopup diff --git a/src/qml/editorwidgets/relationeditors/relation_editor.qml b/src/qml/editorwidgets/relationeditors/relation_editor.qml index 4bf95d3aee..72498cbdd4 100644 --- a/src/qml/editorwidgets/relationeditors/relation_editor.qml +++ b/src/qml/editorwidgets/relationeditors/relation_editor.qml @@ -141,7 +141,7 @@ EditorWidgetBase { repeat: false onTriggered: { - let saved = save(); + let saved = form.state === 'Add' ? save() : true; if (ProjectUtils.transactionMode(qgisProject) !== Qgis.TransactionMode.Disabled) { // When a transaction mode is enabled, we must fallback to saving the parent feature to have provider-side issues if (!saved) { @@ -175,6 +175,14 @@ EditorWidgetBase { } } } + + BusyIndicator { + id: busyIndicator + anchors.centerIn: parent + width: 36 + height: 36 + running: relationEditorModel.isLoading + } } Component { @@ -320,14 +328,6 @@ EditorWidgetBase { } } - BusyIndicator { - id: busyIndicator - anchors.centerIn: parent - width: 36 - height: 36 - running: relationEditorModel.isLoading - } - EmbeddedFeatureForm { id: embeddedPopup