New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QgsProject is a singleton #8

Closed
wonder-sk opened this Issue Dec 1, 2015 · 2 comments

Comments

Projects
None yet
3 participants
@wonder-sk
Member

wonder-sk commented Dec 1, 2015

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

  • in QGIS server (instead of custom project parser)
  • when embedding layers/groups from other projects
  • in browser dock (e.g. load something from other project)
@vmora

This comment has been minimized.

Show comment
Hide comment
@vmora

vmora Oct 28, 2016

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).

vmora commented Oct 28, 2016

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

This comment has been minimized.

Show comment
Hide comment
Contributor

nyalldawson commented Dec 13, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment