mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Bugfix: Race condition at startup, resulting in "Cannot instantiate SplashFrame" error.
This commit is contained in:
@@ -92,6 +92,8 @@ public enum FControl {
|
||||
public void windowClosing(final WindowEvent e) {
|
||||
Singletons.getView().getFrame().setDefaultCloseOperation(
|
||||
WindowConstants.EXIT_ON_CLOSE);
|
||||
|
||||
System.exit(0);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -131,7 +133,6 @@ public enum FControl {
|
||||
|
||||
FView.SINGLETON_INSTANCE.getLpnDocument().addMouseListener(SOverflowUtil.getHideOverflowListener());
|
||||
FView.SINGLETON_INSTANCE.getLpnDocument().addComponentListener(SResizingUtil.getWindowResizeListener());
|
||||
Singletons.getView().getFrame().setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
||||
}
|
||||
|
||||
/** After view and model have been initialized, control can start. */
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
* Forge: Play Magic: the Gathering.
|
||||
* Copyright (C) 2011 Forge Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
*
|
||||
import forge.view.SplashFrame;
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
@@ -11,7 +11,6 @@ import java.util.List;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLayeredPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
@@ -49,13 +48,7 @@ public enum FView {
|
||||
|
||||
//
|
||||
private FView() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try { splash = new SplashFrame(); }
|
||||
catch (Exception e) { e.printStackTrace(); }
|
||||
}
|
||||
});
|
||||
splash = new SplashFrame();
|
||||
}
|
||||
|
||||
/** */
|
||||
|
||||
@@ -21,7 +21,6 @@ import javax.swing.SwingUtilities;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.control.FControl;
|
||||
import forge.error.ErrorViewer;
|
||||
import forge.error.ExceptionHandler;
|
||||
import forge.model.FModel;
|
||||
|
||||
@@ -45,9 +44,20 @@ public final class Main {
|
||||
*/
|
||||
public static void main(final String[] args) {
|
||||
ExceptionHandler.registerErrorHandling();
|
||||
try {
|
||||
|
||||
Singletons.setModel(FModel.SINGLETON_INSTANCE);
|
||||
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Singletons.setView(FView.SINGLETON_INSTANCE);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Singletons.setControl(FControl.SINGLETON_INSTANCE);
|
||||
|
||||
// Use splash frame to initialize everything, then transition to core UI.
|
||||
@@ -55,10 +65,6 @@ public final class Main {
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() { @Override
|
||||
public void run() { Singletons.getView().initialize(); } });
|
||||
|
||||
} catch (final Throwable exn) {
|
||||
ErrorViewer.showError(exn);
|
||||
}
|
||||
}
|
||||
|
||||
/** @throws Throwable */
|
||||
|
||||
@@ -63,10 +63,8 @@ public class SplashFrame extends JFrame {
|
||||
* Create the frame; this <strong>must</strong> be called from an event
|
||||
* dispatch thread.
|
||||
*
|
||||
* @throws Exception {@link IllegalStateException} if not called from an
|
||||
* event dispatch thread.
|
||||
*/
|
||||
public SplashFrame() throws Exception {
|
||||
public SplashFrame() {
|
||||
super();
|
||||
|
||||
if (!SwingUtilities.isEventDispatchThread()) {
|
||||
|
||||
Reference in New Issue
Block a user