keep add feature action until non-modal attribute form is closed (fixes #11461)

This commit is contained in:
Juergen E. Fischer 2014-10-22 00:24:35 +02:00
parent 9dbeefb688
commit b5f047d2d3
2 changed files with 11 additions and 9 deletions

View File

@ -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

View File

@ -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()