Page MenuHomePhabricator

The modules Visible() method is called before the other modules Hidden() method
Closed, ResolvedPublic

Description

Is it possible to change the behavior of the calls for Hidden() and Visible(). Up to now the new views visible method is called before the old view hidden method. This can lead to errors because two views are active at the same time.

Event Timeline

Okay, we have to be careful with the terms "visible" and "active". There can be multiple visible views at the same time (each stack has one visible view), but there is always only one active view.

What is called the wrong way now (in certain cases) are the Activated() and Deactivated() methods. Consider the following: You have two views A and B in the same stack, and A is currently active. If you click on B, what happens right now (in certain cases) is:

B->Visible()
A->Hidden()
B->Activated()
A->Deactivated()

This should be fixed to (*):

B->Visible()
A->Hidden()
A->Deactivated()
B->Activated()

If A and B belong to different stacks and both are visible and A is currently active, clicking on B results in:

A->Deactivated()
B->Activated()

Would (*) solve your problems? If not, what would be the offending use-case?

My problem is that I use the Visible and Hidden methods because every new selection in Datamanager call the deactivated methods. My plan is to reset the image colors to greyvalues when the module is not needed anymore (Hidden) and set to red/green colors when the module is visible again and the checkbox is set. At the moment the behavior for switching between two registration modules is:

B->Visible(): Set to red/green if checkbox is checked
A->Hidden(): Set to greyvalues.

That is why the images are shown in greyvalues after switching between modules even though the red/green flag is set.

My preferred solution would be:

A->Hidden()
B->Visible()
A->Deactivated()
B->Activated()

Or do you have another idea to solve this problem? Using the Activated and Deactivated methods will lead to colorchanges every time the user clicks into the Datamanager.

Another solution could be that clicks in Datamanager do not call the Deactivated methods of other modules because most of the modules work together with the Datamanager.

I see. Considering your use case, I think you are using the wrong technique (obviously...).

You could introduce a new class (possibly as singleton), which counts the number of your currently visible views. The views would increment/decrement the counter in their Visible()/Hidden() methods. If the counter goes to zero, reset the image colors to greyvalues, if it is greater than one and has the checkbox flag set, set the colors to green and red.

Would that work?

[SVN revision 20395]
FIX (#2937): Calling Activated/Deactivated in the correct order now.

[SVN revision 20409]
FIX (#2937): tmp revert for 3M3 demo

We should discuss whether this fix should be reapplied and get tested for the release.

Michi is working on the idea I had during lunch (DataManager and co. should not inherit from QmitkFunctionality).

However, Michi, maybe you can have a look at the changes made in 20395. I still think that Deactivated should be called on the old part before Activated is called on the new one, but now only if the new one inherits from QmitkFunctionality.

[SVN revision 20577]
FIX (#2937): fixed the PartActivated and PartDeactivated methods (again...)

[SVN revision 20599]
FIX (#2937): Calling StdMultiWidgetAvailable only when Functionality is activated. Caused a lot of errors. e.g. showing widget planes when clicking in renderwindow

I thinks this is finally fixed. Reopen if not.