[ekiga/ds-gtk-application] GmEntry: Fixed entry validation when allow_empty is FALSE.



commit e9ced59eec7d69e6489633271f028ba8727b7c30
Author: Damien Sandras <dsandras seconix com>
Date:   Sun Dec 21 12:35:46 2014 +0100

    GmEntry: Fixed entry validation when allow_empty is FALSE.
    
    The GmEntry was validating despite allow_empty was FALSE when there was
    no Regex.

 lib/gui/gm-entry.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/lib/gui/gm-entry.c b/lib/gui/gm-entry.c
index 0c2a737..74e9898 100644
--- a/lib/gui/gm-entry.c
+++ b/lib/gui/gm-entry.c
@@ -408,19 +408,20 @@ gm_entry_text_is_valid (GmEntry *self)
   gchar *value = NULL;
 
   g_return_val_if_fail (GM_IS_ENTRY (self), success);
-  if (!self->priv->regex)
-    return TRUE;
 
   const char *content = gtk_entry_get_text (GTK_ENTRY (self));
-  if (self->priv->allow_empty) {
-    value = g_strdup (content);
-    value = g_strstrip (value);
-    if (!g_strcmp0 (value, "")) {
-      g_free (value);
-      return TRUE;
-    }
+  value = g_strdup (content);
+  value = g_strstrip (value);
+  // First check if value is empty or not
+  if (!g_strcmp0 (value, "")) {
     g_free (value);
+    return self->priv->allow_empty;
   }
+  g_free (value);
+
+  // Here, value is not empty, we check the regex
+  if (!self->priv->regex)
+    return TRUE;
 
   g_regex_match (self->priv->regex, content, 0, &match_info);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]