Fix crash at startup due to splash screen handling
This commit is contained in:
parent
a28c99fc54
commit
efb4952333
@ -13,6 +13,7 @@ import javax.swing.Timer;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import net.sf.openrocket.database.ThrustCurveMotorSetDatabase;
|
||||
import net.sf.openrocket.gui.main.Splash;
|
||||
import net.sf.openrocket.gui.util.GUIUtil;
|
||||
import net.sf.openrocket.l10n.Translator;
|
||||
import net.sf.openrocket.logging.LogHelper;
|
||||
@ -61,7 +62,8 @@ public class MotorDatabaseLoadingDialog extends JDialog {
|
||||
if (db.isLoaded())
|
||||
return;
|
||||
|
||||
if (SplashScreen.getSplashScreen() == null) {
|
||||
SplashScreen splash = Splash.getSplashScreen();
|
||||
if (splash == null || !splash.isVisible()) {
|
||||
|
||||
log.info(1, "Motor database not loaded yet, displaying dialog");
|
||||
|
||||
|
@ -34,6 +34,7 @@ import javax.swing.event.MouseInputAdapter;
|
||||
import net.sf.openrocket.gui.figureelements.CGCaret;
|
||||
import net.sf.openrocket.gui.figureelements.CPCaret;
|
||||
import net.sf.openrocket.gui.figureelements.FigureElement;
|
||||
import net.sf.openrocket.gui.main.Splash;
|
||||
import net.sf.openrocket.logging.LogHelper;
|
||||
import net.sf.openrocket.rocketcomponent.Configuration;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
@ -89,8 +90,8 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
|
||||
//Only initizlize GL if 3d is enabled.
|
||||
if (is3dEnabled()) {
|
||||
//Fixes a linux / X bug: Splash must be closed before GL Init
|
||||
SplashScreen splash = SplashScreen.getSplashScreen();
|
||||
if ( splash != null )
|
||||
SplashScreen splash = Splash.getSplashScreen();
|
||||
if (splash != null && splash.isVisible())
|
||||
splash.close();
|
||||
|
||||
initGLCanvas();
|
||||
@ -223,12 +224,12 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
|
||||
|
||||
if (pressEvent.getButton() == MouseEvent.BUTTON1) {
|
||||
if (Math.abs(dx) > Math.abs(dy)) {
|
||||
setYaw(yaw - (float) dx / 100.0);
|
||||
setYaw(yaw - dx / 100.0);
|
||||
} else {
|
||||
if (yaw > Math.PI / 2.0 && yaw < 3.0 * Math.PI / 2.0) {
|
||||
dy = -dy;
|
||||
}
|
||||
setRoll(roll - (float) dy / 100.0);
|
||||
setRoll(roll - dy / 100.0);
|
||||
}
|
||||
} else {
|
||||
lightPosition[0] -= 0.1f * dx;
|
||||
|
@ -38,7 +38,7 @@ public class Splash {
|
||||
*/
|
||||
public static boolean init() {
|
||||
// Get the splash screen
|
||||
SplashScreen s = getSplash();
|
||||
SplashScreen s = getSplashScreen();
|
||||
if (s == null)
|
||||
return false;
|
||||
|
||||
@ -75,14 +75,19 @@ public class Splash {
|
||||
|
||||
|
||||
/**
|
||||
* Return the current splash screen or <code>null</code> if not available.
|
||||
* Return the current splash screen or <code>null</code> if not available or already closed.
|
||||
* This method catches the possible exceptions and returns null if they occur.
|
||||
*
|
||||
* @return the current splash screen, or <code>null</code>.
|
||||
* @return the current (visible) splash screen, or <code>null</code>.
|
||||
*/
|
||||
private static SplashScreen getSplash() {
|
||||
public static SplashScreen getSplashScreen() {
|
||||
try {
|
||||
return SplashScreen.getSplashScreen();
|
||||
SplashScreen splash = SplashScreen.getSplashScreen();
|
||||
if (splash != null && splash.isVisible()) {
|
||||
return splash;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
return null;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user