From b5f047d2d37e396b92e46473e4f24c0aeca910ea Mon Sep 17 00:00:00 2001 From: "Juergen E. Fischer" Date: Wed, 22 Oct 2014 00:24:35 +0200 Subject: [PATCH] keep add feature action until non-modal attribute form is closed (fixes #11461) --- src/app/qgsfeatureaction.cpp | 13 ++++++------- src/app/qgsmaptooladdfeature.cpp | 7 +++++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/app/qgsfeatureaction.cpp b/src/app/qgsfeatureaction.cpp index fb03b05134a..10eff5b94bc 100644 --- a/src/app/qgsfeatureaction.cpp +++ b/src/app/qgsfeatureaction.cpp @@ -192,18 +192,17 @@ bool QgsFeatureAction::addFeature( const QgsAttributeMap& defaultAttributes, boo dialog->setIsAddDialog( true ); dialog->setEditCommandMessage( text() ); - connect( dialog->attributeForm(), SIGNAL( featureSaved( QgsFeature ) ), this, SLOT( onFeatureSaved( QgsFeature ) ) ); + connect( dialog->attributeForm(), SIGNAL( featureSaved( const QgsFeature & ) ), this, SLOT( onFeatureSaved( const QgsFeature & ) ) ); - if ( showModal ) - { - dialog->setAttribute( Qt::WA_DeleteOnClose ); - dialog->exec(); - } - else + if ( !showModal ) { + setParent( dialog ); // keep dialog until the dialog is closed and destructed dialog->show(); // will also delete the dialog on close (show() is overridden) return true; } + + dialog->setAttribute( Qt::WA_DeleteOnClose ); + dialog->exec(); } // Will be set in the onFeatureSaved SLOT diff --git a/src/app/qgsmaptooladdfeature.cpp b/src/app/qgsmaptooladdfeature.cpp index 4c7fc13eeed..0c0bdea24f0 100644 --- a/src/app/qgsmaptooladdfeature.cpp +++ b/src/app/qgsmaptooladdfeature.cpp @@ -42,8 +42,11 @@ QgsMapToolAddFeature::~QgsMapToolAddFeature() bool QgsMapToolAddFeature::addFeature( QgsVectorLayer *vlayer, QgsFeature *f, bool showModal ) { - QgsFeatureAction action( tr( "add feature" ), *f, vlayer, -1, -1, this ); - return action.addFeature( QgsAttributeMap(), showModal ); + QgsFeatureAction *action = new QgsFeatureAction( tr( "add feature" ), *f, vlayer, -1, -1, this ); + bool res = action->addFeature( QgsAttributeMap(), showModal ); + if ( showModal ) + delete action; + return res; } void QgsMapToolAddFeature::activate()