+2008-06-16 Carlos Garcia Campos <carlosgc@gnome.org>
+
+ * backend/pdf/ev-poppler.cc: (pdf_document_get_info):
+ * shell/ev-sidebar-thumbnails.c:
+ (ev_sidebar_thumbnails_set_loading_icon),
+ (ev_sidebar_thumbnails_refresh):
+ * shell/ev-window.c: (ev_window_error_message),
+ (ev_window_warning_message), (ev_window_refresh_window_thumbnail),
+ (ev_window_set_document):
+
+ Do not crash opening documents with no pages and show a warning
+ message in the message area. Fixes bugs #537574 and #171588.
+
2008-06-15 Carlos Garcia Campos <carlosgc@gnome.org>
* shell/Makefile.am:
"linearized", &(info->linearized),
NULL);
- page = ev_document_get_page (document, 0);
- ev_document_get_page_size (document, page,
- &(info->paper_width),
- &(info->paper_height));
- g_object_unref (page);
+ info->n_pages = ev_document_get_n_pages (document);
- // Convert to mm.
- info->paper_width = info->paper_width / 72.0f * 25.4f;
- info->paper_height = info->paper_height / 72.0f * 25.4f;
+ if (info->n_pages > 0) {
+ page = ev_document_get_page (document, 0);
+ ev_document_get_page_size (document, page,
+ &(info->paper_width),
+ &(info->paper_height));
+ g_object_unref (page);
+
+
+ // Convert to mm.
+ info->paper_width = info->paper_width / 72.0f * 25.4f;
+ info->paper_height = info->paper_height / 72.0f * 25.4f;
+ }
switch (layout) {
case POPPLER_PAGE_LAYOUT_SINGLE_PAGE:
info->permissions |= EV_DOCUMENT_PERMISSIONS_OK_TO_ADD_NOTES;
}
- info->n_pages = ev_document_get_n_pages (document);
-
if (ev_document_security_has_document_security (EV_DOCUMENT_SECURITY (document))) {
/* translators: this is the document security state */
info->security = g_strdup (_("Yes"));
if (sidebar_thumbnails->priv->loading_icon)
g_object_unref (sidebar_thumbnails->priv->loading_icon);
- if (sidebar_thumbnails->priv->document) {
+ if (sidebar_thumbnails->priv->document &&
+ sidebar_thumbnails->priv->n_pages > 0) {
gint width, height;
/* We get the dimensions of the first page so that we can make a blank
sidebar_thumbnails->priv->rotation = rotation;
ev_sidebar_thumbnails_set_loading_icon (sidebar_thumbnails);
- if (sidebar_thumbnails->priv->document == NULL)
+ if (sidebar_thumbnails->priv->document == NULL ||
+ sidebar_thumbnails->priv->n_pages <= 0)
return;
ev_sidebar_thumbnails_clear_model (sidebar_thumbnails);
}
static void
-ev_window_error_message_response_cb (EvMessageArea *area,
- gint response_id,
- EvWindow *window)
+ev_window_message_area_response_cb (EvMessageArea *area,
+ gint response_id,
+ EvWindow *window)
{
ev_window_set_message_area (window, NULL);
}
if (error)
ev_message_area_set_secondary_text (EV_MESSAGE_AREA (area), error->message);
g_signal_connect (area, "response",
- G_CALLBACK (ev_window_error_message_response_cb),
+ G_CALLBACK (ev_window_message_area_response_cb),
+ window);
+ gtk_widget_show (area);
+ ev_window_set_message_area (EV_WINDOW (window), area);
+}
+
+static void
+ev_window_warning_message (GtkWindow *window, const gchar *msg)
+{
+ GtkWidget *area;
+
+ if (EV_WINDOW (window)->priv->message_area)
+ return;
+
+ area = ev_message_area_new (GTK_MESSAGE_WARNING,
+ msg,
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CANCEL,
+ NULL);
+
+ g_signal_connect (area, "response",
+ G_CALLBACK (ev_window_message_area_response_cb),
window);
gtk_widget_show (area);
ev_window_set_message_area (EV_WINDOW (window), area);
gdouble scale;
EvDocument *document = ev_window->priv->document;
- if (!EV_IS_DOCUMENT_THUMBNAILS (document)) {
+ if (!EV_IS_DOCUMENT_THUMBNAILS (document) ||
+ ev_page_cache_get_n_pages (ev_window->priv->page_cache) <= 0) {
return;
}
if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0) {
ev_view_set_document (view, document);
+ } else {
+ ev_window_warning_message (GTK_WINDOW (ev_window),
+ _("The document contains no pages"));
}
g_idle_add ((GSourceFunc)ev_window_setup_document, ev_window);