Page MenuHomePhabricator

mitk::StateMachine internally uses GlobalInteraction::GetInstance
Closed, WontfixPublic

Description

Each instance of mitk::StateMachine uses GlobalInteraction::GetInstance() in order to get its own startState.

This only works if this global instance has been properly initialized previously, e.g. by QmitkregisterClasses().

However, as it is also possible to create non-static instances of GlobalInteraction that can be used completely without the global instance, this can lead to problems. This global instance is not initialized when InitializeStartStates (unsigned int timeSteps) is called and returns NULL.

The result of this is that simply nothing happens (how could without a start-state). There is no warning or anything.

One could say that it should not be a problem to call QmitkRegisterClasses.
However, it is possible to use different instances of mitk::GlobalInteraction with distinct StateMachine.xml.

In this case, the start-states might not be the same which would lead to invalid Statemachines.

Event Timeline

Adding MITK_FATAL messages is the first step. I have added but not yet commited this.

A general discussion about the future of GlobalInteraction then will be necessary. Shall it be a real singleton (then I will move the mitkNewMacro to protected) or shall it be able to use several GlobalInteractions (doesn't really make sense in my opinion).

Things done so far without commit:

  • Restructuring GlonalInteractionTest to also check non singleton instanciation.
  • adding MITK_FATAL Messages in GlobalInteraction and StateMachine
  • within initialization of GlobalInteraction: returning false if no startState recieved by StateMachineFactory. Then it is not initialized (former bug).
  • changing itkWarningMacro to MITK_FATAL or MITK_WARN to use same output strategy

I will open a new bug for commiting the changes mentioned above and make it dependant on this bug.
Then a service like used for DataStorage (GetDefaultDataStorage) might be the solution for a non static GlobalInteraction.

What is the status of this? Ingmar, Markus, could you comment please?

So far, but #4527 is solved.

Still a general discussion about the future of GlobalInteraction is necessary.
so I did not close this bug.

Markus?

I have not yet made any changes to mitkGlobalInteraction regarding this bug.

Right now, it is totally possible to use multiple instances of mitkGlobalInteraction as long as you do not try to use different StateMachine.xml files.

The problem that was originally described is still there. However, as nobody uses this feature (several instances with DIFFERENT StateMachine.xml's) a fix is not needed urgently.

I simply saw a possible problem for the future and entered this bug. In order to really find a solution this matter will have to be discussed as Ingmar already stated.

Result of the "RFD" session:

The one and only xml file is a feature that shall not be changed. For other bundles a feature ist still available, that adds patterns contained in a given xml file to the set of patterns. So this is not to be changed.

For the singleton GlobalInteraction and the bug of defining constructor and destructor public: The strategy of GlobalInteraction shall be merged with Saschas new feature of one mitk core singleton factory. There the one GlobalInteraction, formerly meant to be a singleton, can be added and other objects can ask for that instance. GlobalInteraction then shall be returned to a non singleton class. This way several objects of type GlobalInteraction are possible.

Resetting all bugs without active assignee flag to "CONFIRMED". Change status to IN_PROGRESS if you are working on it.

(In reply to comment #5)

So far, but #4527 is solved.

Still a general discussion about the future of GlobalInteraction is
necessary.

Christian Weber is working on some improvements already.

Christian, could you please check this bug and see if we have covered this topic? Can be discussed during next meeting. If solved, you can close this old bug.

GlobalInteraction is deprecated, and replaced by Dispatcher.
By default the four Renderwindows share the same instance, but this can be overwritten, by creating a new one and assigning it to the desrired Renderwindow.
Also the state machine patterns have been split up into different files.

So I'm closing this bug.

kislinsk added a project: Bulk Edit.
kislinsk removed a project: Bulk Edit.