UI thread is the thread to open dialogs

This commit is contained in:
rusefi 2022-01-17 16:46:36 -05:00
parent 0abd4ce7fc
commit 35ab35d209
1 changed files with 7 additions and 5 deletions

View File

@ -84,11 +84,13 @@ public class PortHolder {
*/
public void packAndSend(final String command, boolean fireEvent) throws InterruptedException {
if (bp == null) {
Window[] windows = JDialog.getWindows();
Window window = windows.length == 0 ? null : windows[0];
JOptionPane.showMessageDialog(window, "No connectivity",
"Error", JOptionPane.ERROR_MESSAGE);
System.exit(-1);
SwingUtilities.invokeLater(() -> {
Window[] windows = JDialog.getWindows();
Window window = windows.length == 0 ? null : windows[0];
JOptionPane.showMessageDialog(window, "No connectivity, will close",
"Error", JOptionPane.ERROR_MESSAGE);
System.exit(-1);
});
}
bp.doSend(command, fireEvent);