Bug report #15737

Editing a form opened via openFeatureForm crashes qgis

Added by Regis Haubourg about 8 years ago. Updated about 8 years ago.

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

Description

Hi,
on 2.16.3 (either compiled or from binaries) and master 7d00cae4bbb723aaf4a2c1e51a9a485c402bc180 (23th of september)

I open a form using openFeatureForm(layer, feature) from python action. Validating the form will crash qgis at first attempt.
This is NOT related to UI form, I get the crash with Autogenerated or drag and drop form.

Python action definition used to launch the edit form is:

registry = QgsMapLayerRegistry.instance()
layer = registry.mapLayer('[% @layer_id %]')
request = QgsFeatureRequest().setFilterFid([% $id %])
feature = next(layer.getFeatures(request))
qgis.utils.iface.openFeatureForm(layer, feature, 0, 1)

Using Hotlink plugin to trigger the same action leads to the same too.

gdb trace here : [[http://pastebin.com/LC0KaW5q]]

a sample project + data to reproduce is attached to the ticket

I declare it as regression since it has been working since early 2.x for me.

CRASH_FORM_via_openFeatureForm.zip (1.13 MB) Regis Haubourg, 2016-10-21 02:34 AM

Associated revisions

Revision 9ecdf610
Added by Hugo Mercier about 8 years ago

Don't delete QgsAttributeDialog too early. Fixes #15737

Revision 91661421
Added by Hugo Mercier about 8 years ago

Merge pull request #3688 from mhugo/fix_15737

Don't delete QgsAttributeDialog too early. Fixes #15737

Revision 9f228d4b
Added by Hugo Mercier about 8 years ago

Don't delete QgsAttributeDialog too early. Fixes #15737

(cherry picked from commit 9ecdf6101433)

Revision 1e6b5eb4
Added by Hugo Mercier about 8 years ago

Don't delete QgsAttributeDialog too early. Fixes #15737

History

#1 Updated by Regis Haubourg about 8 years ago

It seems that only osgeo4w is not affected

#2 Updated by Hugo Mercier about 8 years ago

If you call openFeatureForm with modal = False, it does not crash

qgis.utils.iface.openFeatureForm(layer, feature, False, False)

#3 Updated by Regis Haubourg about 8 years ago

Confirmed!
you gave me a nice workaround, thanks.

#4 Updated by Hugo Mercier about 8 years ago

Ok, there is something strange around QgsAttributeDialog::show that is overloaded. It forces the dialog to be deleted on closing.

Then when the feature is accessed, the dialog is dead.
https://github.com/qgis/QGIS/blob/master/src/app/qgsfeatureaction.cpp#L125

#5 Updated by Hugo Mercier about 8 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF