]> saetta.ns0.it Git - libgtkform/commitdiff
Wrong variable overwrite in checking min and max value on FieldDatetime.
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Mon, 17 Dec 2012 09:46:07 +0000 (10:46 +0100)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Mon, 17 Dec 2012 09:46:07 +0000 (10:46 +0100)
libgtkform/fielddatetime.c

index b5ff8b880fcbb97ff1d0fe6b92fa2c4eb5251f5e..e3e7d61a46f7b3043d57a3216a4a8afe6c158da5 100644 (file)
@@ -427,21 +427,26 @@ gtk_form_field_datetime_is_valid (GtkFormField *field)
                                                {
                                                        gdt_tmp = g_date_time_new_now_local ();
 
-                                                       if (priv->type == GTK_FORM_FIELD_DATETIME_TYPE_DATE)
+                                                       switch (priv->type)
                                                                {
-                                                                       gdt_min_value = g_date_time_new_local (g_date_time_get_year (gdt_tmp),
-                                                                                                              g_date_time_get_month (gdt_tmp),
-                                                                                                              g_date_time_get_day_of_month (gdt_tmp),
-                                                                                                              0, 0, 0.0);
+                                                                       case GTK_FORM_FIELD_DATETIME_TYPE_DATE:
+                                                                               gdt_min_value = g_date_time_new_local (g_date_time_get_year (gdt_tmp),
+                                                                                                                      g_date_time_get_month (gdt_tmp),
+                                                                                                                      g_date_time_get_day_of_month (gdt_tmp),
+                                                                                                                      0, 0, 0.0);
+                                                                               break;
+
+                                                                       case GTK_FORM_FIELD_DATETIME_TYPE_TIME:
+                                                                               gdt_min_value = g_date_time_new_local (1, 1, 1,
+                                                                                                                      g_date_time_get_hour (gdt_tmp),
+                                                                                                                      g_date_time_get_minute (gdt_tmp),
+                                                                                                                      g_date_time_get_seconds (gdt_tmp));
+                                                                               break;
+
+                                                                       default:
+                                                                               gdt_min_value = g_date_time_ref (gdt_tmp);
+                                                                               break;
                                                                }
-                                                       else if (priv->type == GTK_FORM_FIELD_DATETIME_TYPE_TIME)
-                                                               {
-                                                                       gdt_min_value = g_date_time_new_local (1, 1, 1,
-                                                                                                              g_date_time_get_hour (gdt_tmp),
-                                                                                                              g_date_time_get_minute (gdt_tmp),
-                                                                                                              g_date_time_get_seconds (gdt_tmp));
-                                                               }
-                                                       gdt_min_value = g_date_time_ref (gdt_tmp);
                                                        g_date_time_unref (gdt_tmp);
                                                }
                                        else
@@ -466,21 +471,26 @@ gtk_form_field_datetime_is_valid (GtkFormField *field)
                                                {
                                                        gdt_tmp = g_date_time_new_now_local ();
 
-                                                       if (priv->type == GTK_FORM_FIELD_DATETIME_TYPE_DATE)
-                                                               {
-                                                                       gdt_max_value = g_date_time_new_local (g_date_time_get_year (gdt_tmp),
-                                                                                                              g_date_time_get_month (gdt_tmp),
-                                                                                                              g_date_time_get_day_of_month (gdt_tmp),
-                                                                                                              0, 0, 0.0);
-                                                               }
-                                                       else if (priv->type == GTK_FORM_FIELD_DATETIME_TYPE_TIME)
+                                                       switch (priv->type)
                                                                {
-                                                                       gdt_max_value = g_date_time_new_local (1, 1, 1,
-                                                                                                              g_date_time_get_hour (gdt_tmp),
-                                                                                                              g_date_time_get_minute (gdt_tmp),
-                                                                                                              g_date_time_get_seconds (gdt_tmp));
+                                                                       case GTK_FORM_FIELD_DATETIME_TYPE_DATE:
+                                                                               gdt_max_value = g_date_time_new_local (g_date_time_get_year (gdt_tmp),
+                                                                                                                      g_date_time_get_month (gdt_tmp),
+                                                                                                                      g_date_time_get_day_of_month (gdt_tmp),
+                                                                                                                      0, 0, 0.0);
+                                                                               break;
+
+                                                                       case GTK_FORM_FIELD_DATETIME_TYPE_TIME:
+                                                                               gdt_max_value = g_date_time_new_local (1, 1, 1,
+                                                                                                                      g_date_time_get_hour (gdt_tmp),
+                                                                                                                      g_date_time_get_minute (gdt_tmp),
+                                                                                                                      g_date_time_get_seconds (gdt_tmp));
+                                                                               break;
+
+                                                                       default:
+                                                                               gdt_max_value = g_date_time_ref (gdt_tmp);
+                                                                               break;
                                                                }
-                                                       gdt_max_value = g_date_time_ref (gdt_tmp);
                                                        g_date_time_unref (gdt_tmp);
                                                }
                                        else