Bug report #12676

Subforms with Python init function crash when adding values

Added by Médéric RIBREUX almost 9 years ago. Updated almost 9 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:-
Category:Forms
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:20783

Description

Hello,

I am not anymore able to use subforms (based on project relations) which have a Python init function.
When trying to add values (or even cancelling new values), I've got a Python error dialog box:

An error occured during execution of following code:
del _qgis_layer_ILL_PAE20150202141820409

Traceback (most recent call last):
  File "", line 1, in 
NameError: name '_qgis_layer_ILL_PAE20150202141820409' is not defined

It seems that QGIS is trying to call an already deleted (or not already created) Python variable.

When I add new objects on the subform, I've got another error text:

An error occured during execution of following code:
DBPAT_FULL.testSub( _qgis_featureform_27, _qgis_layer_ILL_PAE20150202141820409, _qgis_feature_20150430144850051)

Traceback (most recent call last):
  File "", line 1, in 
NameError: name '_qgis_layer_ILL_PAE20150202141820409' is not defined

This time it is launching my Python init fuction (named testSub) with an invalid reference to the layer...

It is not a blocker because you are able to add new lins to subforms. But the error dialog is always triggered when you close the parent form which is very annoying for end users.

The problem doesn't seem to come from the Python init function code because I've got the error dialog even with the following trivial function:

def testSub(dialog, layerid, featureid):
    QgsMessageLog.logMessage(u"testSub !", "DBPAT", QgsMessageLog.INFO)

When there is no Python init function, there is no error !

For me it is very annoying as it was not present in 2.6.1. QGIS 2.8.1 and master (well, nightly-build) are affected...

Thanks for (trying) to fix this bug...


Related issues

Related to QGIS Application - Bug report #12711: Error when opening more than one form with init function Closed 2015-05-07
Related to QGIS Application - Bug report #13080: QT Forms. Opening two forms using IdentifyFeatures crashes Rejected 2015-07-06

Associated revisions

Revision 03da1fca
Added by Matthias Kuhn almost 9 years ago

Generate unique variable names for python init form

Fix #12676
Fix #12711
Fix #12729

Revision 9d7a650c
Added by Matthias Kuhn almost 9 years ago

Generate unique variable names for python init form

Fix #12676
Fix #12711
Fix #12729

History

#1 Updated by Giovanni Manghi almost 9 years ago

  • Target version changed from Future Release - High Priority to Version 2.8.2
  • Priority changed from High to Severe/Regression

#2 Updated by Matthias Kuhn almost 9 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF