mirror of https://github.com/GNOME/gimp.git
Next step towards fixing bug #344818:
2008-08-16 Sven Neumann <sven@gimp.org> Next step towards fixing bug #344818: * libgimp/gimp.[ch]: keep the last error status and error message in libgimp. Added new functon gimp_pdb_get_error() that allows to retrieve it. * libgimp/gimp.def: updated. * plug-ins/pygimp/gimpmodule.c (pygimp_vectors_import_from_file) (pygimp_vectors_import_from_string): use the new function to get a more useful error message. svn path=/trunk/; revision=26602
This commit is contained in:
parent
c4f3f05df4
commit
2fcef8b03e
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2008-08-16 Sven Neumann <sven@gimp.org>
|
||||
|
||||
Next step towards fixing bug #344818:
|
||||
|
||||
* libgimp/gimp.[ch]: keep the last error status and error message
|
||||
in libgimp. Added new functon gimp_pdb_get_error() that allows to
|
||||
retrieve it.
|
||||
|
||||
* libgimp/gimp.def: updated.
|
||||
|
||||
* plug-ins/pygimp/gimpmodule.c (pygimp_vectors_import_from_file)
|
||||
(pygimp_vectors_import_from_string): use the new function to get
|
||||
a more useful error message.
|
||||
|
||||
2008-08-16 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/plug-in/gimpplugin-message.c (gimp_plug_in_handle_proc_run):
|
||||
|
|
103
libgimp/gimp.c
103
libgimp/gimp.c
|
@ -90,7 +90,6 @@
|
|||
# define USE_WIN32_SHM 1
|
||||
#endif
|
||||
|
||||
#include <libintl.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include "libgimpbase/gimpbasetypes.h"
|
||||
|
@ -104,6 +103,8 @@
|
|||
#include "gimp.h"
|
||||
#include "gimpunitcache.h"
|
||||
|
||||
#include "libgimp-intl.h"
|
||||
|
||||
|
||||
#define TILE_MAP_SIZE (_tile_width * _tile_height * 4)
|
||||
|
||||
|
@ -156,6 +157,9 @@ static gboolean gimp_extension_read (GIOChannel *channel,
|
|||
GIOCondition condition,
|
||||
gpointer data);
|
||||
|
||||
static void gimp_set_pdb_error (const GimpParam *return_vals,
|
||||
gint n_return_vals);
|
||||
|
||||
|
||||
static GIOChannel *_readchannel = NULL;
|
||||
GIOChannel *_writechannel = NULL;
|
||||
|
@ -203,10 +207,13 @@ static const GDebugKey gimp_debug_keys[] =
|
|||
{ "on", GIMP_DEBUG_DEFAULT }
|
||||
};
|
||||
|
||||
|
||||
static GimpPlugInInfo PLUG_IN_INFO;
|
||||
|
||||
|
||||
static GimpPDBStatusType pdb_error_status = GIMP_PDB_SUCCESS;
|
||||
static gchar *pdb_error_message = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* gimp_main:
|
||||
* @info: the PLUG_IN_INFO structure
|
||||
|
@ -964,22 +971,10 @@ gimp_run_procedure2 (const gchar *name,
|
|||
proc_return->nparams = 0;
|
||||
proc_return->params = NULL;
|
||||
|
||||
switch (return_vals[0].data.d_status)
|
||||
{
|
||||
case GIMP_PDB_EXECUTION_ERROR:
|
||||
break;
|
||||
|
||||
case GIMP_PDB_CALLING_ERROR:
|
||||
g_printerr ("a calling error occurred while trying to run: \"%s\"\n",
|
||||
name);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
gimp_wire_destroy (&msg);
|
||||
|
||||
gimp_set_pdb_error (return_vals, *n_return_vals);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
|
@ -1018,6 +1013,49 @@ gimp_destroy_paramdefs (GimpParamDef *paramdefs,
|
|||
g_free (paramdefs);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_get_pdb_error:
|
||||
*
|
||||
* Retrieves the error message from the last procedure call.
|
||||
*
|
||||
* If a procedure call fails, then it might pass an error message with
|
||||
* the return values. Plug-ins that are using the libgimp C wrappers
|
||||
* don't access the procedure return values directly. Thus ligimp
|
||||
* stores the error message and makes it available with this
|
||||
* function. A successful procedure call unsets the error message again.
|
||||
*
|
||||
* The returned string is owned by libgimp and must not be freed or
|
||||
* modified.
|
||||
*
|
||||
* Return value: the error message
|
||||
*
|
||||
* Since: GIMP 2.6
|
||||
**/
|
||||
const gchar *
|
||||
gimp_get_pdb_error (void)
|
||||
{
|
||||
if (pdb_error_message && strlen (pdb_error_message))
|
||||
return pdb_error_message;
|
||||
|
||||
switch (pdb_error_status)
|
||||
{
|
||||
case GIMP_PDB_SUCCESS:
|
||||
return _("success");
|
||||
|
||||
case GIMP_PDB_EXECUTION_ERROR:
|
||||
return _("execution error");
|
||||
|
||||
case GIMP_PDB_CALLING_ERROR:
|
||||
return _("calling error");
|
||||
|
||||
case GIMP_PDB_CANCEL:
|
||||
return _("cancelled");
|
||||
|
||||
default:
|
||||
return "invalid return status";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_tile_width:
|
||||
*
|
||||
|
@ -1229,7 +1267,7 @@ gimp_default_display (void)
|
|||
const gchar *
|
||||
gimp_wm_class (void)
|
||||
{
|
||||
return (const gchar *) _wm_class;
|
||||
return _wm_class;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1244,7 +1282,7 @@ gimp_wm_class (void)
|
|||
const gchar *
|
||||
gimp_display_name (void)
|
||||
{
|
||||
return (const gchar *) _display_name;
|
||||
return _display_name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1953,3 +1991,32 @@ gimp_extension_read (GIOChannel *channel,
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_set_pdb_error (const GimpParam *return_vals,
|
||||
gint n_return_vals)
|
||||
{
|
||||
if (pdb_error_message)
|
||||
{
|
||||
g_free (pdb_error_message);
|
||||
pdb_error_message = NULL;
|
||||
}
|
||||
|
||||
pdb_error_status = return_vals[0].data.d_status;
|
||||
|
||||
switch (pdb_error_status)
|
||||
{
|
||||
case GIMP_PDB_SUCCESS:
|
||||
case GIMP_PDB_PASS_THROUGH:
|
||||
break;
|
||||
|
||||
case GIMP_PDB_EXECUTION_ERROR:
|
||||
case GIMP_PDB_CALLING_ERROR:
|
||||
case GIMP_PDB_CANCEL:
|
||||
if (n_return_vals > 1 && return_vals[1].type == GIMP_PDB_STRING)
|
||||
{
|
||||
pdb_error_message = g_strdup (return_vals[1].data.d_string);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -236,6 +236,7 @@ EXPORTS
|
|||
gimp_get_module_load_inhibit
|
||||
gimp_get_monitor_resolution
|
||||
gimp_get_path_by_tattoo
|
||||
gimp_get_pdb_error
|
||||
gimp_get_progname
|
||||
gimp_get_theme_dir
|
||||
gimp_getpid
|
||||
|
|
|
@ -307,6 +307,10 @@ void gimp_destroy_params (GimpParam *params,
|
|||
void gimp_destroy_paramdefs (GimpParamDef *paramdefs,
|
||||
gint n_params);
|
||||
|
||||
/* Retrieve the error message for the last procedure call.
|
||||
*/
|
||||
const gchar * gimp_get_pdb_error (void);
|
||||
|
||||
|
||||
/* Return various constants given by the GIMP core at plug-in config time.
|
||||
*/
|
||||
|
|
|
@ -1583,7 +1583,8 @@ pygimp_vectors_import_from_file(PyObject *self, PyObject *args, PyObject *kwargs
|
|||
}
|
||||
|
||||
if (!success) {
|
||||
PyErr_SetString(pygimp_error, "Vectors import failed");
|
||||
PyErr_Format(pygimp_error,
|
||||
"Vectors import failed: %s", gimp_get_pdb_error());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1614,7 +1615,8 @@ pygimp_vectors_import_from_string(PyObject *self, PyObject *args, PyObject *kwar
|
|||
&num_vectors, &vectors);
|
||||
|
||||
if (!success) {
|
||||
PyErr_SetString(pygimp_error, "Vectors import failed");
|
||||
PyErr_Format(pygimp_error,
|
||||
"Vectors import failed: %s", gimp_get_pdb_error());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2008-08-16 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* POTFILES.in: added libgimp/gimp.c with some new messages.
|
||||
|
||||
2008-08-14 Takeshi AIHANA <takeshi.aihana@gmail.com>
|
||||
|
||||
* ja.po: Updated Japanese translation by Kiyotaka Nishibori.
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
[encoding: UTF-8]
|
||||
|
||||
libgimp/gimp.c
|
||||
libgimp/gimpbrushmenu.c
|
||||
libgimp/gimpbrushselectbutton.c
|
||||
libgimp/gimpexport.c
|
||||
|
|
Loading…
Reference in New Issue