qgis / qgis4.0_api

Tracker for QGIS 4.0 API related issues and developer discussion
3 stars 1 forks source link

QgsMapLayerRegistry is a singleton #23

Closed NathanW2 closed 7 years ago

NathanW2 commented 8 years ago

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

project = QgsProject.open('blah.qgs')
project.layers()
NathanW2 commented 8 years ago

Dup of #16

NathanW2 commented 8 years ago

Leaving open as it's really a follow on from #16

rldhont commented 7 years ago

also discussed in #42

nyalldawson commented 7 years ago

Fixed in https://github.com/qgis/QGIS/commit/d56a97d4fe21f593746f176ceb6f553eca1d4c2e