Commit d5da6ce8 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

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
parent ad828a03
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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment