From 43398c4ea1a940bc2ee2921d5811fe8ee4144a65 Mon Sep 17 00:00:00 2001 From: "Nickolay V. Shmyrev" Date: Fri, 6 Jan 2006 18:36:53 +0000 Subject: [PATCH] Clamp page recieved from metadata in valid values. Fix for the bug * shell/ev-window.c: (setup_document_from_metadata), (ev_window_cmd_view_reload): Clamp page recieved from metadata in valid values. Fix for the bug #325986. --- ChangeLog | 8 ++++++++ shell/ev-window.c | 7 ++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 96b49e45..89107851 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-01-06 Nickolay V. Shmyrev + + * shell/ev-window.c: (setup_document_from_metadata), + (ev_window_cmd_view_reload): + + Clamp page recieved from metadata in valid values. Fix + for the bug #325986. + 2006-01-06 Nickolay V. Shmyrev * MAINTAINERS: diff --git a/shell/ev-window.c b/shell/ev-window.c index fe2d0a87..15d671f5 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -625,11 +625,12 @@ setup_document_from_metadata (EvWindow *window) { char *uri = window->priv->uri; GValue page = { 0, }; + gint new_page; - /* Page */ if (uri && ev_metadata_manager_get (uri, "page", &page, TRUE)) { + new_page = CLAMP (g_value_get_int (&page), 0, ev_page_cache_get_n_pages (window->priv->page_cache) - 1); ev_page_cache_set_current_page (window->priv->page_cache, - g_value_get_int (&page)); + new_page); } } @@ -2089,7 +2090,7 @@ ev_window_cmd_view_reload (GtkAction *action, EvWindow *ev_window) ev_window_open_uri (ev_window, uri); /* In case the number of pages in the document has changed. */ - page = CLAMP (page, 0, ev_page_cache_get_n_pages (ev_window->priv->page_cache)); + page = CLAMP (page, 0, ev_page_cache_get_n_pages (ev_window->priv->page_cache) - 1); ev_page_cache_set_current_page (ev_window->priv->page_cache, page); -- 2.43.5