qgis / qgis4.0_api

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

QgsProject is a singleton #8

Closed wonder-sk closed 7 years ago

wonder-sk commented 8 years ago

It should be possible to use QgsProject also as a non-singleton. This would allow reading of multiple project files:

vmora commented 7 years ago

A big +1

My grep gives me ~700 calls to QgsProject::instance() in src, 300 for QgsMapLayerRegistry::instance().

For core it's down to 156 and 104, so it's a lot of work but replacing the calls by either functions parameter (if only used in member function) or by an additional member passed to ctor seems the way to go IMO. It breaks the API, but it's not rocket science either, and with down->top approach it can be done step by step.

Once done, the ::instance could be made unusable if included in core components (e.g. ifdef that fails to compile).

nyalldawson commented 7 years ago

Fixed in https://github.com/qgis/QGIS/commit/57ff36bc016c70a3abb99ebb66764f01868edd9f