Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Moved all initializations into Base constructor
  • Loading branch information
cmaglie committed Nov 25, 2016
commit fbe6bf3792d681c23b299efbbab9f814c08cbc7a
89 changes: 42 additions & 47 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,59 +128,13 @@ static public void main(String args[]) throws Exception {
}

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);
Expand Down Expand Up @@ -227,6 +181,47 @@ static public File absoluteFile(String path) {
}

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);
Expand Down