From: Christian Dywan Date: Sat, 25 Dec 2010 01:07:45 +0000 (+0100) Subject: Don't try to set a non-existing page at startup X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69c229b7a77069d7812caa55f74f1d2693070984;p=midori Don't try to set a non-existing page at startup And print a proper warning should this occur somewhere else later on. --- 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)))