Skip to content

Commit

Permalink
avoid opening multiple attribute forms for a single feature in identify
Browse files Browse the repository at this point in the history
(fixes qgis#13520)

On behalf of Faunalia, sponsored by ENEL

(cherry picked from commit 7b8fb79)
  • Loading branch information
jef-n committed Apr 20, 2017
1 parent 1bbc39e commit 20197c2
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/app/qgsfeatureaction.cpp
Expand Up @@ -65,6 +65,7 @@ QgsAttributeDialog *QgsFeatureAction::newDialog( bool cloneFeature )

QgsAttributeDialog *dialog = new QgsAttributeDialog( mLayer, f, cloneFeature, parentWidget(), true, context );
dialog->setWindowFlags( dialog->windowFlags() | Qt::Tool );
dialog->setObjectName( QString( "featureactiondlg:%1:%2" ).arg( mLayer->id(), f->id() ) );

QList<QgsAction> actions = mLayer->actions()->actions( QStringLiteral( "Feature" ) );
if ( !actions.isEmpty() )
Expand Down Expand Up @@ -96,10 +97,19 @@ QgsAttributeDialog *QgsFeatureAction::newDialog( bool cloneFeature )

bool QgsFeatureAction::viewFeatureForm( QgsHighlight *h )
{
if ( !mLayer )
if ( !mLayer || !mFeature )
return false;

QgsAttributeDialog *dialog = newDialog( true );
QString name( QString( "featureactiondlg:%1:%2" ).arg( mLayer->id(), mFeature->id() ) );

QgsAttributeDialog *dialog = QgisApp::instance()->findChild<QgsAttributeDialog *>( name );
if ( dialog )
{
dialog->raise();
return true;
}

dialog = newDialog( true );
dialog->setHighlight( h );
// delete the dialog when it is closed
dialog->setAttribute( Qt::WA_DeleteOnClose );
Expand All @@ -126,7 +136,16 @@ bool QgsFeatureAction::editFeature( bool showModal )
}
else
{
QgsAttributeDialog *dialog = newDialog( false );
QString name( QString( "featureactiondlg:%1:%2" ).arg( mLayer->id(), mFeature->id() ) );

QgsAttributeDialog *dialog = QgisApp::instance()->findChild<QgsAttributeDialog *>( name );
if ( dialog )
{
dialog->raise();
return true;
}

dialog = newDialog( false );

if ( !mFeature->isValid() )
dialog->setMode( QgsAttributeForm::AddFeatureMode );
Expand Down

0 comments on commit 20197c2

Please sign in to comment.