From 086d5cfa28ea1427d1854bdc0b9d0bffc9a43111 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 20 Feb 2024 12:14:48 +1000 Subject: [PATCH] Fix crash when applying vector properties dialog Applyling the field configuration was setting the field properties for the layer, which was triggering a connection to rebuild the dialog properties while we were still mid-way through applying the changes. --- src/gui/vector/qgsattributesformproperties.cpp | 8 +++++++- src/gui/vector/qgsattributesformproperties.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gui/vector/qgsattributesformproperties.cpp b/src/gui/vector/qgsattributesformproperties.cpp index 87f17cfb46da..905eaed0e0c1 100644 --- a/src/gui/vector/qgsattributesformproperties.cpp +++ b/src/gui/vector/qgsattributesformproperties.cpp @@ -84,7 +84,11 @@ QgsAttributesFormProperties::QgsAttributesFormProperties( QgsVectorLayer *layer, connect( pbnSelectEditForm, &QToolButton::clicked, this, &QgsAttributesFormProperties::pbnSelectEditForm_clicked ); connect( mTbInitCode, &QPushButton::clicked, this, &QgsAttributesFormProperties::mTbInitCode_clicked ); - connect( mLayer, &QgsVectorLayer::updatedFields, this, &QgsAttributesFormProperties::updatedFields ); + connect( mLayer, &QgsVectorLayer::updatedFields, this, [this] + { + if ( !mBlockUpdates ) + updatedFields(); + } ); } void QgsAttributesFormProperties::init() @@ -948,6 +952,7 @@ void QgsAttributesFormProperties::store() void QgsAttributesFormProperties::apply() { + mBlockUpdates++; storeAttributeWidgetEdit(); storeAttributeContainerEdit(); storeAttributeTypeDialog(); @@ -1058,6 +1063,7 @@ void QgsAttributesFormProperties::apply() } mLayer->setEditFormConfig( editFormConfig ); + mBlockUpdates--; } diff --git a/src/gui/vector/qgsattributesformproperties.h b/src/gui/vector/qgsattributesformproperties.h index 6c2e56c69ae9..bcf7bde2e148 100644 --- a/src/gui/vector/qgsattributesformproperties.h +++ b/src/gui/vector/qgsattributesformproperties.h @@ -422,6 +422,7 @@ class GUI_EXPORT QgsAttributesFormProperties : public QWidget, public QgsExpress QString mInitFunction; QString mInitFilePath; QString mInitCode; + int mBlockUpdates = 0; };