From add4ed819477485e03ad2f5c3ed5c7743106ddfa Mon Sep 17 00:00:00 2001 From: Andrew Neitsch Date: Mon, 7 Oct 2019 13:53:05 -0600 Subject: [PATCH] Hide splash screen asap if not using gui MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #1970 On macOS, when running, Arduino.app/Contents/MacOS/Arduino --upload sketch.ino a splash screen is visible the entire time the upload is running. This PR hides that splash screen as soon as it’s known for sure that the GUI should not be displayed. This makes for a slightly better user experience: there’s still a splash screen, but it only appears briefly at launch time. The [SplashScreen docs][] explain: > The splash screen can be displayed at application startup, before the > Java Virtual Machine (JVM) starts. ... is closed automatically as soon as > the first window is displayed by Swing/AWT (may be also closed manually > using the Java API, see below) [SplashScreen docs]: https://docs.oracle.com/javase/7/docs/api/java/awt/SplashScreen.html --- app/src/processing/app/Base.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index d8e9b1cac45..bbad124b7bd 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -208,7 +208,6 @@ public Base(String[] args) throws Exception { BaseNoGui.initPortableFolder(); // This configure the logs root folder - System.out.println("Set log4j store directory " + BaseNoGui.getSettingsFolder().getAbsolutePath()); System.setProperty("log4j.dir", BaseNoGui.getSettingsFolder().getAbsolutePath()); // Look for a possible "--preferences-file" parameter and load preferences @@ -218,6 +217,17 @@ public Base(String[] args) throws Exception { parser.parseArgumentsPhase1(); commandLine = !parser.isGuiMode(); + if (!parser.isGuiMode()) { + try { + // This can return null or raise an exception + SplashScreen s = SplashScreen.getSplashScreen(); + if (s != null) { + s.close(); + } + } catch (UnsupportedOperationException e) { + } + } + BaseNoGui.checkInstallationFolder(); // If no path is set, get the default sketchbook folder for this platform