It's handy but makes testing, and isolation hard. Lots of code assumes that the layer is in the registry and uses IDs which requires extra looks into the registry e.g the map renderers
Going forward I think code that needs a layer should take QgsMapLayer objects and not use the ID. Remove any use of QgsMapLayerRegistry that isn't needed and link the active instance to QgsProject
It's handy but makes testing, and isolation hard. Lots of code assumes that the layer is in the registry and uses IDs which requires extra looks into the registry e.g the map renderers
Going forward I think code that needs a layer should take
QgsMapLayer
objects and not use the ID. Remove any use ofQgsMapLayerRegistry
that isn't needed and link the active instance toQgsProject