Skip to content
Permalink
Browse files
avoid opening multiple attribute forms for a single feature in identify
(fixes #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 20197c2fa31e454b095be6b68771274ec5540c39
Showing with 22 additions and 3 deletions.
  1. +22 −3 src/app/qgsfeatureaction.cpp
@@ -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() )
@@ -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 );
@@ -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 );

3 comments on commit 20197c2

@bartoszschilling

This comment has been minimized.

Copy link

@bartoszschilling bartoszschilling replied Jun 29, 2017

It's nice to have this functionality. Thank you.
However, there is one nasty bug in this commit.

Dialog object name generation with

QString( "featureactiondlg:%1:%2" ).arg( mLayer->id(), f->id() )

calls overloaded function

QString QString::arg(const QString & a, int fieldWidth = 0, const QChar & fillChar = QLatin1Char( ' ' )) const

instead

QString QString::arg(const QString & a1, const QString & a2) const

It becomes huge performance issue when QgsCollapsibleGroupBox saves configuration using this object name. On Ubuntu with layers with big ids it causes configuration file to grow very fast to 10MB~100MB which make QGIS almost unusable.

@NathanW2

This comment has been minimized.

Copy link
Member

@NathanW2 NathanW2 replied Jun 30, 2017

@barteksch good find.

@jef-n

This comment has been minimized.

Copy link
Member Author

@jef-n jef-n replied Jun 30, 2017

Fixed in 392b638 and 6dfcf40

Please sign in to comment.