Skip to content
Snippets Groups Projects
Commit 7557f763 authored by Bariatti Francesco's avatar Bariatti Francesco
Browse files

MCTS is now properly closed when the GUI exits

parent b9a1bf40
No related branches found
No related tags found
No related merge requests found
......@@ -50,6 +50,13 @@ public class Controller implements Initializable
{
this.gameProcess = new ProcessBuilder("../bin/theturk").start();
gameInput = new PrintWriter(new OutputStreamWriter(gameProcess.getOutputStream()), true);
Runtime.getRuntime().addShutdownHook(new Thread()
{
public void run()
{
gameProcess.destroy();
}
});
}
catch (IOException e)
{
......
......@@ -26,7 +26,7 @@ public class UpdateThread extends Thread
this.board = board;
this.boardView = boardView;
}
public void run()
{
......@@ -69,10 +69,19 @@ public class UpdateThread extends Thread
Alert alert = new Alert(Alert.AlertType.ERROR, "Error during reading from penguin program!", ButtonType.FINISH);
alert.showAndWait();
e.printStackTrace();
System.exit(1);
Platform.exit();
});
}
catch (Throwable e)
{
gameRunning = false;
Platform.runLater(() -> {
Alert alert = new Alert(Alert.AlertType.ERROR, "Unhandled exception in update thread: " + e.getMessage(), ButtonType.FINISH);
alert.showAndWait();
e.printStackTrace();
Platform.exit();
});
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment