mirror of https://github.com/GNOME/gimp.git
app, libgimp: add _gimp_gp_params_free() to gimpgpparams
which frees exactly what _gimp_value_array_to_gp_params() has allocated, honors its "full_copy" parameter, and plugs the last libgimp refactoring leaks I'm currently aware of.
This commit is contained in:
parent
8acff481a3
commit
bfe4a2f9dd
|
@ -624,8 +624,7 @@ gimp_plug_in_handle_proc_run (GimpPlugIn *plug_in,
|
|||
gimp_plug_in_close (plug_in, TRUE);
|
||||
}
|
||||
|
||||
/* FIXME leaking object arrays */
|
||||
g_free (proc_return.params);
|
||||
_gimp_gp_params_free (proc_return.params, proc_return.nparams, FALSE);
|
||||
}
|
||||
|
||||
gimp_value_array_unref (return_vals);
|
||||
|
|
|
@ -246,8 +246,7 @@ gimp_plug_in_manager_call_run (GimpPlugInManager *manager,
|
|||
g_free (config.display_name);
|
||||
g_free (config.icon_theme_dir);
|
||||
|
||||
/* FIXME leaking object arrays */
|
||||
g_free (proc_run.params);
|
||||
_gimp_gp_params_free (proc_run.params, proc_run.nparams, FALSE);
|
||||
|
||||
g_object_unref (plug_in);
|
||||
|
||||
|
@ -261,8 +260,7 @@ gimp_plug_in_manager_call_run (GimpPlugInManager *manager,
|
|||
g_free (config.display_name);
|
||||
g_free (config.icon_theme_dir);
|
||||
|
||||
/* FIXME leaking object arrays */
|
||||
g_free (proc_run.params);
|
||||
_gimp_gp_params_free (proc_run.params, proc_run.nparams, FALSE);
|
||||
|
||||
/* If this is an extension,
|
||||
* wait for an installation-confirmation message
|
||||
|
@ -341,8 +339,8 @@ gimp_plug_in_manager_call_run_temp (GimpPlugInManager *manager,
|
|||
_("Failed to run plug-in \"%s\""),
|
||||
name);
|
||||
|
||||
/* FIXME leaking object arrays */
|
||||
g_free (proc_run.params);
|
||||
|
||||
_gimp_gp_params_free (proc_run.params, proc_run.nparams, FALSE);
|
||||
gimp_plug_in_proc_frame_pop (plug_in);
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (GIMP_PROCEDURE (procedure),
|
||||
|
@ -354,8 +352,7 @@ gimp_plug_in_manager_call_run_temp (GimpPlugInManager *manager,
|
|||
|
||||
gimp_allow_set_foreground_window (plug_in);
|
||||
|
||||
/* FIXME leaking object arrays */
|
||||
g_free (proc_run.params);
|
||||
_gimp_gp_params_free (proc_run.params, proc_run.nparams, FALSE);
|
||||
|
||||
g_object_ref (plug_in);
|
||||
gimp_plug_in_proc_frame_ref (proc_frame);
|
||||
|
|
|
@ -835,7 +835,7 @@ gimp_value_to_gp_param (const GValue *value,
|
|||
|
||||
param->data.d_id_array.size = array->length;
|
||||
|
||||
/* FIXME LEAK */
|
||||
/* must be free'd also for full_copy == FALSE */
|
||||
param->data.d_id_array.data = g_new (gint32, array->length);
|
||||
|
||||
for (i = 0; i < array->length; i++)
|
||||
|
@ -926,3 +926,71 @@ _gimp_value_array_to_gp_params (const GimpValueArray *args,
|
|||
|
||||
return params;
|
||||
}
|
||||
|
||||
void
|
||||
_gimp_gp_params_free (GPParam *params,
|
||||
gint n_params,
|
||||
gboolean full_copy)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < n_params; i++)
|
||||
{
|
||||
if (full_copy)
|
||||
g_free (params[i].type_name);
|
||||
|
||||
switch (params[i].param_type)
|
||||
{
|
||||
case GP_PARAM_TYPE_INT:
|
||||
case GP_PARAM_TYPE_FLOAT:
|
||||
break;
|
||||
|
||||
case GP_PARAM_TYPE_STRING:
|
||||
if (full_copy)
|
||||
g_free (params[i].data.d_string);
|
||||
break;
|
||||
|
||||
case GP_PARAM_TYPE_COLOR:
|
||||
break;
|
||||
|
||||
case GP_PARAM_TYPE_ARRAY:
|
||||
if (full_copy)
|
||||
g_free (params[i].data.d_array.data);
|
||||
break;
|
||||
|
||||
case GP_PARAM_TYPE_STRING_ARRAY:
|
||||
if (full_copy &&
|
||||
params[i].data.d_string_array.size > 0 &&
|
||||
params[i].data.d_string_array.data)
|
||||
{
|
||||
gint j;
|
||||
|
||||
for (j = 0; j < params[i].data.d_string_array.size; j++)
|
||||
g_free (params[i].data.d_string_array.data[j]);
|
||||
|
||||
g_free (params[i].data.d_string_array.data);
|
||||
}
|
||||
break;
|
||||
|
||||
case GP_PARAM_TYPE_ID_ARRAY:
|
||||
if (full_copy)
|
||||
g_free (params[i].data.d_id_array.type_name);
|
||||
|
||||
/* always free the array */
|
||||
g_free (params[i].data.d_id_array.data);
|
||||
break;
|
||||
|
||||
case GP_PARAM_TYPE_PARASITE:
|
||||
if (full_copy)
|
||||
g_free (params[i].data.d_parasite.name);
|
||||
if (params[i].data.d_parasite.data)
|
||||
g_free (params[i].data.d_parasite.data);
|
||||
break;
|
||||
|
||||
case GP_PARAM_TYPE_PARAM_DEF:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_free (params);
|
||||
}
|
||||
|
|
|
@ -37,6 +37,9 @@ GimpValueArray * _gimp_gp_params_to_value_array (gpointer gimp,
|
|||
gboolean return_values);
|
||||
GPParam * _gimp_value_array_to_gp_params (const GimpValueArray *args,
|
||||
gboolean full_copy);
|
||||
void _gimp_gp_params_free (GPParam *params,
|
||||
gint n_params,
|
||||
gboolean full_copy);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -302,8 +302,7 @@ gimp_pdb_run_procedure_array (GimpPDB *pdb,
|
|||
&proc_run, pdb->priv->plug_in))
|
||||
gimp_quit ();
|
||||
|
||||
/* FIXME leaking object arrays */
|
||||
g_free (proc_run.params);
|
||||
_gimp_gp_params_free (proc_run.params, proc_run.nparams, FALSE);
|
||||
|
||||
_gimp_plug_in_read_expect_msg (pdb->priv->plug_in, &msg, GP_PROC_RETURN);
|
||||
|
||||
|
|
|
@ -1127,8 +1127,7 @@ gimp_plug_in_proc_run (GimpPlugIn *plug_in,
|
|||
&proc_return, plug_in))
|
||||
gimp_quit ();
|
||||
|
||||
/* FIXME leaking object arrays */
|
||||
g_free (proc_return.params);
|
||||
_gimp_gp_params_free (proc_return.params, proc_return.nparams, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1151,8 +1150,7 @@ gimp_plug_in_temp_proc_run (GimpPlugIn *plug_in,
|
|||
&proc_return, plug_in))
|
||||
gimp_quit ();
|
||||
|
||||
/* FIXME leaking object arrays */
|
||||
g_free (proc_return.params);
|
||||
_gimp_gp_params_free (proc_return.params, proc_return.nparams, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue