Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Generate unique variable names for python init form
Fix #12676
Fix #12711
Fix #12729
  • Loading branch information
m-kuhn committed May 13, 2015
1 parent 1e08bc0 commit 9d7a650
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/gui/qgsattributeform.cpp
Expand Up @@ -530,7 +530,8 @@ void QgsAttributeForm::initPython()
QString numArgs;
QgsPythonRunner::eval( QString( "len(inspect.getargspec(%1)[0])" ).arg( module ), numArgs );

mPyFormVarName = QString( "_qgis_featureform_%1" ).arg( mFormNr );
static int sFormId = 0;
mPyFormVarName = QString( "_qgis_featureform_%1_%2" ).arg( mFormNr ).arg( sFormId++ );

QString form = QString( "%1 = sip.wrapinstance( %2, qgis.gui.QgsAttributeForm )" )
.arg( mPyFormVarName )
Expand Down
3 changes: 2 additions & 1 deletion src/gui/qgsattributeformlegacyinterface.cpp
Expand Up @@ -27,7 +27,8 @@ QgsAttributeFormLegacyInterface::QgsAttributeFormLegacyInterface( const QString&
, mPyFunctionName( function )
, mPyFormVarName( pyFormName )
{
mPyLayerVarName = QString( "_qgis_layer_%1" ).arg( form->layer()->id() );
static int sLayerCounter = 0;
mPyLayerVarName = QString( "_qgis_layer_%1_%2" ).arg( form->layer()->id() ).arg( sLayerCounter++ );
mPyLayerVarName.replace( QRegExp( "[^a-zA-Z0-9_]" ), "_" ); // clean identifier

QString initLayer = QString( "%1 = sip.wrapinstance( %2, qgis.core.QgsVectorLayer )" )
Expand Down

0 comments on commit 9d7a650

Please sign in to comment.