[balsa] main: Use non-copying GVariant formats



commit b520762a7eb5e0de3d98d0601fee9890ebcc6f67
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Mon Feb 24 10:21:14 2020 -0500

    main: Use non-copying GVariant formats
    
    Since
    https://gitlab.gnome.org/GNOME/glib/-/commit/325f1e3eb54d3969d3be104481fa1097ffa37d7b,
    the GApplication docs recommend using non-copying variant formats.
    
    * src/main.c
      (balsa_check_open_mailboxes): use g_free(), not g_strfreev(),
        to free cmd_line_open_mailboxes, because it is now a shallow copy;
      (scan_mailboxes_idle_cb): ditto;
      (balsa_check_open_compose_window): ditto opt_attach_list;
      (parse_options): ditto remaining_args; use the non-copying formats.

 ChangeLog  | 31 +++++++++++++++++++++++--------
 src/main.c | 14 +++++++-------
 2 files changed, 30 insertions(+), 15 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 220e62d06..91e010f45 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2020-02-24  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       main: Use non-copying GVariant formats
+
+       Since
+       https://gitlab.gnome.org/GNOME/glib/-/commit/325f1e3eb54d3969d3be104481fa1097ffa37d7b,
+       the GApplication docs recommend using non-copying variant formats.
+
+       * src/main.c
+         (balsa_check_open_mailboxes): use g_free(), not g_strfreev(),
+           to free cmd_line_open_mailboxes, because it is now a shallow copy;
+         (scan_mailboxes_idle_cb): ditto;
+         (balsa_check_open_compose_window): ditto opt_attach_list;
+         (parse_options): ditto remaining_args; use the non-copying formats.
+
 2020-02-23  Peter Bloomfield  <pbloomfield bellsouth net>
 
        main: Parse command line arguments in the local instance
@@ -8,14 +23,14 @@
          (parse_options): use the GVariantDict instead of parsing the
            command-line arguments;
          (scan_mailboxes_idle_cb): coding style;
-       (balsa_handle_local_options_cb): new function for handling
-         command line options that do not need to be passed to the
-         primary instance (currently just "--version");
-       (balsa_command_line_cb):  use the GVariantDict instead of parsing
-         the command-line arguments;
-       (main): use g_application_add_main_option_entries() and connect
-         to the "handle-local-options" signal.
-       (handle_remote): coding style;
+         (balsa_handle_local_options_cb): new function for handling
+           command line options that do not need to be passed to the
+           primary instance (currently just "--version");
+         (balsa_command_line_cb):  use the GVariantDict instead of parsing
+           the command-line arguments;
+         (main): use g_application_add_main_option_entries() and connect
+           to the "handle-local-options" signal.
+         (handle_remote): coding style;
 
 2020-02-21  Peter Bloomfield  <pbloomfield bellsouth net>
 
diff --git a/src/main.c b/src/main.c
index b5070f6f8..58826a3d0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -224,7 +224,7 @@ balsa_check_open_mailboxes(void)
     gchar **urls;
 
     join = g_strjoinv(";", cmd_line_open_mailboxes);
-    g_strfreev(cmd_line_open_mailboxes);
+    g_free(cmd_line_open_mailboxes); /* It was a shallow copy. */
     cmd_line_open_mailboxes = NULL;
 
     urls = g_strsplit(join, ";", 20);
@@ -275,7 +275,7 @@ scan_mailboxes_idle_cb()
         gchar **p;
 
         join = g_strjoinv(";", cmd_line_open_mailboxes);
-        g_strfreev(cmd_line_open_mailboxes);
+        g_free(cmd_line_open_mailboxes); /* It was a shallow copy. */
         cmd_line_open_mailboxes = NULL;
 
         urls = g_strsplit(join, ";", 20);
@@ -455,7 +455,7 @@ balsa_check_open_compose_window(void)
         if (opt_attach_list != NULL) {
             for (attach = opt_attach_list; *attach; ++attach)
                 add_attachment(snd, *attach, FALSE, NULL);
-            g_strfreev(opt_attach_list);
+            g_free(opt_attach_list); /* It was a shallow copy. */
             opt_attach_list = NULL;
         }
 
@@ -660,13 +660,13 @@ parse_options(GApplicationCommandLine * cmdline)
     if (!g_variant_dict_lookup(dict, "compose", "&s", &opt_compose_email))
         opt_compose_email = NULL;
 
-    if (!g_variant_dict_lookup(dict, "attach", "^aay", &opt_attach_list))
+    if (!g_variant_dict_lookup(dict, "attach", "^a&ay", &opt_attach_list))
         opt_attach_list = NULL;
 
-    if (!g_variant_dict_lookup(dict, "open-mailbox", "^as", &cmd_line_open_mailboxes))
+    if (!g_variant_dict_lookup(dict, "open-mailbox", "^a&s", &cmd_line_open_mailboxes))
         cmd_line_open_mailboxes = NULL;
 
-    if (!g_variant_dict_lookup(dict, G_OPTION_REMAINING, "^aay", &remaining_args))
+    if (!g_variant_dict_lookup(dict, G_OPTION_REMAINING, "^a&ay", &remaining_args))
         remaining_args = NULL;
 
     if (remaining_args != NULL) {
@@ -677,7 +677,7 @@ parse_options(GApplicationCommandLine * cmdline)
             /* process remaining_args[i] here */
             /* we do nothing for now */
         }
-        g_strfreev(remaining_args);
+        g_free(remaining_args); /* It was a shallow copy. */
         remaining_args = NULL;
     }
 }


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