From: Andrea Zagli Date: Fri, 13 Mar 2020 14:25:45 +0000 (+0100) Subject: Seams that g_ptr_array_copy doesn't work... X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=e2cb22fa28d98c6ff0b93c63198622aaf358238b;p=zakform%2Flibzakform Seams that g_ptr_array_copy doesn't work... --- diff --git a/src/formelement.c b/src/formelement.c index 857ed31..c40a1be 100644 --- a/src/formelement.c +++ b/src/formelement.c @@ -1386,21 +1386,26 @@ zak_form_element_is_valid (ZakFormElement *element) return ret; } -static gpointer -copy_ar_func (gconstpointer src, gpointer data) +static GPtrArray +*copy_ar_func (GPtrArray *src) { GPtrArray *ret; GPtrArray *ar_src; guint i; + if (src == NULL) + { + return NULL; + } + ar_src = (GPtrArray *)src; ret = g_ptr_array_new (); for (i = 0; i < ar_src->len; i++) { - g_ptr_array_add (ret, g_strdup ((gchar *)g_ptr_array_index (ar_src, i))); + g_ptr_array_add (ret, (gpointer)g_strdup ((gchar *)g_ptr_array_index (ar_src, i))); } return ret; @@ -1416,7 +1421,14 @@ GPtrArray { ZakFormElementPrivate *priv = zak_form_element_get_instance_private (element); - return g_ptr_array_copy (priv->pa_messages, copy_ar_func, NULL); + if (priv->pa_messages == NULL) + { + return NULL; + } + else + { + return copy_ar_func (priv->pa_messages); + } } /** @@ -1434,7 +1446,7 @@ zak_form_element_set_messages (ZakFormElement *element, GPtrArray *messages) if (priv->pa_messages != NULL) { g_ptr_array_free (priv->pa_messages, TRUE); - priv->pa_messages = g_ptr_array_copy (messages, copy_ar_func, NULL); + priv->pa_messages = copy_ar_func (messages); } }