Bug report #7674
crash after adding map layer to registry
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||win7, ubuntu 12.04, debian||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||16591|
#1 Updated by Josef Källgården over 8 years ago
from the python console:
uri = QgsDataSourceURI() uri.setDatabase('/home/josef/Documents/sqlite_db.sqlite') uri.setDataSource('','table1', 'Geometry') layer = QgsVectorLayer(uri.uri(), 'table1', 'spatialite') QgsMapLayerRegistry.instance().addMapLayers([layer])
If the code above is pasted into python console with an additional end-of-line so that all lines are executed immediately, then this causes segmentation fault on both win 7 and ubuntu 12.04. Sometimes directly and sometimes after changing visibility for the layer.
If last line is executed after a short pause, then no crash.
#2 Updated by Borys Jurgiel over 8 years ago
- Operating System changed from win7, ubuntu 12.04 to win7, ubuntu 12.04, debian
I just observed very similar problem: After a plugin adds a map layer to the QgsMapLayerRegistry, a first action done on that layer (remove, visibility change, attribute table open) causes a crash.
#7 Updated by Josef Källgården over 8 years ago
Same problems with memory layers:
ml = QgsVectorLayer("Point?crs=epsg:4326&field=id:integer&field=name:string(20)&index=yes", "temporary_points", "memory") QgsMapLayerRegistry.instance().addMapLayers([ml])
This causes a crash after turning visibility on/off, opening attribute table etc. Sometimes the crash occurs after a second addition of a memory layer.
#8 Updated by Borys Jurgiel over 8 years ago
I can confirm the problem also with Shapefiles when using plugins like TableManager or Shapefile Encoding Fixer. They both use QgsMapLayerRegistry.instance().addMapLayers([layer]) after applying changes.
So if you can confirm this, please extend the title and category from SpatiaLite back to general QgsVectorLayer.
#10 Updated by Josef Källgården over 8 years ago
I made a few more tests and yes, I can confirm crashes for shape files when using the plugins. Also, new memory layer plugin results in crash (same usage of addMapLayers).
Can someone with the necessary permissions change title and category according to Borys suggestion?