Skip to content

Commit ed7e3be

Browse files
fix: using Desktop api can crash Phoebus on centos clients
1 parent cd10c27 commit ed7e3be

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/AttachmentsPreviewController.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@
4343
import org.phoebus.logbook.Attachment;
4444
import org.phoebus.logbook.olog.ui.write.AttachmentsViewController;
4545
import org.phoebus.ui.application.ApplicationLauncherService;
46+
import org.phoebus.ui.application.PhoebusApplication;
4647
import org.phoebus.ui.dialog.ExceptionDetailsErrorDialog;
4748
import org.phoebus.ui.javafx.ImageCache;
4849

4950
import javax.imageio.ImageIO;
50-
import java.awt.*;
5151
import java.awt.image.BufferedImage;
5252
import java.io.File;
5353
import java.io.IOException;
@@ -128,14 +128,12 @@ public void changed(ObservableValue<? extends Attachment> observable, Attachment
128128
String[] parts = fileName.split("\\.");
129129
if(parts.length == 1 || !ApplicationService.getExtensionsHandledByExternalApp().contains(parts[parts.length - 1])){
130130
// If there is no app configured for the file type, then use the default configured for the OS/User
131+
// Note: Do not use Desktop API, as using Java AWT can hang Phoebus / JavaFX Applications
131132
try {
132-
if(Desktop.isDesktopSupported()) {
133-
Desktop.getDesktop().open(attachment.getFile());
134-
return;
135-
} else {
136-
ExceptionDetailsErrorDialog.openError(Messages.PreviewOpenErrorTitle, Messages.PreviewOpenErrorBody, null);
137-
}
138-
} catch (IOException | UnsupportedOperationException e) {
133+
PhoebusApplication.INSTANCE.getHostServices().showDocument(
134+
attachment.getFile().toURI().getRawPath()
135+
);
136+
} catch (Exception e) {
139137
ExceptionDetailsErrorDialog.openError(Messages.PreviewOpenErrorTitle, Messages.PreviewOpenErrorBody, null);
140138
}
141139
}

0 commit comments

Comments
 (0)