From: Andrea Zagli Date: Thu, 29 Sep 2011 11:36:43 +0000 (+0200) Subject: Bugfix. X-Git-Tag: 0.4.0~7 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=6228084341e138720b8205a1a7f3dc401995c953;p=libgtkform Bugfix. --- diff --git a/libgtkform/fielddatetime.c b/libgtkform/fielddatetime.c index bcb62a3..d92b244 100644 --- a/libgtkform/fielddatetime.c +++ b/libgtkform/fielddatetime.c @@ -352,8 +352,8 @@ gtk_form_field_datetime_is_changed (GtkFormField *field) if (value != NULL && priv->original_value != NULL) { ret = (g_date_time_get_year (value) != g_date_time_get_year (priv->original_value) - || g_date_time_get_month (value) != g_date_time_get_month (priv->original_value) - || g_date_time_get_day_of_month (value) != g_date_time_get_day_of_month (priv->original_value)); + || g_date_time_get_month (value) != g_date_time_get_month (priv->original_value) + || g_date_time_get_day_of_month (value) != g_date_time_get_day_of_month (priv->original_value)); if (!ret && priv->type == GTK_FORM_FIELD_DATETIME_TYPE_DATETIME) { ret = (g_date_time_get_hour (value) != g_date_time_get_hour (priv->original_value) @@ -519,12 +519,19 @@ gtk_form_field_datetime_set_as_origin (GtkFormField *field) value = gtk_form_field_datetime_get_gdatetime_from_str (gtk_form_field_datetime_get_value_stringify (field), priv->display_format); - priv->original_value = g_date_time_new_local (priv->type != GTK_FORM_FIELD_DATETIME_TYPE_TIME ? g_date_time_get_year (value) : 1, - priv->type != GTK_FORM_FIELD_DATETIME_TYPE_TIME ?g_date_time_get_month (value) : 1, - priv->type != GTK_FORM_FIELD_DATETIME_TYPE_TIME ?g_date_time_get_day_of_month (value) : 1, - priv->type != GTK_FORM_FIELD_DATETIME_TYPE_DATE ? g_date_time_get_hour (value): 0, - priv->type != GTK_FORM_FIELD_DATETIME_TYPE_DATE ? g_date_time_get_minute (value): 0, - priv->type != GTK_FORM_FIELD_DATETIME_TYPE_DATE ? g_date_time_get_seconds (value): 0.0); + if (value == NULL) + { + priv->original_value = NULL; + } + else + { + priv->original_value = g_date_time_new_local (priv->type != GTK_FORM_FIELD_DATETIME_TYPE_TIME ? g_date_time_get_year (value) : 1, + priv->type != GTK_FORM_FIELD_DATETIME_TYPE_TIME ?g_date_time_get_month (value) : 1, + priv->type != GTK_FORM_FIELD_DATETIME_TYPE_TIME ?g_date_time_get_day_of_month (value) : 1, + priv->type != GTK_FORM_FIELD_DATETIME_TYPE_DATE ? g_date_time_get_hour (value): 0, + priv->type != GTK_FORM_FIELD_DATETIME_TYPE_DATE ? g_date_time_get_minute (value): 0, + priv->type != GTK_FORM_FIELD_DATETIME_TYPE_DATE ? g_date_time_get_seconds (value): 0.0); + } g_date_time_unref (value); }