in case of an error, pass the error message with the return values.
2008-08-17 Sven Neumann <sven@gimp.org> * plug-ins/common/file-pdf.c: in case of an error, pass the error message with the return values. svn path=/trunk/; revision=26637
This commit is contained in:

committed by
Sven Neumann

parent
ad828a0301
commit
d5da6ce87b
@ -1,3 +1,8 @@
|
||||
2008-08-17 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/common/file-pdf.c: in case of an error, pass the error
|
||||
message with the return values.
|
||||
|
||||
2008-08-17 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/common/file-gif-load.c
|
||||
|
@ -289,14 +289,11 @@ run (const gchar *name,
|
||||
if (export == GIMP_EXPORT_EXPORT)
|
||||
gimp_image_delete (image_ID);
|
||||
|
||||
if (status == GIMP_PDB_EXECUTION_ERROR)
|
||||
if (status == GIMP_PDB_EXECUTION_ERROR && error)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
*nreturn_vals = 2;
|
||||
values[1].type = GIMP_PDB_STRING;
|
||||
values[1].data.d_string = error->message;
|
||||
}
|
||||
*nreturn_vals = 2;
|
||||
values[1].type = GIMP_PDB_STRING;
|
||||
values[1].data.d_string = error->message;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,8 @@ static gint32 load_image (PopplerDocument *doc,
|
||||
static gboolean load_dialog (PopplerDocument *doc,
|
||||
PdfSelectedPages *pages);
|
||||
|
||||
static PopplerDocument * open_document (const gchar *filename);
|
||||
static PopplerDocument * open_document (const gchar *filename,
|
||||
GError **error);
|
||||
|
||||
static GdkPixbuf * get_thumbnail (PopplerDocument *doc,
|
||||
gint page,
|
||||
@ -327,6 +328,7 @@ run (const gchar *name,
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
gint32 image_ID = -1;
|
||||
PopplerDocument *doc = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
run_mode = param[0].data.d_int32;
|
||||
|
||||
@ -351,7 +353,7 @@ run (const gchar *name,
|
||||
/* Possibly retrieve last settings */
|
||||
gimp_get_data (LOAD_PROC, &loadvals);
|
||||
|
||||
doc = open_document (param[1].data.d_string);
|
||||
doc = open_document (param[1].data.d_string, &error);
|
||||
|
||||
if (!doc)
|
||||
{
|
||||
@ -371,7 +373,7 @@ run (const gchar *name,
|
||||
break;
|
||||
|
||||
case GIMP_RUN_NONINTERACTIVE:
|
||||
doc = open_document (param[1].data.d_string);
|
||||
doc = open_document (param[1].data.d_string, &error);
|
||||
|
||||
if (doc)
|
||||
{
|
||||
@ -392,8 +394,9 @@ run (const gchar *name,
|
||||
}
|
||||
}
|
||||
else
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
|
||||
{
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -439,7 +442,7 @@ run (const gchar *name,
|
||||
/* Possibly retrieve last settings */
|
||||
gimp_get_data (LOAD_PROC, &loadvals);
|
||||
|
||||
doc = open_document (param[0].data.d_string);
|
||||
doc = open_document (param[0].data.d_string, &error);
|
||||
|
||||
if (doc)
|
||||
{
|
||||
@ -499,37 +502,46 @@ run (const gchar *name,
|
||||
status = GIMP_PDB_CALLING_ERROR;
|
||||
}
|
||||
|
||||
if (status == GIMP_PDB_EXECUTION_ERROR && error)
|
||||
{
|
||||
*nreturn_vals = 2;
|
||||
values[1].type = GIMP_PDB_STRING;
|
||||
values[1].data.d_string = error->message;
|
||||
}
|
||||
|
||||
values[0].data.d_status = status;
|
||||
}
|
||||
|
||||
static PopplerDocument*
|
||||
open_document (const gchar *filename)
|
||||
open_document (const gchar *filename,
|
||||
GError **load_error)
|
||||
{
|
||||
PopplerDocument *doc;
|
||||
GError *err = NULL;
|
||||
gchar *uri;
|
||||
GError *error = NULL;
|
||||
|
||||
uri = g_filename_to_uri (filename, NULL, &err);
|
||||
uri = g_filename_to_uri (filename, NULL, &error);
|
||||
|
||||
if (err)
|
||||
if (! uri)
|
||||
{
|
||||
g_warning ("Could not convert '%s' to an URI: %s",
|
||||
gimp_filename_to_utf8 (filename),
|
||||
err->message);
|
||||
|
||||
g_set_error (load_error, 0, 0,
|
||||
"Could not convert '%s' to an URI: %s",
|
||||
gimp_filename_to_utf8 (filename), error->message);
|
||||
g_error_free (error);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
doc = poppler_document_new_from_file (uri, NULL, &err);
|
||||
doc = poppler_document_new_from_file (uri, NULL, &error);
|
||||
|
||||
g_free (uri);
|
||||
|
||||
if (err)
|
||||
if (! doc)
|
||||
{
|
||||
g_message (_("Could not open '%s' for reading: %s"),
|
||||
gimp_filename_to_utf8 (filename),
|
||||
err->message);
|
||||
|
||||
g_set_error (load_error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
|
||||
_("Could not open '%s' for reading: %s"),
|
||||
gimp_filename_to_utf8 (filename),
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user