[Xfce4-commits] [apps/xfce4-screenshooter] 02/03: Revert "Fix crash in GValueArray handling (#11879)"

noreply at xfce.org noreply at xfce.org
Tue Jun 27 00:58:31 CEST 2017


This is an automated email from the git hooks/post-receive script.

a   n   d   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-screenshooter.

commit 3fb61ff16ffa05e47185e26389ca0105a9ef42b6
Author: Evangelos Foutras <evangelos at foutrelis.com>
Date:   Sun Jun 25 03:10:51 2017 +0300

    Revert "Fix crash in GValueArray handling (#11879)"
    
    This reverts commit 6de6b7e2faec6b4f349be1819450d4f97d624110.
---
 lib/screenshooter-imgur.c      | 11 ++++++-----
 lib/screenshooter-simple-job.c | 14 +++-----------
 2 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/lib/screenshooter-imgur.c b/lib/screenshooter-imgur.c
index 85a76da..c30503a 100644
--- a/lib/screenshooter-imgur.c
+++ b/lib/screenshooter-imgur.c
@@ -55,16 +55,17 @@ imgur_upload_job (ScreenshooterJob *job, GArray *param_values, GError **error)
   g_return_val_if_fail (SCREENSHOOTER_IS_JOB (job), FALSE);
   g_return_val_if_fail (param_values != NULL, FALSE);
   g_return_val_if_fail (param_values->len == 2, FALSE);
-  g_return_val_if_fail ((G_VALUE_HOLDS_STRING (g_array_index(param_values, GValue*, 0))), FALSE);
-  g_return_val_if_fail ((G_VALUE_HOLDS_STRING (g_array_index(param_values, GValue*, 1))), FALSE);
+  g_return_val_if_fail ((G_VALUE_HOLDS_STRING (&g_array_index(param_values, GValue, 0))), FALSE);
+  g_return_val_if_fail ((G_VALUE_HOLDS_STRING (&g_array_index(param_values, GValue, 1))), FALSE);
   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
   g_object_set_data (G_OBJECT (job), "jobtype", "imgur");
   if (exo_job_set_error_if_cancelled (EXO_JOB (job), error))
     return FALSE;
 
-  image_path = g_value_get_string (g_array_index (param_values, GValue*, 0));
-  title = g_value_get_string (g_array_index (param_values, GValue*, 1));
+
+  image_path = g_value_get_string (&g_array_index (param_values, GValue, 0));
+  title = g_value_get_string (&g_array_index (param_values, GValue, 1));
 
   session = soup_session_new ();
 #if DEBUG > 0
@@ -128,7 +129,7 @@ imgur_upload_job (ScreenshooterJob *job, GArray *param_values, GError **error)
   root_node = xmlDocGetRootElement(doc);
   for (child_node = root_node->children; child_node; child_node = child_node->next)
     if (xmlStrEqual(child_node->name, (const xmlChar *) "id"))
-       online_file_name = (gchar*)xmlNodeGetContent(child_node);
+       online_file_name = xmlNodeGetContent(child_node);
   TRACE("found picture id %s\n", online_file_name);
   xmlFreeDoc(doc);
   soup_buffer_free (buf);
diff --git a/lib/screenshooter-simple-job.c b/lib/screenshooter-simple-job.c
index 4b21bea..da06f4d 100644
--- a/lib/screenshooter-simple-job.c
+++ b/lib/screenshooter-simple-job.c
@@ -157,24 +157,20 @@ screenshooter_simple_job_launch (ScreenshooterSimpleJobFunc func,
   ScreenshooterSimpleJob *simple_job;
   va_list var_args;
   GValue value = { 0, };
-  GValue *copy;
   gchar *error_message;
   guint n;
-  GType type;
 
   /* allocate and initialize the simple job */
   simple_job = g_object_new (SCREENSHOOTER_TYPE_SIMPLE_JOB, NULL);
   simple_job->func = func;
-  simple_job->param_values = g_array_sized_new (FALSE, FALSE, sizeof(GValue*), n_param_values);
-  g_array_set_clear_func (simple_job->param_values, (GDestroyNotify) g_free);
+  simple_job->param_values = g_array_sized_new (FALSE, FALSE, sizeof(GValue), n_param_values);
 
   /* collect the parameters */
   va_start (var_args, n_param_values);
   for (n = 0; n < n_param_values; ++n)
     {
       /* initialize the value to hold the next parameter */
-      type = va_arg (var_args, GType);
-      g_value_init (&value, type);
+      g_value_init (&value, va_arg (var_args, GType));
 
       /* collect the value from the stack */
       G_VALUE_COLLECT (&value, var_args, 0, &error_message);
@@ -186,11 +182,7 @@ screenshooter_simple_job_launch (ScreenshooterSimpleJobFunc func,
           g_free (error_message);
         }
 
-      // GArray only takes references, so we allocate extra memory. this will be freed wenn the array is freed
-      copy = g_new0(GValue,1);
-      g_value_init(copy, type);
-      g_value_copy(&value,copy);
-      g_array_insert_val(simple_job->param_values,n,copy);
+      g_array_append_val(simple_job->param_values, value);
       g_value_unset (&value);
     }
   va_end (var_args);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list