VISAB-ORG / VISAB

VISAB is a standalone utility to visualize artificial intelligence agent behavior in games.
1 stars 0 forks source link

B fix threading in views #96

Closed leRoe93 closed 3 years ago

leRoe93 commented 3 years ago

Due to the fact that the continuous updates of the session overview and the replay view are based on a threaded logic, we needed handling for onStageClosed events to shutdown the pending java processes as soon as the user simply "closes the window".

This PR introduces a GenericScope which can be injected into view models that need some handling on stage close and the DialogHelper which is called to display the session overview now has a similar method to show a view like the DynamicViewLoader so that the scope injection is properly supported also for "non-visualizer-views".

The implementation itself is not clean yet, but we do a refactoring anyway.

This is a working version, we always may jump back to, if we find no better solution.

Only adding for notice, merging right away because this stabilizes VISAB rather than breaking something.

mfroeh commented 3 years ago

I really like the idea to make this a seperate scope! My naming suggestion for the future would be something like Stage or ViewEventScope. The implementation could essentially encapsualate the events of the stage for usage inside the ViewModel.

An improvement to the current implementation would also be, to not have a public method for invoking the stage closed event, but instead having a private implementation, that registers an event handler in the setter for the stage.

Good stuff :rocket: