From: Andrea Zagli Date: Mon, 17 Dec 2012 09:46:07 +0000 (+0100) Subject: Wrong variable overwrite in checking min and max value on FieldDatetime. X-Git-Tag: 0.5.0~5 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=f8704b82f8a6ba0d8e1449acfe7e23a4d7edcf44;p=libgtkform Wrong variable overwrite in checking min and max value on FieldDatetime. --- diff --git a/libgtkform/fielddatetime.c b/libgtkform/fielddatetime.c index b5ff8b8..e3e7d61 100644 --- a/libgtkform/fielddatetime.c +++ b/libgtkform/fielddatetime.c @@ -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