diff mde/lookup/Options.d @ 85:56c0ddd90193

Intermediate commit (not stable). Changes to init system.
author Diggory Hardy <diggory.hardy@gmail.com>
date Thu, 11 Sep 2008 11:33:51 +0100
parents e0f1ec7fe73a
children 79d816b3e2d2
line wrap: on
line diff
--- a/mde/lookup/Options.d	Sun Aug 31 15:59:17 2008 +0100
+++ b/mde/lookup/Options.d	Thu Sep 11 11:33:51 2008 +0100
@@ -136,6 +136,7 @@
             assert (c !is null);    // Instance must be created before calling addOptionsClass
             assert (((cast(ID) i) in subClasses) is null);  // Don't allow a silent replacement
         } body {
+            debug logger.trace ("Adding Options subClass: "~i);
             subClasses[cast(ID) i] = c;
         }
     
@@ -168,15 +169,27 @@
         }
         void save () {
             if (!changed) return;   // no changes to save
-        
+            // Types:
+            // interface IDataSection {...}
+            // class Options {...}
+            // alias char[] ID;
+            // IDataSection[ID] ds.sec;
+            // Options[ID] subClasses;
             DataSet ds = new DataSet();
-            foreach (id, subOpts; subClasses) ds.sec[id] = subOpts.optionChanges;
-        
+            foreach (id, subOpts; subClasses) {
+                ds.sec[id] = subOpts.optionChanges;
+                debug logger.trace ("Saving options section: "~id);
+            }
+            foreach (i,s; ds.sec)
+                debug logger.trace ("sec ID length: {}", i.length);
+            debug logger.trace ("0");
+            
             // Read locally-stored options
             try {
                 IReader reader;
                 reader = confDir.makeMTReader (fileName, PRIORITY.HIGH_ONLY, ds);
                 reader.dataSecCreator = delegate IDataSection(ID id) {
+                    debug logger.trace ("New section to save ignored: "~id);
                     return null;    // All recognised sections are already in the dataset.
                 };
                 reader.read;
@@ -188,9 +201,15 @@
             }
         
             try {
+                debug logger.trace ("1");
                 IWriter writer;
-                writer = confDir.makeMTWriter (fileName, ds);
-                writer.write();
+                foreach (i,s; ds.sec)
+                    debug logger.trace ("sec ID length: {}", i.length);
+                debug logger.trace ("2");
+                writer = confDir.makeMTWriter (fileName, ds);   // FIXME - sometimes SIGSEGV
+                debug logger.trace ("3");
+                writer.write(); // FIXME - this is causing hang at exit!
+                debug logger.trace ("4");
             } catch (Exception e) {
                 logger.error ("Saving options aborted: "~e.msg);
             }
@@ -457,7 +476,7 @@
 /** A home for all miscellaneous options, at least for now. */
 OptionsMisc miscOpts;
 class OptionsMisc : Options {
-    mixin (impl!("bool useThreads, exitImmediately; int logOptions; double pollInterval; char[] L10n, a,b,c;"));
+    mixin (impl!("bool exitImmediately; int numThreads, logOptions; double pollInterval; char[] L10n, a,b,c;"));
     
     static this() {
         miscOpts = new OptionsMisc;