What is the bug or the crash?
In QGIS3, the truth value of a QgsLayerTreeNode (layer or group) was always True.
This allowed to write the following
layer_id = "my_id"
node = QgsProject.instance().layerTreeRoot().findLayer(layer_id)
if node:
# Process node
...
In QGIS4 the truth value of a QgsLayerTreeLayer is always False, and True only for QgsLayerTreeGroup with child nodes.
Steps to reproduce the issue
QGIS4
>>> bool(QgsLayerTreeLayer(""))
False
QGIS3
>>> bool(QgsLayerTreeLayer(""))
True
Versions
QGIS 3.44.8 vs QGIS 4.0.0
Supported QGIS version
New profile
No Duplicate of the Issue
Additional context
No response
What is the bug or the crash?
In QGIS3, the truth value of a
QgsLayerTreeNode(layer or group) was always True.This allowed to write the following
In QGIS4 the truth value of a
QgsLayerTreeLayeris always False, and True only forQgsLayerTreeGroupwith child nodes.Steps to reproduce the issue
QGIS4
QGIS3
Versions
QGIS 3.44.8 vs QGIS 4.0.0
Supported QGIS version
New profile
No Duplicate of the Issue
Additional context
No response