qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.39k stars 2.98k forks source link

Layers added using a `.qlr` file cannot be added to an open Elevation Profile View #58533

Open PeterDrexel opened 3 weeks ago

PeterDrexel commented 3 weeks ago

What is the bug or the crash?

Using "Log = QgsLayerDefinition().loadLayerDefinition("pathtofile/xxx.qlr", QgsProject.instance(),QgsProject.instance().layerTreeRoot())" in a Script or in the Python-Console works well to open some elevation data into the layer table and the main view. But if I want to see the same Data in an Elevation-Profile-View the dataset does not show up in an already opened Elevation-Profile-View. I have to close and reopen the Elevation Profile View to see the loaded Dataset.

Steps to reproduce the issue

Start QGIS

Versions

3.38.2

Supported QGIS version

New profile

Additional context

No response

uclaros commented 3 weeks ago

Same happens if you open the .qlr by drag and drop.

The QgsLayerTreeRegistryBridge in the profile widget relies on the QgsProject::legendLayersAdded() signal in order to be kept updated. The signal is not fired in .qlr loading code, since loadInLegend is set to false: https://github.com/qgis/QGIS/blob/5215f3351a140ef942a9ff1b64623fcaf26df683/src/core/qgslayerdefinition.cpp#L173-L183