From fbe6bf3792d681c23b299efbbab9f814c08cbc7a Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 7 Nov 2016 15:27:02 +0100 Subject: [PATCH] Moved all initializations into Base constructor --- app/src/processing/app/Base.java | 89 +++++++++++++++----------------- 1 file changed, 42 insertions(+), 47 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index aff37e0a1..a96ac221a 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -128,59 +128,13 @@ public class Base { } try { - guardedMain(args); + INSTANCE = new Base(args); } catch (Throwable e) { e.printStackTrace(System.err); System.exit(255); } } - static public void guardedMain(String args[]) throws Exception { - Thread deleteFilesOnShutdownThread = new Thread(DeleteFilesOnShutdown.INSTANCE); - deleteFilesOnShutdownThread.setName("DeleteFilesOnShutdown"); - Runtime.getRuntime().addShutdownHook(deleteFilesOnShutdownThread); - - BaseNoGui.initLogger(); - - initLogger(); - - BaseNoGui.initPlatform(); - - BaseNoGui.getPlatform().init(); - - BaseNoGui.initPortableFolder(); - - BaseNoGui.initParameters(args); - - splashScreenHelper.splashText(tr("Loading configuration...")); - - BaseNoGui.initVersion(); - - // Use native popups so they don't look so crappy on osx - JPopupMenu.setDefaultLightWeightPopupEnabled(false); - - // Don't put anything above this line that might make GUI, - // because the platform has to be inited properly first. - - // setup the theme coloring fun - Theme.init(); - System.setProperty("swing.aatext", PreferencesData.get("editor.antialias", "true")); - - // Set the look and feel before opening the window - try { - BaseNoGui.getPlatform().setLookAndFeel(); - } catch (Exception e) { - // ignore - } - - // Create a location for untitled sketches - untitledFolder = FileUtils.createTempFolder("untitled" + new Random().nextInt(Integer.MAX_VALUE), ".tmp"); - DeleteFilesOnShutdown.add(untitledFolder); - - INSTANCE = new Base(args); - } - - static public void initLogger() { Handler consoleHandler = new ConsoleLogger(); consoleHandler.setLevel(Level.ALL); @@ -227,6 +181,47 @@ public class Base { } public Base(String[] args) throws Exception { + Thread deleteFilesOnShutdownThread = new Thread(DeleteFilesOnShutdown.INSTANCE); + deleteFilesOnShutdownThread.setName("DeleteFilesOnShutdown"); + Runtime.getRuntime().addShutdownHook(deleteFilesOnShutdownThread); + + BaseNoGui.initLogger(); + + initLogger(); + + BaseNoGui.initPlatform(); + + BaseNoGui.getPlatform().init(); + + BaseNoGui.initPortableFolder(); + + BaseNoGui.initParameters(args); + + splashScreenHelper.splashText(tr("Loading configuration...")); + + BaseNoGui.initVersion(); + + // Use native popups so they don't look so crappy on osx + JPopupMenu.setDefaultLightWeightPopupEnabled(false); + + // Don't put anything above this line that might make GUI, + // because the platform has to be inited properly first. + + // setup the theme coloring fun + Theme.init(); + System.setProperty("swing.aatext", PreferencesData.get("editor.antialias", "true")); + + // Set the look and feel before opening the window + try { + BaseNoGui.getPlatform().setLookAndFeel(); + } catch (Exception e) { + // ignore + } + + // Create a location for untitled sketches + untitledFolder = FileUtils.createTempFolder("untitled" + new Random().nextInt(Integer.MAX_VALUE), ".tmp"); + DeleteFilesOnShutdown.add(untitledFolder); + BaseNoGui.notifier = new GUIUserNotifier(this); CommandlineParser parser = new CommandlineParser(args);