Skip to content

Commit b5f047d

Browse files
committedOct 21, 2014
keep add feature action until non-modal attribute form is closed (fixes #11461)
1 parent 9dbeefb commit b5f047d

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed
 

‎src/app/qgsfeatureaction.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,17 @@ bool QgsFeatureAction::addFeature( const QgsAttributeMap& defaultAttributes, boo
192192
dialog->setIsAddDialog( true );
193193
dialog->setEditCommandMessage( text() );
194194

195-
connect( dialog->attributeForm(), SIGNAL( featureSaved( QgsFeature ) ), this, SLOT( onFeatureSaved( QgsFeature ) ) );
195+
connect( dialog->attributeForm(), SIGNAL( featureSaved( const QgsFeature & ) ), this, SLOT( onFeatureSaved( const QgsFeature & ) ) );
196196

197-
if ( showModal )
198-
{
199-
dialog->setAttribute( Qt::WA_DeleteOnClose );
200-
dialog->exec();
201-
}
202-
else
197+
if ( !showModal )
203198
{
199+
setParent( dialog ); // keep dialog until the dialog is closed and destructed
204200
dialog->show(); // will also delete the dialog on close (show() is overridden)
205201
return true;
206202
}
203+
204+
dialog->setAttribute( Qt::WA_DeleteOnClose );
205+
dialog->exec();
207206
}
208207

209208
// Will be set in the onFeatureSaved SLOT

‎src/app/qgsmaptooladdfeature.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ QgsMapToolAddFeature::~QgsMapToolAddFeature()
4242

4343
bool QgsMapToolAddFeature::addFeature( QgsVectorLayer *vlayer, QgsFeature *f, bool showModal )
4444
{
45-
QgsFeatureAction action( tr( "add feature" ), *f, vlayer, -1, -1, this );
46-
return action.addFeature( QgsAttributeMap(), showModal );
45+
QgsFeatureAction *action = new QgsFeatureAction( tr( "add feature" ), *f, vlayer, -1, -1, this );
46+
bool res = action->addFeature( QgsAttributeMap(), showModal );
47+
if ( showModal )
48+
delete action;
49+
return res;
4750
}
4851

4952
void QgsMapToolAddFeature::activate()

0 commit comments

Comments
 (0)
Please sign in to comment.