From 69c229b7a77069d7812caa55f74f1d2693070984 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sat, 25 Dec 2010 02:07:45 +0100 Subject: [PATCH] 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 db80d834..32420b0c 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 c085e257..7f6b256a 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)))