From 2e12371e9182543286ccbbf1513c4bc807e6e116 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 26 Sep 2021 15:58:18 -0400 Subject: [PATCH] "wrong bundle" warning text sometimes not visible #3267 --- .../main/java/com/rusefi/io/DfuHelper.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/java_console/io/src/main/java/com/rusefi/io/DfuHelper.java b/java_console/io/src/main/java/com/rusefi/io/DfuHelper.java index 5d6dcd83bd..a64b3171db 100644 --- a/java_console/io/src/main/java/com/rusefi/io/DfuHelper.java +++ b/java_console/io/src/main/java/com/rusefi/io/DfuHelper.java @@ -32,16 +32,20 @@ public class DfuHelper { if (!bundleName.equalsIgnoreCase(s.getBundle())) { String message = String.format("You have \"%s\" controller does not look right to program it with \"%s\"", s.getBundle(), bundleName); FileLog.MAIN.logLine(message); - JOptionPane.showMessageDialog(parent, message); - // in case of mismatched bundle type we are supposed do close connection - // and properly handle the case of user hitting "Update Firmware" again - // closing connection is a mess on Windows so it's simpler to just exit - new Thread(() -> { - // let's have a delay and separate thread to address - // "wrong bundle" warning text sometimes not visible #3267 - sleep(5 * SECOND); - System.exit(-5); - }).start(); + + SwingUtilities.invokeLater(() -> { + JOptionPane.showMessageDialog(parent, message); + // in case of mismatched bundle type we are supposed do close connection + // and properly handle the case of user hitting "Update Firmware" again + // closing connection is a mess on Windows so it's simpler to just exit + new Thread(() -> { + // let's have a delay and separate thread to address + // "wrong bundle" warning text sometimes not visible #3267 + sleep(5 * SECOND); + System.exit(-5); + }).start(); + }); + return false; } }