[Qgis-developer] QGIS Python add layer to subGroup from thread error

AnVit2a Anvit2a at gmail.com
Thu Nov 24 13:10:18 PST 2016


I'm developing a python plugin for QGIS and I have found an error I cannot
seem to get my head around.

I have create a QObject that is my worker class that i will pass to a
Everything is running fine but my problem is i create some layergroups.

Group 1 which has subgroup named Group 2. This i create with:
QgsMapLayerRegistry.instance().addMapLayer(knude, False)
group = self.layerTree.addGroup("Group1")
group2 = group.addGroup("Group2")

Layer is valid and layer is added to the correct group. But when this is
loaded and i close qgis, drag the layer to another place or click new
project i QGIS i get a crash and QGIS shuts down with a minidump and
sometimes just a crash where qgis stopped working.

If i add the layer to group and not group2 from the thread every thing is
working fine. I have not seen a crash yet.

I have tried doing this outside a thread too (directly in the plugin
code/thread with gui) Here i can add the layer to group2 and can now drag
the layer, close qgis without minidump or start a new project.

Has anybody else seen the same problem with subGroups or I'm just doing this

I'm using QGIS 2.16.3 and QGIS 2.18 (here i get a bad allocation)

View this message in context: http://osgeo-org.1560.x6.nabble.com/QGIS-Python-add-layer-to-subGroup-from-thread-error-tp5297338.html
Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.

More information about the Qgis-developer mailing list