[evince] Check legal boundaries of accessible pages (revisited)



commit feff531edc6f5b844f4f2a8d358ab5c638b3a449
Author: Germán Poo-Caamaño <gpoo gnome org>
Date:   Thu Feb 18 16:44:40 2016 -0800

    Check legal boundaries of accessible pages (revisited)
    
    Keep the accessible view end page under the limits of the document.
    Sometimes when a document is reloaded, it may have less pages making
    the end page higher than the actual number of pages.
    
    Fix https://bugzilla.gnome.org/show_bug.cgi?id=735744

 libview/ev-view-accessible.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/libview/ev-view-accessible.c b/libview/ev-view-accessible.c
index f3cd3dd..0b87cb6 100644
--- a/libview/ev-view-accessible.c
+++ b/libview/ev-view-accessible.c
@@ -389,6 +389,14 @@ initialize_children (EvViewAccessible *self)
                child = ev_page_accessible_new (self, i);
                g_ptr_array_add (self->priv->children, child);
        }
+
+        /* When a document is reloaded, it may have less pages.
+         * We need to update the end page accordingly to avoid
+         * invalid access to self->priv->children
+         * See https://bugzilla.gnome.org/show_bug.cgi?id=735744
+         */
+       if (self->priv->end_page > n_pages)
+               self->priv->end_page = n_pages;
 }
 
 static void
@@ -577,16 +585,8 @@ ev_view_accessible_set_page_range (EvViewAccessible *accessible,
 
        g_return_if_fail (EV_IS_VIEW_ACCESSIBLE (accessible));
 
-        /* When a document is reloaded, the accessible->priv->children is
-         * cleaned up and updated with the new document information.
-         * In specific cases, where the document is smaller, priv->end_page
-         * will be higher than the current number of pages. Therefore, we
-         * check the number of pages to avoid access to non-existent pages
-         * in priv->children).
-         * See https://bugzilla.gnome.org/show_bug.cgi?id=735744
-         */
        for (i = accessible->priv->start_page; i <= accessible->priv->end_page; i++) {
-               if ((i < start || i > end) && i < ev_view_accessible_get_n_pages (accessible)) {
+               if (i < start || i > end) {
                        page = g_ptr_array_index (accessible->priv->children, i);
                        atk_object_notify_state_change (page, ATK_STATE_SHOWING, FALSE);
                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]