OSDN Git Service

Fix Diagnostic Message Handler initialisation logic.
authorKeith Marshall <keithmarshall@users.sourceforge.net>
Thu, 18 Oct 2012 13:08:05 +0000 (14:08 +0100)
committerKeith Marshall <keithmarshall@users.sourceforge.net>
Thu, 18 Oct 2012 13:08:05 +0000 (14:08 +0100)
ChangeLog
src/dmh.cpp

index f7b4b67..99b55b5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2012-10-18  Keith Marshall  <keithmarshall@users.sourceforge.net>
+
+       Fix Diagnostic Message Handler initialisation logic.
+
+       * src/dmh.cpp (dmh_init) [DMH_SUBSYSTEM_GUI]: Correct a logic error;
+       it previously fell through after any successful initialisation of the
+       DMH_SUBSYSTEM_GUI handler, replacing it with a DMH_SUBSYSTEM_TTY type
+       handler.  Also, assign a heap copy of the passed "progname" string
+       resource, which is volatile, to ensure that the handler retains a
+       valid reference.
+
 2012-10-11  Keith Marshall  <keithmarshall@users.sourceforge.net>
 
        Implement preliminary GUI mode data sheet compiler.
index 91bca19..c36c5bb 100644 (file)
@@ -104,16 +104,17 @@ EXTERN_C void dmh_init( const dmh_class subsystem, const char *progname )
     /* No message handler has yet been initialised;
      * passing the specified program name, select...
      */
-    if( (subsystem == DMH_SUBSYSTEM_GUI)
+    if( subsystem == DMH_SUBSYSTEM_GUI )
+    {
       /*
        * ...a GUI class handler on demand...
        */
-    && ((dmh = dmh_init_gui( progname )) == NULL) )
-      /*
-       * ...but bail out, if this cannot be initialised...
-       */
-      throw dmh_exception( "DMH subsystem initialisation failed" );
-
+      if( (dmh = dmh_init_gui( strdup( progname ))) == NULL )
+       /*
+        * ...but bail out, if this cannot be initialised...
+        */
+       throw dmh_exception( "DMH subsystem initialisation failed" );
+    }
     else
       /* ...otherwise, a console class handler by default.
        */