Commit 582caf5a 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.

(cherry picked from commit a89e5030)
parent d75a4615
......@@ -668,24 +668,11 @@ open_document (const gchar *filename,
GError **load_error)
{
PopplerDocument *doc;
GMappedFile *mapped_file;
GFile *file;
GError *error = NULL;
mapped_file = g_mapped_file_new (filename, FALSE, &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);
file = g_file_new_for_path (filename);
doc = poppler_document_new_from_gfile (file, PDF_password, NULL, &error);
if (run_mode == GIMP_RUN_INTERACTIVE)
{
......@@ -724,10 +711,9 @@ open_document (const gchar *filename,
if (run == GTK_RESPONSE_OK)
{
g_clear_error (&error);
doc = poppler_document_new_from_data (g_mapped_file_get_contents (mapped_file),
g_mapped_file_get_length (mapped_file),
gtk_entry_get_text (GTK_ENTRY (entry)),
&error);
doc = poppler_document_new_from_gfile (file,
gtk_entry_get_text (GTK_ENTRY (entry)),
NULL, &error);
}
label = gtk_label_new (_("Wrong password! Please input the right one:"));
gtk_widget_destroy (dialog);
......@@ -738,6 +724,7 @@ open_document (const gchar *filename,
}
gtk_widget_destroy (label);
}
g_object_unref (file);
/* 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
......
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