Commit a89e5030 authored by Jehan's avatar Jehan

Issue #2611: Cannot open certain .pdf files in GIMP.

I am unsure of the problem, but it is fixed by using
poppler_document_new_from_gfile() instead of giving the contents of a
GMappedFile to poppler_document_new_from_data().
Using GFile is anyway usually prefered so I don't dig up more and just
make this change.
parent ff2d22d9
...@@ -668,24 +668,11 @@ open_document (const gchar *filename, ...@@ -668,24 +668,11 @@ open_document (const gchar *filename,
GError **load_error) GError **load_error)
{ {
PopplerDocument *doc; PopplerDocument *doc;
GMappedFile *mapped_file; GFile *file;
GError *error = NULL; GError *error = NULL;
mapped_file = g_mapped_file_new (filename, FALSE, &error); file = g_file_new_for_path (filename);
doc = poppler_document_new_from_gfile (file, PDF_password, NULL, &error);
if (! mapped_file)
{
g_set_error (load_error, GIMP_PLUGIN_PDF_LOAD_ERROR, 0,
_("Could not load '%s': %s"),
gimp_filename_to_utf8 (filename), error->message);
g_error_free (error);
return NULL;
}
doc = poppler_document_new_from_data (g_mapped_file_get_contents (mapped_file),
g_mapped_file_get_length (mapped_file),
PDF_password,
&error);
if (run_mode == GIMP_RUN_INTERACTIVE) if (run_mode == GIMP_RUN_INTERACTIVE)
{ {
...@@ -724,10 +711,9 @@ open_document (const gchar *filename, ...@@ -724,10 +711,9 @@ open_document (const gchar *filename,
if (run == GTK_RESPONSE_OK) if (run == GTK_RESPONSE_OK)
{ {
g_clear_error (&error); g_clear_error (&error);
doc = poppler_document_new_from_data (g_mapped_file_get_contents (mapped_file), doc = poppler_document_new_from_gfile (file,
g_mapped_file_get_length (mapped_file), gtk_entry_get_text (GTK_ENTRY (entry)),
gtk_entry_get_text (GTK_ENTRY (entry)), NULL, &error);
&error);
} }
label = gtk_label_new (_("Wrong password! Please input the right one:")); label = gtk_label_new (_("Wrong password! Please input the right one:"));
gtk_widget_destroy (dialog); gtk_widget_destroy (dialog);
...@@ -738,6 +724,7 @@ open_document (const gchar *filename, ...@@ -738,6 +724,7 @@ open_document (const gchar *filename,
} }
gtk_widget_destroy (label); gtk_widget_destroy (label);
} }
g_object_unref (file);
/* We can't g_mapped_file_unref(mapped_file) as apparently doc has /* We can't g_mapped_file_unref(mapped_file) as apparently doc has
* references to data in there. No big deal, this is just a * references to data in there. No big deal, this is just a
......
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