Skip to content
Permalink
Browse files

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 9d7a650c6b235a88436eb2d397cd97b9604c92f2
Showing with 4 additions and 2 deletions.
  1. +2 −1 src/gui/qgsattributeform.cpp
  2. +2 −1 src/gui/qgsattributeformlegacyinterface.cpp
@@ -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 )
@@ -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 )" )

0 comments on commit 9d7a650

Please sign in to comment.
You can’t perform that action at this time.