Skip to content

Commit 9693260

Browse files
authored
Fix save dialog not appearing when closing an edited project (#689)
* Fix save dialog not appearing when closing an edited project Closes #660 Closes #688
1 parent f8a9044 commit 9693260

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

ui/src/main/java/edu/wpi/grip/ui/Main.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ public void start(Stage stage) throws IOException {
127127
}
128128
});
129129

130-
// If this isn't here this can cause a deadlock on windows. See issue #297
131-
stage.setOnCloseRequest(event -> SafeShutdown.exit(0, Platform::exit));
132130
stage.setTitle(MAIN_TITLE);
133131
stage.getIcons().add(new Image("/edu/wpi/grip/ui/icons/grip.png"));
134132
stage.setScene(new Scene(root));

ui/src/main/java/edu/wpi/grip/ui/MainWindowController.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ protected void initialize() {
120120
statusLabel.setText("Pipeline " + stateMessage);
121121
analyzeMenuItem.setDisable(state.equals(Service.State.TERMINATED));
122122
}), Platform::runLater);
123+
Platform.runLater(() -> root.getScene().getWindow().setOnCloseRequest(e -> {
124+
if (!quit()) {
125+
// Asked to quit but cancelled, consume the event to avoid closing the window
126+
e.consume();
127+
}
128+
}));
123129
}
124130

125131
/**
@@ -278,11 +284,13 @@ protected void showProjectAboutDialog() throws IOException {
278284
}
279285

280286
@FXML
281-
protected void quit() {
287+
protected boolean quit() {
282288
if (showConfirmationDialogAndWait()) {
283289
pipelineRunner.stopAsync();
284290
SafeShutdown.exit(0);
291+
return true;
285292
}
293+
return false;
286294
}
287295

288296
/**

ui/src/main/resources/edu/wpi/grip/ui/MainWindow.fxml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,7 @@
9898
</graphic>
9999
</MenuItem>
100100
<SeparatorMenuItem />
101-
<MenuItem text="Exit" onAction="#quit">
102-
<accelerator>
103-
<KeyCodeCombination alt="UP" code="Q" control="UP" meta="UP" shift="UP" shortcut="DOWN" />
104-
</accelerator>
105-
</MenuItem>
101+
<MenuItem text="Exit" onAction="#quit" />
106102
</Menu>
107103
<Menu text="Tools">
108104
<MenuItem text="Deploy" onAction="#deploy">

0 commit comments

Comments
 (0)