Hi, Le lun. 29 oct. 2018 à 11:04, Luiz Motta <[email protected]> a écrit :
> Hi, > > I need get the signal when have change of layers order of legend. > > I tried use the signal of layerOrderChanged, but, crash QGIS. > Version: 3.4 > Code 4a4b62e <https://github.com/qgis/QGIS/commit/4a4b62e> > OS: Kubuntu 18.04 > > I used the Terminal Python: > > def changeOrder(): > print('Change order') > > root = QgsProject.instance().layerTreeRoot() > > root.layerOrderChanged.connect(changeOrder) # Crash for normal layer > > root.customLayerOrderChanged.connect(changeOrder) # None crash for normal > layer > > It is a Bug ? > Yes this is a bug. > > What is a custom layer ? > It's not the layer that is custom, it's the order. That's the way to have a layer order that is differement from the one in the legend. see https://docs.qgis.org/2.18/en/docs/user_manual/introduction/general_tools.html#working-with-the-legend-independent-layer-order For technical details, it seems that the signal is emitted before QgsLayerTreeModel::removeRows could return true. And a new repaint of the layer tree is requested (while still in removing rows). The crash occurs in QgsLayerTreeModel::index2node() at the return line: QObject *obj = reinterpret_cast<QObject *>( index.internalPointer() ); return qobject_cast<QgsLayerTreeNode *>( obj ); I am not really sure how to fix it here, Martin... can you have a look it? Denis -- Denis Rouzaud [email protected] <[email protected]> +41 76 370 21 22
_______________________________________________ QGIS-Developer mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
