[goffice] Avoid serializing empty graph data. [#46]



commit fcac4d610e0cc87d5c0de1f501d7d5afd2bf6e30
Author: Jean Brefort <jean brefort normalesup org>
Date:   Thu May 14 09:50:25 2020 +0200

    Avoid serializing empty graph data. [#46]

 ChangeLog                      |  9 +++++++++
 NEWS                           |  3 +++
 goffice/data/go-data.c         |  2 ++
 goffice/graph/gog-object-xml.c |  5 ++++-
 goffice/gtk/go-font-sel.c      | 46 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 64 insertions(+), 1 deletion(-)
---
diff --git a/ChangeLog b/ChangeLog
index 09ee3ec5..905479ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2020-05-14  Jean Brefort  <jean brefort normalesup org>
+
+       * goffice/data/go-data.c (go_data_unserialize): don't load an invalid
+       empty string. [#46]
+       * goffice/graph/gog-object-xml.c (gog_dataset_sax_save): don't save any
+       void data. [#46]
+       * goffice/gtk/go-font-sel.c (gfs_get_property), (gfs_set_property),
+       (gfs_class_init): fix criticals with Gtk+ >= 3.24.
+
 2020-05-09  Morten Welinder <terra gnome org>
 
        * configure.ac: Post-release bump.
diff --git a/NEWS b/NEWS
index c97fd6cf..74f5d36f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
 goffice 0.10.48:
 
+Jean:
+       * Avoid serializing empty graph data. [#46]
+
 --------------------------------------------------------------------------
 goffice 0.10.47:
 
diff --git a/goffice/data/go-data.c b/goffice/data/go-data.c
index 06726835..cb776028 100644
--- a/goffice/data/go-data.c
+++ b/goffice/data/go-data.c
@@ -268,6 +268,8 @@ go_data_unserialize (GOData *dat, char const *str, gpointer user)
 {
        GODataClass const *klass = GO_DATA_GET_CLASS (dat);
        g_return_val_if_fail (klass != NULL, FALSE);
+       /* an empty string is not valid, see #46 */
+       g_return_val_if_fail (str && *str, FALSE);
        return (*klass->unserialize) (dat, str, user);
 }
 
diff --git a/goffice/graph/gog-object-xml.c b/goffice/graph/gog-object-xml.c
index a2274d5d..0f16f819 100644
--- a/goffice/graph/gog-object-xml.c
+++ b/goffice/graph/gog-object-xml.c
@@ -168,11 +168,14 @@ gog_dataset_sax_save (GogDataset const *set, GsfXMLOut *output, gpointer user)
                if (dat == NULL)
                        continue;
 
+               tmp = go_data_serialize (dat, user);
+               /* only save the data if there is some valid content, see #46 */
+               if (tmp == NULL || *tmp == 0)
+                       continue;
                gsf_xml_out_start_element (output, "dimension");
                gsf_xml_out_add_int (output, "id", i);
                gsf_xml_out_add_cstr (output, "type",
                        G_OBJECT_TYPE_NAME (dat));
-               tmp = go_data_serialize (dat, user);
                gsf_xml_out_add_cstr (output, NULL, tmp);
                g_free (tmp);
                gsf_xml_out_end_element (output); /* </dimension> */
diff --git a/goffice/gtk/go-font-sel.c b/goffice/gtk/go-font-sel.c
index fa315cb5..b11480c7 100644
--- a/goffice/gtk/go-font-sel.c
+++ b/goffice/gtk/go-font-sel.c
@@ -99,6 +99,11 @@ enum {
        GFS_GTK_FONT_CHOOSER_PROP_FONT_DESC,
        GFS_GTK_FONT_CHOOSER_PROP_PREVIEW_TEXT,
        GFS_GTK_FONT_CHOOSER_PROP_SHOW_PREVIEW_ENTRY,
+#if GTK_CHECK_VERSION(3,24,0)
+       GFS_GTK_FONT_CHOOSER_PROP_LEVEL,
+       GFS_GTK_FONT_CHOOSER_PROP_LANGUAGE,
+       GFS_GTK_FONT_CHOOSER_PROP_FONT_FEATURES,
+#endif
        GFS_GTK_FONT_CHOOSER_PROP_LAST
 };
 
@@ -1114,6 +1119,22 @@ gfs_get_property (GObject         *object,
                g_value_set_boolean (value, gfs->show_preview_entry);
                break;
 
+#if GTK_CHECK_VERSION(3,24,0)
+       case GFS_GTK_FONT_CHOOSER_PROP_LEVEL:
+               g_value_set_int (value, GTK_FONT_CHOOSER_LEVEL_FAMILY |
+                                             GTK_FONT_CHOOSER_LEVEL_STYLE |
+                                             GTK_FONT_CHOOSER_LEVEL_SIZE);
+               break;
+
+       case GFS_GTK_FONT_CHOOSER_PROP_LANGUAGE:
+               g_value_set_string (value, "");
+               break;
+
+       case GFS_GTK_FONT_CHOOSER_PROP_FONT_FEATURES:
+               g_value_set_string (value, "");
+               break;
+#endif
+
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                break;
@@ -1189,6 +1210,20 @@ gfs_set_property (GObject         *object,
                update_preview (gfs);
                break;
 
+#if GTK_CHECK_VERSION(3,24,0)
+       case GFS_GTK_FONT_CHOOSER_PROP_LEVEL:
+               /* not supported, just to avoid criticals */
+
+               break;
+       case GFS_GTK_FONT_CHOOSER_PROP_LANGUAGE:
+               /* not supported, just to avoid criticals */
+
+               break;
+       case GFS_GTK_FONT_CHOOSER_PROP_FONT_FEATURES:
+               /* not supported, just to avoid criticals */
+               break;
+#endif
+
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                break;
@@ -1305,6 +1340,17 @@ gfs_class_init (GObjectClass *klass)
        g_object_class_override_property (klass,
                                          GFS_GTK_FONT_CHOOSER_PROP_SHOW_PREVIEW_ENTRY,
                                          "show-preview-entry");
+#if GTK_CHECK_VERSION(3,24,0)
+       g_object_class_override_property (klass,
+                                         GFS_GTK_FONT_CHOOSER_PROP_LEVEL,
+                                         "level");
+       g_object_class_override_property (klass,
+                                         GFS_GTK_FONT_CHOOSER_PROP_LANGUAGE,
+                                         "language");
+       g_object_class_override_property (klass,
+                                         GFS_GTK_FONT_CHOOSER_PROP_FONT_FEATURES,
+                                         "font-features");
+#endif
 
        gfs_signals[FONT_CHANGED] =
                g_signal_new (


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