Skip to content

Commit

Permalink
Fix loading of Python Init method with unsaved features
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Jan 8, 2013
1 parent 0ca96a8 commit c759740
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/app/qgsattributedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,19 +348,23 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat
.arg( vl->id() )
.arg(( unsigned long ) vl );

QString feature = QString( "_qgis_feature_%1 = wrapinstance( %2, qgis.core.QgsFeature )" )
.arg( mFeature->id() )
// Generate the unique ID of this feature. We used to use feature ID but some providers
// return a ID that is an invalid python variable when we have new unsaved features.
QDateTime dt = QDateTime::currentDateTime();
QString featurevarname = QString( "_qgis_feature_%1" ).arg( dt.toString( "yyyyMMddhhmmsszzz" ) );
QString feature = QString( "%1 = wrapinstance( %2, qgis.core.QgsFeature )" )
.arg( featurevarname )
.arg(( unsigned long ) mFeature );

QgsPythonRunner::run( form );
QgsPythonRunner::run( feature );
QgsPythonRunner::run( layer );

QString expr = QString( "%1(_qgis_featureform_%2, _qgis_layer_%3, _qgis_feature_%4)" )
QString expr = QString( "%1(_qgis_featureform_%2, _qgis_layer_%3, %4)" )
.arg( vl->editFormInit() )
.arg( mFormNr )
.arg( vl->id() )
.arg( mFeature->id() );
.arg( featurevarname );

QgsDebugMsg( QString( "running featureForm init: %1" ).arg( expr ) );
QgsPythonRunner::run( expr );
Expand Down

0 comments on commit c759740

Please sign in to comment.