[Xfce4-commits] <midori:master> Don't try to set a non-existing page at startup

Christian Dywan noreply at xfce.org
Sat Dec 25 02:08:01 CET 2010


Updating branch refs/heads/master
         to 69c229b7a77069d7812caa55f74f1d2693070984 (commit)
       from 448e119b0b5eed88ee24faa0d545fa6004e7ce92 (commit)

commit 69c229b7a77069d7812caa55f74f1d2693070984
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sat Dec 25 02:07:45 2010 +0100

    Don't try to set a non-existing page at startup
    
    And print a proper warning should this occur somewhere
    else later on.

 midori/main.c           |    7 ++++---
 midori/midori-browser.c |    6 ++++++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/midori/main.c b/midori/main.c
index db80d83..32420b0 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -1312,11 +1312,12 @@ midori_load_session (gpointer data)
         midori_browser_add_item (browser, item);
     }
     current = katze_item_get_meta_integer (KATZE_ITEM (_session), "current");
-    if (current < 0)
-        current = 0;
-    midori_browser_set_current_page (browser, current);
     if (!(item = katze_array_get_nth_item (_session, current)))
+    {
+        current = 0;
         item = katze_array_get_nth_item (_session, 0);
+    }
+    midori_browser_set_current_page (browser, current);
     if (!g_strcmp0 (katze_item_get_uri (item), ""))
         midori_browser_activate_action (browser, "Location");
 
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index c085e25..7f6b256 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -6876,8 +6876,14 @@ void
 midori_browser_set_current_page (MidoriBrowser* browser,
                                  gint           n)
 {
+    gint n_pages;
     GtkWidget* view;
 
+    g_return_if_fail (MIDORI_IS_BROWSER (browser));
+
+    n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (browser->notebook));
+    g_return_if_fail (n < n_pages);
+
     gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), n);
     view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), n);
     if (midori_view_is_blank (MIDORI_VIEW (view)))



More information about the Xfce4-commits mailing list