]> saetta.ns0.it Git - libgtkform/commitdiff
Bugfix.
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Thu, 29 Sep 2011 11:36:43 +0000 (13:36 +0200)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Thu, 29 Sep 2011 11:36:43 +0000 (13:36 +0200)
libgtkform/fielddatetime.c

index bcb62a3f93beb14e9516f65b857546b9233d56c9..d92b2443b1d0207bdb8370b436d24a17496122d8 100644 (file)
@@ -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);
 }