[kepler-dev] Found simple fix was Re: Splash screen and corresponding changes
Kevin Ruland
kruland at ku.edu
Tue Feb 14 09:50:09 PST 2006
Christopher,
These changes are perhaps quite a bit safer since they indeed put the
gui parts in invokeLater. The two calls I refer to are the display of
the documentation effigy and the createPrimaryTableau() calls. Both of
these methods are pretty heavy and do cause the Splash to become
non-responsive.
Without great analysis of where pack(), or show() or setVisible(true) is
first called in the various tableau classes, I don't know how much finer
grained we can get. My gut feeling is
Configuration.createPrimaryTableau() should really call Tableau.show()
only in the event handler thread. But that would be a much deeper
change than I am comfortable with.
Do you have any bug reports or test cases which were fixed by placing
VergilApplication(String[]) in invokeLater()? That would help me out.
Kevin
*** ../ptII/ptolemy/vergil/VergilApplication.java Mon Feb 13 08:57:11
2006
--- src/exp/ptolemy/vergil/VergilApplication.java Tue Feb 14 11:39:40
2006
***************
*** 45,50 ****
--- 45,51 ----
import ptolemy.actor.gui.PtolemyPreferences;
import ptolemy.data.expr.Parameter;
import ptolemy.gui.GraphicalMessageHandler;
+ import ptolemy.gui.SwingWorker;
import ptolemy.kernel.CompositeEntity;
import ptolemy.kernel.attributes.URIAttribute;
import ptolemy.kernel.util.ChangeRequest;
***************
*** 139,161 ****
// weird things happens at the user interface level. This
// seems to prevent occasional errors rending HTML under Web
Start.
try {
! // NOTE: This is unfortunate... It would be nice
! // if this could be run inside a PtolemyThread, since
! // getting read access the workspace is much more efficient
! // in PtolemyThread.
! SwingUtilities.invokeLater(new Runnable() {
! public void run() {
try {
! new VergilApplication(args);
} catch (Throwable throwable) {
System.err.println("xxxxxxxxxxxxxxxxxxxx");
// If we get an Error or and Exception while
// configuring, we will end up here.
_errorAndExit("Command failed", args, throwable);
}
}
! });
} catch (Throwable throwable2) {
// We are not likely to get here, but just to be safe
// we try to print the error message and display it in a
--- 140,160 ----
// weird things happens at the user interface level. This
// seems to prevent occasional errors rending HTML under Web
Start.
try {
! SwingWorker w = new SwingWorker() {
! public Object construct() {
try {
! return new VergilApplication(args);
} catch (Throwable throwable) {
System.err.println("xxxxxxxxxxxxxxxxxxxx");
// If we get an Error or and Exception while
// configuring, we will end up here.
_errorAndExit("Command failed", args, throwable);
+ return null;
}
}
! };
! w.start();
} catch (Throwable throwable2) {
// We are not likely to get here, but just to be safe
// we try to print the error message and display it in a
***************
*** 439,445 ****
* @exception Exception If the configuration cannot be opened.
*/
protected Configuration _createEmptyConfiguration() throws Exception {
! Configuration configuration = _createDefaultConfiguration();
URL welcomeURL = null;
URL introURL = null;
--- 438,444 ----
* @exception Exception If the configuration cannot be opened.
*/
protected Configuration _createEmptyConfiguration() throws Exception {
! final Configuration configuration = _createDefaultConfiguration();
URL welcomeURL = null;
URL introURL = null;
***************
*** 449,456 ****
new PtolemyEffigy.Factory(directory,
directory.uniqueName("ptolemyEffigy"));
! Effigy effigy = factory.createEffigy(directory, null, null);
configuration.createPrimaryTableau(effigy);
try {
// First, we see if we can find the welcome window by
--- 448,459 ----
new PtolemyEffigy.Factory(directory,
directory.uniqueName("ptolemyEffigy"));
! final Effigy effigy = factory.createEffigy(directory, null, null);
! SwingUtilities.invokeLater( new Runnable() {
! public void run() {
configuration.createPrimaryTableau(effigy);
+ }
+ });
try {
// First, we see if we can find the welcome window by
***************
*** 483,491 ****
_parser.parse(welcomeURL, welcomeURL);
}
! Effigy doc = (Effigy) configuration.getEntity("directory.doc");
! doc.identifier.setExpression(introURL.toExternalForm());
return configuration;
--- 486,507 ----
_parser.parse(welcomeURL, welcomeURL);
}
! final Effigy doc = (Effigy)
configuration.getEntity("directory.doc");
! /* Need to have a final variable to hold the introURL in order
! * to use in an anonymous class.
! */
! final URL finalIntroURL = introURL;
! SwingUtilities.invokeLater( new Runnable() {
! public void run() {
! try {
!
doc.identifier.setExpression(finalIntroURL.toExternalForm());
! }
! catch( IllegalActionException ex ) {
! /* Not certain what to do with this here */
! }
! }
! });
return configuration;
More information about the Kepler-dev
mailing list