Revision: 1621
          http://svn.sourceforge.net/spring-rich-c/?rev=1621&view=rev
Author:   ge0ffrey
Date:     2007-01-04 01:11:46 -0800 (Thu, 04 Jan 2007)

Log Message:
-----------
RCP-454 application.start() must be done in event thread

Modified Paths:
--------------
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/ApplicationLauncher.java

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/ApplicationLauncher.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/ApplicationLauncher.java
   2007-01-04 09:08:08 UTC (rev 1620)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/ApplicationLauncher.java
   2007-01-04 09:11:46 UTC (rev 1621)
@@ -15,6 +15,8 @@
  */
 package org.springframework.richclient.application;
 
+import java.lang.reflect.InvocationTargetException;
+
 import javax.swing.SwingUtilities;
 
 import org.apache.commons.logging.Log;
@@ -273,7 +275,7 @@
                        displaySplashScreen(rootApplicationContext);
                }
 
-               Application application;
+               final Application application;
                try {
                        application = (Application) 
rootApplicationContext.getBean(APPLICATION_BEAN_ID, Application.class);
                }
@@ -282,7 +284,21 @@
                                        "A single 
org.springframework.richclient.Application bean definition must be defined "
                                                        + "in the main 
application context", e);
                }
-               application.start();
+               try {
+                       // To avoid deadlocks when events fire during 
initialization of some swing components
+                       // Possible to do: in theory not a single Swing 
component should be created (=modified) in the launcher thread...
+                       SwingUtilities.invokeAndWait(new Runnable() {
+                               public void run() {
+                                       application.start();
+                               }
+                       });
+               } catch (InterruptedException e) {
+                       logger.warn("Application start interrupted", e);
+               } catch (InvocationTargetException e) {
+                       Throwable cause = e.getCause();
+                       throw new IllegalStateException("Application start 
thrown an exception: " + cause.getMessage(), cause);
+               }
+               // application.start();
                logger.debug("Launcher thread exiting...");
        }
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
spring-rich-c-cvs mailing list
spring-rich-c-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to