Ecdar / Ecdar-GUI

A graphical tool for modeling using ECDAR (Environment for Compositional Design and Analysis of Real Time Systems)
MIT License
3 stars 5 forks source link

Only close affected connections on Engine change #149

Open Nielswps opened 1 year ago

Nielswps commented 1 year ago

When the user saves changes to the engines through the EngineOptionsDialog, all engines are re-instantiated and their connections are closed. It would be more efficient to only close the connections that are no longer in the active port range of the affected engines.

https://github.com/Ecdar/Ecdar-GUI/blob/a25b0994e654f940a06ebc760a87a0822ff0bcd3/src/main/java/ecdar/backend/BackendHelper.java#L121-L126

https://github.com/Ecdar/Ecdar-GUI/blob/a25b0994e654f940a06ebc760a87a0822ff0bcd3/src/main/java/ecdar/controllers/EngineOptionsDialogController.java#L73-L76

:warning: This change might seem fairly easy, but it should include a refactor of the way engines are referenced and handled in the EngineOptionsDialogController.

This also becomes an issue if long-running queries are started and then the port range is changed for the associated engine in order to run other queries. This case would result in the long-running query being canceled. (Thanks to @Brandhoej for this example of the issue)

Suggested approach

I suggest that the EngineInstance (the visual representation of the engine within the EngineOptionsDialog) does not operate on the engines, but instead takes an Engine as a constructor parameter for populating the input fields and then has a method for constructing an engine based on the values of these fields.