Page MenuHomePhabricator

Should RenderingManager be used without singleton?
Closed, ResolvedPublic

Description

Currently we have a lot of calls to RenderingManager::GetInstance() to receive the rendering manager singleton and work with it. This is typically done to perform some actions on all render windows (which are handled by the global rendering manager singleton).

However, it is possible to register render windows with an individual rendering manager, leading to something like
mitk::BaseRenderer::GetInstance(renderWindow)->GetRenderingManager()
or
mitk::BaseRenderer::GetInstance(mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget0"))

The second option is not a good option in my opinion since it explicitly requires a specific, magic string. The first option only works if you already have a render window at hand.

I think we never faced the problem of needing multiple rendering managers. Also, this was done to only use the rendering manager singleton: rMITK5e0e87c36865: Handle RenderingManager like the singleton it is.

Reason for this topic to come up was the latest PR on GitHub: https://github.com/MITK/MITK/pull/248
On the user list the user struggled with the difference between the two functions accessing the "global" or "local" rendering manager.

Event Timeline

kalali triaged this task as Normal priority.Jul 3 2020, 10:37 AM
kalali created this task.

I cannot see any declaration of GetRenderingManager() in BaseRenderer (even before rMITK5e0e87c3)? In the second example I even cannot see anything related to RenderingManager? :-)

Anyway, to answer the title question: no. We never had or missed the possibility to actually use multiple rendering managers since it was never fully implemented to work this way. This eventually lead to all the code removal in rMITK5e0e87c3.

I cannot see any declaration of GetRenderingManager() in BaseRenderer

That's because you removed it. So I'm currently realizing that the topic was silently (unintentionally?) closed by your commit rMITK5e0e87c3 (which was done before this task came up). That leads me to the question if the task "Remove all possibilities to use multiple rendering managers" is done. If it is this topic can be closed.

In the second example I even cannot see anything related to RenderingManager? :-)

There was a missing call to GetRenderingManager() as in the example above.

kislinsk claimed this task.