@@ -633,34 +633,41 @@ void QgsAttributeForm::initPython()
633
633
634
634
QgsPythonRunner::run ( " import inspect" );
635
635
QString numArgs;
636
- QgsPythonRunner::eval ( QString ( " len(inspect.getargspec(%1)[0])" ).arg ( initFunction ), numArgs );
637
636
638
- static int sFormId = 0 ;
639
- mPyFormVarName = QString ( " _qgis_featureform_%1_%2" ).arg ( mFormNr ).arg ( sFormId ++ );
637
+ // Check for eval result
638
+ if ( QgsPythonRunner::eval ( QString ( " len(inspect.getargspec(%1)[0])" ).arg ( initFunction ), numArgs ) )
639
+ {
640
+ static int sFormId = 0 ;
641
+ mPyFormVarName = QString ( " _qgis_featureform_%1_%2" ).arg ( mFormNr ).arg ( sFormId ++ );
640
642
641
- QString form = QString ( " %1 = sip.wrapinstance( %2, qgis.gui.QgsAttributeForm )" )
642
- .arg ( mPyFormVarName )
643
- .arg (( unsigned long ) this );
643
+ QString form = QString ( " %1 = sip.wrapinstance( %2, qgis.gui.QgsAttributeForm )" )
644
+ .arg ( mPyFormVarName )
645
+ .arg (( unsigned long ) this );
644
646
645
- QgsPythonRunner::run ( form );
647
+ QgsPythonRunner::run ( form );
646
648
647
- QgsDebugMsg ( QString ( " running featureForm init: %1" ).arg ( mPyFormVarName ) );
649
+ QgsDebugMsg ( QString ( " running featureForm init: %1" ).arg ( mPyFormVarName ) );
648
650
649
- // Legacy
650
- if ( numArgs == " 3" )
651
- {
652
- addInterface ( new QgsAttributeFormLegacyInterface ( initFunction, mPyFormVarName , this ) );
651
+ // Legacy
652
+ if ( numArgs == " 3" )
653
+ {
654
+ addInterface ( new QgsAttributeFormLegacyInterface ( initFunction, mPyFormVarName , this ) );
655
+ }
656
+ else
657
+ {
658
+ #if 0
659
+ QString expr = QString( "%1(%2)" )
660
+ .arg( mLayer->editFormInit() )
661
+ .arg( mPyFormVarName );
662
+ QgsAttributeFormInterface* iface = QgsPythonRunner::evalToSipObject<QgsAttributeFormInterface*>( expr, "QgsAttributeFormInterface" );
663
+ if ( iface )
664
+ addInterface( iface );
665
+ #endif
666
+ }
653
667
}
654
668
else
655
669
{
656
- #if 0
657
- QString expr = QString( "%1(%2)" )
658
- .arg( mLayer->editFormInit() )
659
- .arg( mPyFormVarName );
660
- QgsAttributeFormInterface* iface = QgsPythonRunner::evalToSipObject<QgsAttributeFormInterface*>( expr, "QgsAttributeFormInterface" );
661
- if ( iface )
662
- addInterface( iface );
663
- #endif
670
+ QgsLogger::warning ( QString ( " There was an error evaluating the python init function!" ) );
664
671
}
665
672
}
666
673
}
0 commit comments