diff --git a/Ghidra/Features/Base/src/main/java/ghidra/framework/GhidraApplicationConfiguration.java b/Ghidra/Features/Base/src/main/java/ghidra/framework/GhidraApplicationConfiguration.java index c39a1351b2..3f0c43c8ce 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/framework/GhidraApplicationConfiguration.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/framework/GhidraApplicationConfiguration.java @@ -49,7 +49,7 @@ public class GhidraApplicationConfiguration extends HeadlessGhidraApplicationCon if (showSplashScreen) { showUserAgreement(); - SplashScreen.showSplashScreen(); + SplashScreen.showLater(); this.monitor = new StatusReportingTaskMonitor(); } diff --git a/Ghidra/Framework/Docking/src/main/java/docking/DockingDialog.java b/Ghidra/Framework/Docking/src/main/java/docking/DockingDialog.java index c75418fe9f..928e7a804f 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/DockingDialog.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/DockingDialog.java @@ -320,10 +320,8 @@ public class DockingDialog extends JDialog implements HelpDescriptor { return; } - Rectangle r = getBounds(); Point p = WindowUtilities.centerOnComponent(c, this); - r.setLocation(p); - setBounds(r); + setLocation(p); } @Override diff --git a/Ghidra/Framework/Docking/src/main/java/docking/framework/DockingApplicationConfiguration.java b/Ghidra/Framework/Docking/src/main/java/docking/framework/DockingApplicationConfiguration.java index fef37b3cf4..631ed78ca1 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/framework/DockingApplicationConfiguration.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/framework/DockingApplicationConfiguration.java @@ -53,7 +53,7 @@ public class DockingApplicationConfiguration extends ApplicationConfiguration { LookAndFeelUtils.performPlatformSpecificFixups(); if (showSplashScreen) { - SplashScreen.showSplashScreen(); + SplashScreen.showLater(); } ApplicationKeyManagerFactory diff --git a/Ghidra/Framework/Docking/src/main/java/docking/framework/SplashScreen.java b/Ghidra/Framework/Docking/src/main/java/docking/framework/SplashScreen.java index c156c3cc5a..9242513993 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/framework/SplashScreen.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/framework/SplashScreen.java @@ -32,6 +32,7 @@ import generic.theme.Gui; import generic.util.WindowUtilities; import ghidra.framework.Application; import ghidra.util.Msg; +import ghidra.util.Swing; import utility.application.ApplicationLayout; /** @@ -42,7 +43,6 @@ import utility.application.ApplicationLayout; public class SplashScreen extends JWindow { private static final Color BG_COLOR = new GColor("color.bg.splashscreen"); - private static final Color FG_COLOR = new GColor("color.fg.splashscreen"); private static final String FONT_ID = "font.splash.status"; @@ -52,34 +52,61 @@ public class SplashScreen extends JWindow { private static Timer hideSplashWindowTimer; /** - * Show the splash screen; displayed only when Ghidra is first coming up + * Show the splash screen on the Swing thread later. + */ + public static void showLater() { + + Swing.runIfSwingOrRunLater(() -> { + + if (splashWindow != null) { + return; // already showing + } + + JFrame parentFrame = getParentFrame(); + splashWindow = new SplashScreen(parentFrame); + + initializeSplashWindowAndParent(parentFrame); + + createSplashScreenCloseListeners(parentFrame); + + parentFrame.setVisible(true); + splashWindow.setVisible(true); + + // this call is needed for the splash screen to initially paint correctly on the Mac + splashWindow.repaint(); + }); + } + + /** + * Show the splash screen on the Swing thread now. This will block. * @return the new splash screen */ - public static SplashScreen showSplashScreen() { - if (splashWindow != null) { - return splashWindow; // already showing - } + public static SplashScreen showNow() { + return Swing.runNow(() -> { + if (splashWindow != null) { + return splashWindow; // already showing + } - final JFrame parentFrame = getParentFrame(); - splashWindow = new SplashScreen(parentFrame); + JFrame parentFrame = getParentFrame(); + splashWindow = new SplashScreen(parentFrame); - initializeSplashWindowAndParent(parentFrame); + initializeSplashWindowAndParent(parentFrame); - createSplashScreenCloseListeners(parentFrame); + createSplashScreenCloseListeners(parentFrame); - parentFrame.setVisible(true); - splashWindow.setVisible(true); + parentFrame.setVisible(true); + splashWindow.setVisible(true); - // this call is needed for the splash screen to initially paint correctly on the Mac - splashWindow.repaint(); - return splashWindow; + // this call is needed for the splash screen to initially paint correctly on the Mac + splashWindow.repaint(); + return splashWindow; + }); } private static void initializeSplashWindowAndParent(final JFrame parentFrame) { Dimension wd = splashWindow.getPreferredSize(); Point point = WindowUtilities.centerOnScreen(wd); - splashWindow.setLocation(point); // move us when the parent frame moves @@ -288,7 +315,7 @@ public class SplashScreen extends JWindow { } private static void updateStatus(String status) { - statusLabel.setText(status); + Swing.runIfSwingOrRunLater(() -> statusLabel.setText(status)); } private JPanel createMainPanel() { @@ -330,7 +357,7 @@ public class SplashScreen extends JWindow { config.setShowSplashScreen(false); Application.initializeApplication(layout, config); - showSplashScreen(); + showLater(); // tests that modal dialogs popup on top of the splash screen // new Thread( new Runnable() { diff --git a/Ghidra/Framework/Docking/src/test.slow/java/docking/framework/SplashScreenTest.java b/Ghidra/Framework/Docking/src/test.slow/java/docking/framework/SplashScreenTest.java index 0dbdf2655b..11001d1b3d 100644 --- a/Ghidra/Framework/Docking/src/test.slow/java/docking/framework/SplashScreenTest.java +++ b/Ghidra/Framework/Docking/src/test.slow/java/docking/framework/SplashScreenTest.java @@ -159,7 +159,7 @@ public class SplashScreenTest extends AbstractDockingTest { private void showSplashScreen(final boolean makeVisible) { if (makeVisible) { - SplashScreen splash = runSwing(() -> SplashScreen.showSplashScreen()); + SplashScreen splash = SplashScreen.showNow(); assertNotNull("Failed showing splash screen", splash); waitForSwing(); return;