If nothing can be done for the strange releasing of the CommandDialog's latch
[but something strange is happening because I cannot debug that point (there with a long delay)]
I think the workaround I devised is acceptable:
The method that opens the CommandDialogs will not restore the back command if the show method returns early, that is, after the further InteractionDialog has been opened (here's the latch release).
So there is no concurrent setting of the backCommand.
Then the CommandDialog is called again from inside the disposing InteractionDialog after its back command is called (now assigned to the toolbar and the form).
(the old back command was passed as a parameter to the method that opens the InteractionDialog and swiftly restored)
But
I realized that the right way is to use both
form.setBackCommand(backCommand);
and
form.getToolbar().setBackCommand(backCommand);
to set
and
form.setBackCommand(oldBackCommand);
and
form.getToolbar().setBackCommand(oldBackCommand);
to restore.
Now I see three back buttons on the toolbar.
I have to avoid this.
How do I remove the old button, or change directly its command, instead of the toolbar's one?
Thanks