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

Crash after calling QgsMapLayerRegistry::addMapLayers #15253

Closed
qgib opened this issue Jun 5, 2012 · 5 comments
Closed

Crash after calling QgsMapLayerRegistry::addMapLayers #15253

qgib opened this issue Jun 5, 2012 · 5 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Plugins

Comments

@qgib
Copy link
Contributor

qgib commented Jun 5, 2012

Author Name: Giuseppe Sucameli (@brushtyler)
Original Redmine Issue: 5747
Affected QGIS version: master
Redmine category:python_plugins


The @QgsMapLayerRegistry.addMapLayer@ is deprecated but the newer version @QgsMapLayerRegistry.addMapLayers@ if called two times cause segfault.

From the python console:

vl1 = QgsVectorLayer("/home/brushtyler/vl1", "test", "ogr")
QgsMapLayerRegistry.instance().addMapLayers([vl1])

vl2 = QgsVectorLayer("/home/brushtyler/vl2", "test", "ogr")
QgsMapLayerRegistry.instance().addMapLayers([vl2])
</code>

Confirmed on both Win7 and Ubuntu 11.04, QGis 1.8

@qgib
Copy link
Contributor Author

qgib commented Jun 5, 2012

Author Name: Giovanni Manghi (@gioman)


is this a regression since 1.7.4?

@qgib
Copy link
Contributor Author

qgib commented Jun 5, 2012

Author Name: Giuseppe Sucameli (@brushtyler)


Giovanni Manghi wrote:

is this a regression since 1.7.4?

no, the QgsMapLayerRegistry::addMapLayers() method is new in 1.8 (it wasn't present in 1.7.x)

@qgib
Copy link
Contributor Author

qgib commented Jun 5, 2012

Author Name: Larry Shaffer (Larry Shaffer)


Giuseppe,

I attempted to confirm with 1.8_1125571 on Mac OS X 10.6.8 and Ubuntu 12.04, but I couldn't get @QgsMapLayerRegistry.addMapLayers()@ to work without an exception being raised:

TypeError: QgsMapLayerRegistry.addMapLayers(list-of-QgsMapLayer, bool theEmitSignal=True): first argument of unbound method must have type 'QgsMapLayerRegistry'

I tried @from qgis.core import QgsMapLayerRegistry@ but ends in same exception.

However, I had no issues adding 7 layers with @QgsMapLayerRegistry.instance().addMapLayers()@, as long as I did not use an existing layer name as the second parameter to the @QgsVectorLayer@ constructor.

This works on both platforms:

v1 = QgsVectorLayer("/data/hr_100kdlg/hr-bnd.shp", "test1", "ogr")
QgsMapLayerRegistry.instance().addMapLayers([v1])
v2 = QgsVectorLayer("/data/hr_100kdlg/hr-rds.shp", "test2", "ogr")
QgsMapLayerRegistry.instance().addMapLayers([v2])
...
v7 = QgsVectorLayer("/data/hr_100kdlg/hr-quads.shp", "test7", "ogr")
QgsMapLayerRegistry.instance().addMapLayers([v7])
</code>

but this causes the crash on both platforms (sometimes took 3 layers):

v1 = QgsVectorLayer("/data/hr_100kdlg/hr-bnd.shp", "samename", "ogr")
QgsMapLayerRegistry.instance().addMapLayers([v1])
v2 = QgsVectorLayer("/data/hr_100kdlg/hr-rds.shp", "samename", "ogr")
QgsMapLayerRegistry.instance().addMapLayers([v2])
</code>

Does it still crash on your tested platforms when using dissimilar layer names in @QgsVectorLayer@ constructor?

@qgib
Copy link
Contributor Author

qgib commented Jun 5, 2012

Author Name: Jürgen Fischer (@jef-n)


  • category_id was changed from Map Canvas to Python plugins

@qgib
Copy link
Contributor Author

qgib commented Jun 5, 2012

Author Name: Jürgen Fischer (@jef-n)


Fixed in changeset "d78e6052431192351115eac5720c34721a5085c1".


  • status_id was changed from Open to Closed

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Plugins labels May 24, 2019
@qgib qgib closed this as completed May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Plugins
Projects
None yet
Development

No branches or pull requests

1 participant