mirror of https://github.com/GNOME/gimp.git
don't memset(0) the array of return values if the procedure didn't
2006-03-30 Michael Natterer <mitch@gimp.org> * app/pdb/procedural_db.c (procedural_db_execute_proc): don't memset(0) the array of return values if the procedure didn't succeed. GValues don't like to be treated like that and I don't understand what the memsetting is good for. It just looks like a very bad hack. * app/file/file-open.c: additionally, don't access return_vals[>0] unless the procedure returned successfully. * app/core/gimppdbprogress.c * app/widgets/gimppdbdialog.c: procedural_db_run_proc() always returns non-NULL, no need to check for it.
This commit is contained in:
parent
eed050e454
commit
4b24ca376f
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2006-03-30 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/pdb/procedural_db.c (procedural_db_execute_proc): don't
|
||||
memset(0) the array of return values if the procedure didn't
|
||||
succeed. GValues don't like to be treated like that and I don't
|
||||
understand what the memsetting is good for. It just looks like a
|
||||
very bad hack.
|
||||
|
||||
* app/file/file-open.c: additionally, don't access return_vals[>0]
|
||||
unless the procedure returned successfully.
|
||||
|
||||
* app/core/gimppdbprogress.c
|
||||
* app/widgets/gimppdbdialog.c: procedural_db_run_proc() always
|
||||
returns non-NULL, no need to check for it.
|
||||
|
||||
2006-03-30 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* tools/pdbgen/pdb/procedural_db.pdb: got rid of one more (the
|
||||
|
|
|
@ -259,8 +259,7 @@ gimp_pdb_progress_run_callback (GimpPdbProgress *progress,
|
|||
GIMP_PDB_FLOAT, value,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (! return_vals ||
|
||||
g_value_get_enum (&return_vals[0].value) != GIMP_PDB_SUCCESS)
|
||||
if (g_value_get_enum (&return_vals[0].value) != GIMP_PDB_SUCCESS)
|
||||
{
|
||||
g_message (_("Unable to run %s callback. "
|
||||
"The corresponding plug-in may have crashed."),
|
||||
|
|
|
@ -89,7 +89,7 @@ file_open_image (Gimp *gimp,
|
|||
Argument *return_vals;
|
||||
gint n_return_vals;
|
||||
gchar *filename;
|
||||
GimpImage *image;
|
||||
GimpImage *image = NULL;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
||||
|
@ -151,20 +151,17 @@ file_open_image (Gimp *gimp,
|
|||
g_free (filename);
|
||||
|
||||
*status = g_value_get_enum (&return_vals[0].value);
|
||||
image = gimp_value_get_image (&return_vals[1].value, gimp);
|
||||
|
||||
procedural_db_destroy_args (return_vals, n_return_vals, TRUE);
|
||||
|
||||
if (*status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
image = gimp_value_get_image (&return_vals[1].value, gimp);
|
||||
|
||||
if (image)
|
||||
{
|
||||
file_open_sanitize_image (image);
|
||||
|
||||
if (mime_type)
|
||||
*mime_type = file_proc->mime_type;
|
||||
|
||||
return image;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -180,7 +177,9 @@ file_open_image (Gimp *gimp,
|
|||
_("Plug-In could not open image"));
|
||||
}
|
||||
|
||||
return NULL;
|
||||
procedural_db_destroy_args (return_vals, n_return_vals, TRUE);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
/* Attempts to load a thumbnail by using a registered thumbnail loader. */
|
||||
|
@ -220,7 +219,7 @@ file_open_thumbnail (Gimp *gimp,
|
|||
Argument *return_vals;
|
||||
gint n_return_vals;
|
||||
gchar *filename;
|
||||
GimpImage *image;
|
||||
GimpImage *image = NULL;
|
||||
|
||||
filename = file_utils_filename_from_uri (uri);
|
||||
|
||||
|
@ -237,27 +236,31 @@ file_open_thumbnail (Gimp *gimp,
|
|||
g_free (filename);
|
||||
|
||||
status = g_value_get_enum (&return_vals[0].value);
|
||||
image = gimp_value_get_image (&return_vals[1].value, gimp);
|
||||
|
||||
if (proc->num_values >= 3)
|
||||
if (status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
*image_width = MAX (0, g_value_get_int (&return_vals[2].value));
|
||||
*image_height = MAX (0, g_value_get_int (&return_vals[3].value));
|
||||
image = gimp_value_get_image (&return_vals[1].value, gimp);
|
||||
|
||||
if (n_return_vals >= 3)
|
||||
{
|
||||
*image_width = MAX (0, g_value_get_int (&return_vals[2].value));
|
||||
*image_height = MAX (0, g_value_get_int (&return_vals[3].value));
|
||||
}
|
||||
|
||||
if (image)
|
||||
{
|
||||
file_open_sanitize_image (image);
|
||||
|
||||
*mime_type = file_proc->mime_type;
|
||||
|
||||
g_printerr ("opened thumbnail at %d x %d\n",
|
||||
image->width, image->height);
|
||||
}
|
||||
}
|
||||
|
||||
procedural_db_destroy_args (return_vals, n_return_vals, TRUE);
|
||||
|
||||
if (status == GIMP_PDB_SUCCESS && image != NULL)
|
||||
{
|
||||
file_open_sanitize_image (image);
|
||||
|
||||
*mime_type = file_proc->mime_type;
|
||||
|
||||
g_printerr ("opened thumbnail at %d x %d\n",
|
||||
image->width, image->height);
|
||||
|
||||
return image;
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -294,13 +297,13 @@ file_open_with_proc_and_display (Gimp *gimp,
|
|||
g_return_val_if_fail (status != NULL, NULL);
|
||||
|
||||
image = file_open_image (gimp, context, progress,
|
||||
uri,
|
||||
entered_filename,
|
||||
file_proc,
|
||||
GIMP_RUN_INTERACTIVE,
|
||||
status,
|
||||
&mime_type,
|
||||
error);
|
||||
uri,
|
||||
entered_filename,
|
||||
file_proc,
|
||||
GIMP_RUN_INTERACTIVE,
|
||||
status,
|
||||
&mime_type,
|
||||
error);
|
||||
|
||||
if (image)
|
||||
{
|
||||
|
|
|
@ -342,13 +342,6 @@ procedural_db_execute_proc (Gimp *gimp,
|
|||
return return_vals;
|
||||
}
|
||||
|
||||
if (g_value_get_enum (&return_vals[0].value) != GIMP_PDB_SUCCESS &&
|
||||
g_value_get_enum (&return_vals[0].value) != GIMP_PDB_PASS_THROUGH &&
|
||||
procedure->num_values > 0)
|
||||
{
|
||||
memset (&return_vals[1], 0, sizeof (Argument) * procedure->num_values);
|
||||
}
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
|
|
|
@ -342,13 +342,6 @@ procedural_db_execute_proc (Gimp *gimp,
|
|||
return return_vals;
|
||||
}
|
||||
|
||||
if (g_value_get_enum (&return_vals[0].value) != GIMP_PDB_SUCCESS &&
|
||||
g_value_get_enum (&return_vals[0].value) != GIMP_PDB_PASS_THROUGH &&
|
||||
procedure->num_values > 0)
|
||||
{
|
||||
memset (&return_vals[1], 0, sizeof (Argument) * procedure->num_values);
|
||||
}
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
|
|
|
@ -342,13 +342,6 @@ procedural_db_execute_proc (Gimp *gimp,
|
|||
return return_vals;
|
||||
}
|
||||
|
||||
if (g_value_get_enum (&return_vals[0].value) != GIMP_PDB_SUCCESS &&
|
||||
g_value_get_enum (&return_vals[0].value) != GIMP_PDB_PASS_THROUGH &&
|
||||
procedure->num_values > 0)
|
||||
{
|
||||
memset (&return_vals[1], 0, sizeof (Argument) * procedure->num_values);
|
||||
}
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
|
|
|
@ -342,13 +342,6 @@ procedural_db_execute_proc (Gimp *gimp,
|
|||
return return_vals;
|
||||
}
|
||||
|
||||
if (g_value_get_enum (&return_vals[0].value) != GIMP_PDB_SUCCESS &&
|
||||
g_value_get_enum (&return_vals[0].value) != GIMP_PDB_PASS_THROUGH &&
|
||||
procedure->num_values > 0)
|
||||
{
|
||||
memset (&return_vals[1], 0, sizeof (Argument) * procedure->num_values);
|
||||
}
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
|
|
|
@ -314,16 +314,14 @@ gimp_pdb_dialog_run_callback (GimpPdbDialog *dialog,
|
|||
return_vals = klass->run_callback (dialog, object, closing,
|
||||
&n_return_vals);
|
||||
|
||||
if (! return_vals ||
|
||||
g_value_get_enum (&return_vals[0].value) != GIMP_PDB_SUCCESS)
|
||||
if (g_value_get_enum (&return_vals[0].value) != GIMP_PDB_SUCCESS)
|
||||
{
|
||||
g_message (_("Unable to run %s callback. "
|
||||
"The corresponding plug-in may have crashed."),
|
||||
g_type_name (G_TYPE_FROM_INSTANCE (dialog)));
|
||||
}
|
||||
|
||||
if (return_vals)
|
||||
procedural_db_destroy_args (return_vals, n_return_vals, TRUE);
|
||||
procedural_db_destroy_args (return_vals, n_return_vals, TRUE);
|
||||
}
|
||||
|
||||
dialog->callback_busy = FALSE;
|
||||
|
|
Loading…
Reference in New Issue