Skip to content

Commit 03da1fc

Browse files
committedMay 13, 2015
Generate unique variable names for python init form
Fix #12676 Fix #12711 Fix #12729
1 parent d64086d commit 03da1fc

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed
 

‎src/gui/qgsattributeform.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,8 @@ void QgsAttributeForm::initPython()
530530
QString numArgs;
531531
QgsPythonRunner::eval( QString( "len(inspect.getargspec(%1)[0])" ).arg( module ), numArgs );
532532

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

535536
QString form = QString( "%1 = sip.wrapinstance( %2, qgis.gui.QgsAttributeForm )" )
536537
.arg( mPyFormVarName )

‎src/gui/qgsattributeformlegacyinterface.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ QgsAttributeFormLegacyInterface::QgsAttributeFormLegacyInterface( const QString&
2727
, mPyFunctionName( function )
2828
, mPyFormVarName( pyFormName )
2929
{
30-
mPyLayerVarName = QString( "_qgis_layer_%1" ).arg( form->layer()->id() );
30+
static int sLayerCounter = 0;
31+
mPyLayerVarName = QString( "_qgis_layer_%1_%2" ).arg( form->layer()->id() ).arg( sLayerCounter++ );
3132
mPyLayerVarName.replace( QRegExp( "[^a-zA-Z0-9_]" ), "_" ); // clean identifier
3233

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

0 commit comments

Comments
 (0)
Please sign in to comment.