Skip to content
Permalink
Browse files
Fix loading of Python Init method with unsaved features
  • Loading branch information
NathanW2 committed Jan 8, 2013
1 parent 0ca96a8 commit c759740a32dd4cbbf5459dc8a1d692b91bd11bba
Showing with 8 additions and 4 deletions.
  1. +8 −4 src/app/qgsattributedialog.cpp
@@ -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 );

0 comments on commit c759740

Please sign in to comment.