From 8031b9cf51e0a7fc9d758adee5b59a19af404951 Mon Sep 17 00:00:00 2001 From: bkuker Date: Tue, 28 Aug 2012 22:16:17 +0000 Subject: [PATCH] - Remove GL Late-initialization. GL is now set up when RocketFigure3d is constructed. This fixes a crash / hang on Java 7. - Splash Screen must now be closed sooner. RocketFigure3d performs this task. This fixes a crash on Linux / X11. - Check for "-Dopenrocket.3d.disable" and do no GL setup at all if this is defined. If users find GL cause OpenRocket to crash they may specify this option and use OR (Without 3d!) git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@1005 180e2498-e6e9-4542-8430-84ac67f01cd8 --- core/ChangeLog | 6 ++++ core/doc/properties.txt | 3 +- .../gui/figure3d/RocketFigure3d.java | 36 ++++++++++--------- .../gui/scalefigure/RocketPanel.java | 2 +- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/core/ChangeLog b/core/ChangeLog index 87738415..5987e25d 100644 --- a/core/ChangeLog +++ b/core/ChangeLog @@ -1,3 +1,9 @@ +2012-08-28 Bill Kuker + + * Removed late GL initialization, was causing issues with Java 7. + + * Added -Dopenrocket.3d.disable option for anyone experiencing crashes as a result of OpenGL. + 2012-08-01 Kevin Ruland * Changed the loader to pull *.rkt files from zip containers. diff --git a/core/doc/properties.txt b/core/doc/properties.txt index db4a52fa..c9a44cb4 100644 --- a/core/doc/properties.txt +++ b/core/doc/properties.txt @@ -9,7 +9,8 @@ openrocket.locale Select the default locale to be used, for example "en_US". If set to "xx", the logical keys will be displayed instead of the translated strings. - +openrocket.3d.disable + Disables all OpenGL calls if set. Logging options --------------- diff --git a/core/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java b/core/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java index 3e3a98c4..8df1e850 100644 --- a/core/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java +++ b/core/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java @@ -6,8 +6,7 @@ import java.awt.Graphics2D; import java.awt.Point; import java.awt.Rectangle; import java.awt.RenderingHints; -import java.awt.event.HierarchyEvent; -import java.awt.event.HierarchyListener; +import java.awt.SplashScreen; import java.awt.event.MouseEvent; import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; @@ -86,20 +85,25 @@ public class RocketFigure3d extends JPanel implements GLEventListener { public RocketFigure3d(Configuration config) { this.configuration = config; this.setLayout(new BorderLayout()); - - /** - * This achieves late GL initialization, so that if there is a crash - * it does not occur until user selects 3D view, so as to not render - * the application unusable. - */ - addHierarchyListener(new HierarchyListener() { - @Override - public void hierarchyChanged(HierarchyEvent e) { - log.verbose("GL - Calling initGLCanvas on hierarchy change"); - initGLCanvas(); - RocketFigure3d.this.removeHierarchyListener(this); - } - }); + + //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 ) + splash.close(); + + initGLCanvas(); + } + } + + /** + * Return true if 3d view is enabled. This may be toggled by the user at + * launch time. + * @return + */ + public static boolean is3dEnabled(){ + return System.getProperty("openrocket.3d.disable") == null; } private void initGLCanvas(){ diff --git a/core/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java b/core/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java index ed80812d..2cef7080 100644 --- a/core/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java +++ b/core/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java @@ -285,9 +285,9 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change } }); bg.add(toggle3d); + toggle3d.setEnabled(RocketFigure3d.is3dEnabled()); add(toggle3d, "gap rel"); - // Zoom level selector scaleSelector = new ScaleSelector(scrollPane); add(scaleSelector); -- 2.30.2