Move static function useSafetyChecks() to Application.
authorkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Tue, 13 Dec 2011 19:20:59 +0000 (19:20 +0000)
committerkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Tue, 13 Dec 2011 19:20:59 +0000 (19:20 +0000)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@228 180e2498-e6e9-4542-8430-84ac67f01cd8

src/net/sf/openrocket/startup/Application.java
src/net/sf/openrocket/util/Invalidator.java
src/net/sf/openrocket/util/SafetyMutex.java

index dbe28f848f88d140ccf0cccb5627072f774fa991..863776f7925be5e7e147688a7d53c1967563388c 100644 (file)
@@ -31,6 +31,17 @@ public final class Application {
                setLogOutputLevel(LogLevel.DEBUG);
        }
        
+       /**
+        * Return whether to use additional safety code checks.
+        */
+       public static boolean useSafetyChecks() {
+               // Currently default to false unless openrocket.debug.safetycheck is defined
+               String s = System.getProperty("openrocket.debug.safetycheck");
+               if (s != null && !(s.equalsIgnoreCase("false") || s.equalsIgnoreCase("off"))) {
+                       return true;
+               }
+               return false;
+       }
        
        /**
         * Retrieve the logger to be used in logging.  By default this returns
index 7b6781141aa39a49951a8daa165c7a0008e56c22..9e40c10293b7052821ca6d4b2cdcece608bd5b7c 100644 (file)
@@ -10,7 +10,7 @@ import net.sf.openrocket.startup.Application;
  * @author Sampo Niskanen <sampo.niskanen@iki.fi>
  */
 public class Invalidator implements Invalidatable {
-       private static final boolean USE_CHECKS = Prefs.useSafetyChecks();
+       private static final boolean USE_CHECKS = Application.useSafetyChecks();
        
        private static final LogHelper log = Application.getLogger();
        
index df0139b99117003170ab9d90b2ff4f7b32281076..1e8267ebcca3577243cd77c0bc854d7bebb06c4f 100644 (file)
@@ -18,6 +18,7 @@ import net.sf.openrocket.startup.Application;
  * @author Sampo Niskanen <sampo.niskanen@iki.fi>
  */
 public abstract class SafetyMutex {
+       private static final boolean USE_CHECKS = Application.useSafetyChecks();
        private static final LogHelper log = Application.getLogger();
        
        
@@ -28,7 +29,7 @@ public abstract class SafetyMutex {
         * @return      a new instance of a safety mutex
         */
        public static SafetyMutex newInstance() {
-               if (Prefs.useSafetyChecks()) {
+               if (USE_CHECKS) {
                        return new ConcreteSafetyMutex();
                } else {
                        return new BogusSafetyMutex();