Skip to content
Permalink
Browse files
Clean up return from form Python init function
  • Loading branch information
NathanW2 committed Jul 27, 2013
1 parent 157e3b7 commit 763d5057dd68608d109517e34b54d7af8189b7d1
Showing with 9 additions and 2 deletions.
  1. +8 −2 src/gui/qgsattributedialog.cpp
  2. +1 −0 src/gui/qgsattributedialog.h
@@ -423,13 +423,13 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat
QgsPythonRunner::run( feature );
QgsPythonRunner::run( layer );

QString returnvarname = QString( "_qgis_feature_form_%1" ).arg( dt.toString( "yyyyMMddhhmmsszzz" ) );
mReturnvarname = QString( "_qgis_feature_form_%1" ).arg( dt.toString( "yyyyMMddhhmmsszzz" ) );
QString expr = QString( "%5 = %1(_qgis_featureform_%2, _qgis_layer_%3, %4)" )
.arg( vl->editFormInit() )
.arg( mFormNr )
.arg( vl->id() )
.arg( featurevarname )
.arg( returnvarname );
.arg( mReturnvarname );

QgsDebugMsg( QString( "running featureForm init: %1" ).arg( expr ) );
QgsPythonRunner::run( expr );
@@ -550,6 +550,12 @@ void QgsAttributeDialog::dialogDestroyed()
QgsPythonRunner::run( expr );
}

if ( !mReturnvarname.isEmpty() )
{
QString expr = QString( "if locals().has_key('%1'): del %1\n" ).arg( mReturnvarname );
QgsPythonRunner::run( expr );
}

mDialog = NULL;
deleteLater();
}
@@ -73,6 +73,7 @@ class GUI_EXPORT QgsAttributeDialog : public QObject
int mFormNr;
static int smFormCounter;
bool mShowDialogButtons;
QString mReturnvarname;
};

#endif

0 comments on commit 763d505

Please sign in to comment.