Skip to content

Commit

Permalink
Fix save dialog not appearing when closing an edited project (#689)
Browse files Browse the repository at this point in the history
* Fix save dialog not appearing when closing an edited project

Closes #660
Closes #688
  • Loading branch information
SamCarlberg authored Dec 31, 2016
1 parent f8a9044 commit 9693260
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 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 @@ -127,8 +127,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 @@ -120,6 +120,12 @@ protected void initialize() {
statusLabel.setText("Pipeline " + stateMessage);
analyzeMenuItem.setDisable(state.equals(Service.State.TERMINATED));
}), 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 @@ -278,11 +284,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
6 changes: 1 addition & 5 deletions ui/src/main/resources/edu/wpi/grip/ui/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@
</graphic>
</MenuItem>
<SeparatorMenuItem />
<MenuItem text="Exit" onAction="#quit">
<accelerator>
<KeyCodeCombination alt="UP" code="Q" control="UP" meta="UP" shift="UP" shortcut="DOWN" />
</accelerator>
</MenuItem>
<MenuItem text="Exit" onAction="#quit" />
</Menu>
<Menu text="Tools">
<MenuItem text="Deploy" onAction="#deploy">
Expand Down

0 comments on commit 9693260

Please sign in to comment.