[goffice] GogObject: accept translated boolean properties.



commit 80d8a9407e0c310e02e109617d719615b5bfce11
Author: Morten Welinder <terra gnome org>
Date:   Wed Jul 15 19:41:07 2020 -0400

    GogObject: accept translated boolean properties.

 ChangeLog                      |  9 +++++++++
 NEWS                           |  1 +
 goffice/graph/gog-object-xml.c | 21 ++++++++++++++++++++-
 goffice/utils/go-file.c        |  2 ++
 4 files changed, 32 insertions(+), 1 deletion(-)
---
diff --git a/ChangeLog b/ChangeLog
index 69d1d9e9..060d0bc7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2020-07-15  Morten Welinder  <terra gnome org>
+
+       * goffice/graph/gog-object-xml.c (gogo_prop_end): Handle
+       translated booleans since we've managed to save some files that
+       way.
+
+       * goffice/utils/go-file.c (go_file_get_owner_name)
+       (go_file_get_group_name): Plug leak.
+
 2020-06-26  Morten Welinder  <terra gnome org>
 
        * configure.ac (xrender): Stop checking for xrender.  We haven't
diff --git a/NEWS b/NEWS
index c9a0feb6..89dfa41d 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ Morten:
        * Introspection fixes.
        * Speed up GocGroup for large number of children.  [Gnumeric #465]
        * Stop checking for Xrender.
+       * Plug leaks.
 
 --------------------------------------------------------------------------
 goffice 0.10.47:
diff --git a/goffice/graph/gog-object-xml.c b/goffice/graph/gog-object-xml.c
index 0f16f819..c941b49f 100644
--- a/goffice/graph/gog-object-xml.c
+++ b/goffice/graph/gog-object-xml.c
@@ -21,6 +21,7 @@
 
 #include <goffice/goffice-config.h>
 #include <goffice/goffice.h>
+#include <glib/gi18n-lib.h>
 
 #include <string.h>
 #include <stdlib.h>
@@ -417,13 +418,31 @@ gogo_prop_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *unknown)
                g_value_set_object (&val, G_OBJECT (obj));
                g_object_unref (obj);
        } else {
+               gboolean ok = FALSE;
                if (content == NULL && prop_ftype != G_TYPE_BOOLEAN) {
                        g_warning ("could not convert NULL to type `%s' for property `%s'",
                                   g_type_name (prop_type), state->prop_spec->name);
                        return;
                }
 
-               if (!gsf_xml_gvalue_from_str (&val, prop_type, content)) {
+               if (prop_type == G_TYPE_BOOLEAN) {
+                       // We've managed to save some files with translated
+                       // booleans.  Try to recover.
+                       if (g_str_equal (content, _("TRUE"))) {
+                               g_value_init (&val, prop_type);
+                               g_value_set_boolean (&val, TRUE);
+                               ok = TRUE;
+                       } else if (g_str_equal (content, _("FALSE"))) {
+                               g_value_init (&val, prop_type);
+                               g_value_set_boolean (&val, FALSE);
+                               ok = TRUE;
+                       }
+               }
+
+               if (!ok)
+                       ok = gsf_xml_gvalue_from_str (&val, prop_type, content);
+
+               if (!ok) {
                        g_warning ("could not convert string to type `%s' for property `%s'",
                                   g_type_name (prop_type), state->prop_spec->name);
                        return;
diff --git a/goffice/utils/go-file.c b/goffice/utils/go-file.c
index e5b538f4..1a08dfb9 100644
--- a/goffice/utils/go-file.c
+++ b/goffice/utils/go-file.c
@@ -721,6 +721,7 @@ go_file_get_owner_name (char const *uri)
        name = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_OWNER_USER);
        (void) go_guess_encoding (name, strlen (name),
                                  NULL, &nameutf8, NULL);
+       g_object_unref (info);
        return (nameutf8 ? g_string_free (nameutf8, FALSE) : NULL);
 }
 
@@ -747,6 +748,7 @@ go_file_get_group_name (char const *uri)
        name = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_OWNER_GROUP);
        (void) go_guess_encoding (name, strlen (name),
                                  NULL, &nameutf8, NULL);
+       g_object_unref (info);
        return (nameutf8 ? g_string_free (nameutf8, FALSE) : NULL);
 }
 


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