[Xfce4-commits] <xfwm4:master> Use explicit message when actual type of option does not match the expected type (so the warning can be useful)

Olivier Fourdan noreply at xfce.org
Wed Feb 24 19:38:03 CET 2010


Updating branch refs/heads/master
         to 88b0f9105f8a8a688a72743ccf75907f2fed2497 (commit)
       from 6b385d5f53ce84fa05ba66955be0b3f5b7d794e4 (commit)

commit 88b0f9105f8a8a688a72743ccf75907f2fed2497
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Wed Feb 24 14:24:27 2010 +0100

    Use explicit message when actual type of option does not match the expected type (so the warning can be useful)

 src/parserc.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/parserc.c b/src/parserc.c
index 132ecaa..ac1e0fc 100644
--- a/src/parserc.c
+++ b/src/parserc.c
@@ -300,7 +300,11 @@ getStringValue (const gchar *option, Settings *rc)
         {
             if (rc[i].value == NULL)
                 return NULL;
-            g_return_val_if_fail(G_VALUE_TYPE(rc[i].value) == G_TYPE_STRING, NULL);
+            if (G_VALUE_TYPE(rc[i].value) != G_TYPE_STRING)
+            {
+                g_warning ("Option \"%s\" in not of expected type string", option);
+                return NULL;
+            }
             return g_value_get_string(rc[i].value);
         }
     }
@@ -322,7 +326,11 @@ getIntValue (const gchar *option, Settings *rc)
         {
             if (rc[i].value == NULL)
                 return 0;
-            g_return_val_if_fail(G_VALUE_TYPE(rc[i].value) == G_TYPE_INT, 0);
+            if (G_VALUE_TYPE(rc[i].value) != G_TYPE_INT)
+            {
+                g_warning ("Option \"%s\" in not of expected type int", option);
+                return 0;
+            }
             return g_value_get_int(rc[i].value);
         }
     }
@@ -344,7 +352,11 @@ getBoolValue (const gchar *option, Settings *rc)
         {
             if (rc[i].value == NULL)
                 return FALSE;
-            g_return_val_if_fail(G_VALUE_TYPE(rc[i].value) == G_TYPE_BOOLEAN, FALSE);
+            if (G_VALUE_TYPE(rc[i].value) != G_TYPE_BOOLEAN)
+            {
+                g_warning ("Option \"%s\" in not of expected type boolean", option);
+                return FALSE;
+            }
             return g_value_get_boolean(rc[i].value);
         }
     }



More information about the Xfce4-commits mailing list