Skip to content

Commit

Permalink
Solves deadlocking when opening a saved project (#685)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamCarlberg authored Oct 12, 2016
1 parent 103b8a8 commit 1d02ed1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions ui/src/main/java/edu/wpi/grip/ui/MainWindowController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import edu.wpi.grip.core.Pipeline;
import edu.wpi.grip.core.PipelineRunner;
import edu.wpi.grip.core.events.ProjectSettingsChangedEvent;
import edu.wpi.grip.core.events.UnexpectedThrowableEvent;
import edu.wpi.grip.core.serialization.Project;
import edu.wpi.grip.core.settings.ProjectSettings;
import edu.wpi.grip.core.settings.SettingsProvider;
Expand Down Expand Up @@ -153,7 +154,7 @@ public void newProject() {
* pipeline, an "are you sure?" dialog is shown. (TODO)
*/
@FXML
public void openProject() throws IOException {
public void openProject() {
if (showConfirmationDialogAndWait()) {
final FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Open Project");
Expand All @@ -165,7 +166,15 @@ public void openProject() throws IOException {

final File file = fileChooser.showOpenDialog(root.getScene().getWindow());
if (file != null) {
project.open(file);
Thread fileOpenThread = new Thread(() -> {
try {
project.open(file);
} catch (IOException e) {
eventBus.post(new UnexpectedThrowableEvent(e, "Failed to load save file"));
}
}, "Project Open Thread");
fileOpenThread.setDaemon(true);
fileOpenThread.start();
}
}
}
Expand Down

0 comments on commit 1d02ed1

Please sign in to comment.