Skip to content

Commit

Permalink
Fix save dialog not appearing when closing an edited project
Browse files Browse the repository at this point in the history
  • Loading branch information
SamCarlberg committed Oct 14, 2016
1 parent 1d02ed1 commit 099e624
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 0 additions & 2 deletions ui/src/main/java/edu/wpi/grip/ui/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ public void start(Stage stage) throws IOException {
}
});

// If this isn't here this can cause a deadlock on windows. See issue #297
stage.setOnCloseRequest(event -> SafeShutdown.exit(0, Platform::exit));
stage.setTitle(MAIN_TITLE);
stage.getIcons().add(new Image("/edu/wpi/grip/ui/icons/grip.png"));
stage.setScene(new Scene(root));
Expand Down
10 changes: 9 additions & 1 deletion ui/src/main/java/edu/wpi/grip/ui/MainWindowController.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ protected void initialize() {
.toString());
statusBar.setText(" Pipeline " + stateMessage);
}), Platform::runLater);
Platform.runLater(() -> root.getScene().getWindow().setOnCloseRequest(e -> {
if (!quit()) {
// Asked to quit but cancelled, consume the event to avoid closing the window
e.consume();
}
}));
}

/**
Expand Down Expand Up @@ -248,11 +254,13 @@ protected void showProjectAboutDialog() throws IOException {
}

@FXML
protected void quit() {
protected boolean quit() {
if (showConfirmationDialogAndWait()) {
pipelineRunner.stopAsync();
SafeShutdown.exit(0);
return true;
}
return false;
}

/**
Expand Down

0 comments on commit 099e624

Please sign in to comment.