From: <adr...@us...> - 2010-09-05 20:41:35
|
Revision: 3773 http://reprap.svn.sourceforge.net/reprap/?rev=3773&view=rev Author: adrian-bowyer Date: 2010-09-05 20:41:28 +0000 (Sun, 05 Sep 2010) Log Message: ----------- Bug whereby the host crashed the first time you ran it if you have no preferences file fixed. Modified Paths: -------------- trunk/software/host/src/org/reprap/Main.java trunk/software/host/src/org/reprap/Preferences.java trunk/software/host/src/org/reprap/machines/MachineFactory.java Modified: trunk/software/host/src/org/reprap/Main.java =================================================================== --- trunk/software/host/src/org/reprap/Main.java 2010-09-05 20:10:08 UTC (rev 3772) +++ trunk/software/host/src/org/reprap/Main.java 2010-09-05 20:41:28 UTC (rev 3773) @@ -96,13 +96,14 @@ FileFilter filter = new ExtensionFileFilter("STL", new String[] { "STL" }); chooser.setFileFilter(filter); + try { printer = MachineFactory.create(); } catch (Exception ex) { - System.err.println("MachineFactory.create() failed.\n" + - ex.toString()); + System.err.println("MachineFactory.create() failed.\n"); + ex.printStackTrace(); } } @@ -728,15 +729,15 @@ Debug.d("Main dispose()"); ftd.killThem(); /// TODO This class should be fixed so it gets the dispose on window close - try { - // Attempt to save screen position if requested - org.reprap.Preferences prefs = org.reprap.Preferences.getGlobalPreferences(); - if (prefs.loadBool("RememberWindowPosition")) { - //prefs.setGlobalBool("MainWindowTop", xxx) - } - } catch (Exception ex) { - - } +// try { +// // Attempt to save screen position if requested +// org.reprap.Preferences prefs = org.reprap.Preferences.getGlobalPreferences(); +// if (prefs.loadBool("RememberWindowPosition")) { +// //prefs.setGlobalBool("MainWindowTop", xxx); +// } +// } catch (Exception ex) { +// +// } System.exit(0); } Modified: trunk/software/host/src/org/reprap/Preferences.java =================================================================== --- trunk/software/host/src/org/reprap/Preferences.java 2010-09-05 20:10:08 UTC (rev 3772) +++ trunk/software/host/src/org/reprap/Preferences.java 2010-09-05 20:41:28 UTC (rev 3773) @@ -91,7 +91,8 @@ URL mainUrl = mainFile.toURI().toURL(); if (fallbackUrl == null && !mainFile.exists()) - throw new IOException("Cannot load RepRap properties file or default "+propsFileDist); + //throw new IOException("Cannot load RepRap properties file or default "+propsFileDist); + Debug.e("Cannot load RepRap properties file or default "+propsFileDist); if (fallbackUrl != null) fallbackPreferences.load(fallbackUrl.openStream()); @@ -106,7 +107,7 @@ // If we don't have a local preferences file copy the default // file into it. mainPreferences.load(fallbackUrl.openStream()); - save(); + save(true); } } @@ -173,7 +174,7 @@ Debug.d("The distribution preferences file and yours match. This is good."); } - public void save() throws FileNotFoundException, IOException { + public void save(boolean startUp) throws FileNotFoundException, IOException { String savePath = new String(System.getProperty("user.home") + File.separatorChar + propsFolder + File.separatorChar); File f = new File(savePath + File.separatorChar + propsFile); @@ -188,7 +189,9 @@ OutputStream output = new FileOutputStream(f); mainPreferences.store(output, "RepRap machine parameters. See http://objects.reprap.org/wiki/Java_Software_Preferences_File"); - org.reprap.Main.gui.getPrinter().refreshPreferences(); + + if(!startUp) + org.reprap.Main.gui.getPrinter().refreshPreferences(); } public String loadString(String name) { @@ -260,7 +263,7 @@ public static void saveGlobal() throws IOException { initIfNeeded(); - globalPrefs.save(); + globalPrefs.save(false); } public static Preferences getGlobalPreferences() throws IOException { Modified: trunk/software/host/src/org/reprap/machines/MachineFactory.java =================================================================== --- trunk/software/host/src/org/reprap/machines/MachineFactory.java 2010-09-05 20:10:08 UTC (rev 3772) +++ trunk/software/host/src/org/reprap/machines/MachineFactory.java 2010-09-05 20:41:28 UTC (rev 3773) @@ -24,7 +24,7 @@ */ static public Printer create() throws Exception { - String machine = Preferences.loadGlobalString("RepRap_Machine"); + String machine = org.reprap.Preferences.loadGlobalString("RepRap_Machine"); // if (machine.compareToIgnoreCase("SNAPRepRap") == 0) // return new SNAPReprap(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |