Skip to content

Commit

Permalink
Clean up return from form Python init function
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Jul 27, 2013
1 parent 157e3b7 commit 763d505
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/gui/qgsattributedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsattributedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.