From 6c47a08ecc7aef1cfa0247e48bea3c6dbea2bdd9 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Fri, 2 Nov 2012 15:38:17 +0400 Subject: [PATCH] Don't let the chance to AWTAutoShutdown to kill dispatch queue in the gap between splash is already been hidden and IdeFrame not yet shown. --- .../com/intellij/idea/IdeaApplication.java | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java index 9a9ca7e7d866..eb6046e23213 100644 --- a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java +++ b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java @@ -37,7 +37,9 @@ import com.intellij.openapi.updateSettings.impl.UpdateChecker; import com.intellij.openapi.updateSettings.impl.UpdateSettings; import com.intellij.openapi.util.*; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.wm.IdeFrame; import com.intellij.openapi.wm.WindowManager; +import com.intellij.openapi.wm.WindowManagerListener; import com.intellij.openapi.wm.ex.WindowManagerEx; import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeFrame; import com.intellij.ui.Splash; @@ -286,18 +288,36 @@ public class IdeaApplication { // application components. So it is proper to perform replacement only here. ApplicationEx app = ApplicationManagerEx.getApplicationEx(); // app.setupIdeQueue(IdeEventQueue.getInstance()); + final WindowManagerEx windowManager = (WindowManagerEx)WindowManager.getInstance(); + WindowManagerListener splashDisposer = new WindowManagerListener() { + @Override + public void frameCreated(IdeFrame frame) { + if (mySplash != null) { + mySplash.dispose(); + mySplash = null; // Allow GC collect the splash window + } + windowManager.removeListener(this); + } + + @Override + public void beforeFrameReleased(IdeFrame frame) {} + }; + + windowManager.addListener(splashDisposer); + try { - IdeEventQueue.getInstance().setWindowManager((WindowManagerEx)WindowManager.getInstance()); + IdeEventQueue.getInstance().setWindowManager(windowManager); final Ref willOpenProject = new Ref(Boolean.FALSE); final AppLifecycleListener lifecyclePublisher = app.getMessageBus().syncPublisher(AppLifecycleListener.TOPIC); lifecyclePublisher.appFrameCreated(args, willOpenProject); LOG.info("App initialization took " + (System.nanoTime() - PluginManager.startupStart) / 1000000 + " ms"); PluginManager.dumpPluginClassStatistics(); - //if (!willOpenProject.get()) { + if (!willOpenProject.get()) { WelcomeFrame.showNow(); lifecyclePublisher.welcomeScreenDisplayed(); - //} + splashDisposer.frameCreated(null); + } } catch (PluginException e) { Messages.showErrorDialog("Plugin " + e.getPluginId() + " couldn't be loaded, the IDE will now exit.\n" + @@ -306,17 +326,6 @@ public class IdeaApplication { System.exit(-1); } - app.invokeLater(new Runnable() { - @Override - public void run() { - if (mySplash != null) { - mySplash.dispose(); - mySplash = null; // Allow GC collect the splash window - } - } - }, ModalityState.NON_MODAL); - - app.invokeLater(new Runnable() { @Override public void run() {