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