Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Console crashes when removing non-existent vector layer #18

Open
rduivenvoorde opened this issue Jun 25, 2016 · 1 comment
Open

Comments

@rduivenvoorde
Copy link
Owner

rduivenvoorde commented Jun 25, 2016

Imported from Redmine: http://hub.qgis.org/issues/10755
Originally created on Mon Jun 30 02:16:22 -0700 2014, last update on Sat Nov 07 06:02:05 -0800 2015
Author: @rduivenvoorde rduivenvoorde@foo.bar (Q: should we show email?, Q: should we create @ mention?)

Description

When I try to run the following code (included in attachment crash.py) from Python Console, the QGis crashes by saying:

minidump written to C:\Users\rauni\AppData\Local\Temp\qgis-20140630-120940-6060-5464-8fdd08a.dmp (see attached minidump)

However, if I run the code (included in attachment no_crash.py), then no error occurs.

Code is following:

 iface = qgis.utils.iface

 rasterLayer = iface.addRasterLayer("crs=EPSG:4326&dpiMode=7&featureCount=10&format=image/png&layers=natura2000&styles=&url=http://geodata.nationaalgeoregister.nl/natura2000/ows", "wms master example", "wms" ) 
 vectorLayer = iface.addVectorLayer("http://geodata.nationaalgeoregister.nl/bestuurlijkegrenzen/wfs?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=bestuurlijkegrenzen:provincies&SRSNAME=EPSG:28992","wfs example","WFS")

 #QgsMapLayerRegistry.instance().addMapLayer(vectorLayer) #if this line is commented out, a crash occurs.

 # additional code...

 QgsMapLayerRegistry.instance().removeMapLayer(vectorLayer.id())

I am using the versions:
QGIS versioon 2.4.0-Chugiak
QGIS koodi revisjon 8fdd08a
Kompileeritud Qt-le 4.8.5
Töötab Qt-s 4.8.5
Kompileeritud GDAL/OGR-le 1.11.0
Töötab GDAL/OGR-s 1.11.0
Compiled against GEOS 3.4.2-CAPI-1.8.2
Running against GEOS 3.4.2-CAPI-1.8.2 r3921
PostgreSQL kliendi versioon 9.2.4
SpatiaLite versioon 4.1.1
QWT versioon 5.2.3
PROJ.4 Versioon 480
QScintilla2 Version 2.7.2

I am using Windows 7, if it matters.

Attachments

crash.py - crash file. Rauni Lillemets, 06/30/2014 02:16 am
crash.py.zip

no_crash.py - no crash occurs. Rauni Lillemets, 06/30/2014 02:16 am
no_crash.py.zip

Related

Issue #17

@rduivenvoorde
Copy link
Owner Author

rduivenvoorde commented Jun 25, 2016

History from Redmine

Rauni Lillemets 06/30/2014 02:17 am

File qgis-20140630-120940-6060-5464-8fdd08a.zip added
qgis-20140630-120940-6060-5464-8fdd08a.zip

Matthias Kuhn, m-kuhn

Crashes here only in the following order:

rasterLayer = iface.addRasterLayer("crs=EPSG:4326&dpiMode=7&featureCount=10&format=image/png&layers=natura2000&styles=&url=http://geodata.nationaalgeoregister.nl/natura2000/ows", "wms master example", "wms" ) 
vectorLayer = iface.addVectorLayer("http://geodata.nationaalgeoregister.nl/bestuurlijkegrenzen/wfs?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=bestuurlijkegrenzen:provincies&SRSNAME=EPSG:28992","wfs example","WFS")

QgsMapLayerRegistry.instance().removeMapLayer(vectorLayer.id())
QgsMapLayerRegistry.instance().addMapLayer(vectorLayer) #if this line is commented out, a crash occurs.
QgsMapLayerRegistry.instance().removeMapLayer(vectorLayer.id())

Giovanni Manghi

Category set to PyQGIS Console (mapped to label: 5 CAT: PyQGIS)
Priority changed from Normal to High (mapped to label: 3 PRIO: High)
Causes crash or corruption changed from No to Yes (mapped to label: 3 PRIO: Severe/Regression)

Jürgen Fischer

Matthias Kuhn wrote:

Crashes here only in the following order:

[...]

More detailed:

  • @QgsMapLayerRegistry.addMapLayer@ transfers ownership of the layer
  • @QgsMapLayerRegistry.removeMapLayer@ in turn destructs the layer
  • The python object @vectorLayer@ doesn't notice and hence the call to @vectorLayer.id()@ crashes (before @removeMapLayer@ is even called a second time)

So that's a flaw in the API and a duplicate of #777.

But @crash.py@ doesn't use the layer after it has been removed and doesn't crash here on master.

Status changed from Open to Feedback

Jürgen Fischer

Subject changed from Python Console crashes when removing non-existant vector layer to Python Console crashes when removing non-existent vector layer

Giovanni Manghi

Should we close this as duplicate?

Jürgen Fischer

Status changed from Feedback to Closed
Resolution set to duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants