From f83d1639f84590bbc939416f55b795068f4c6ea5 Mon Sep 17 00:00:00 2001 From: Shaun McCance Date: Fri, 17 Feb 2012 10:57:51 -0500 Subject: [PATCH] Don't crash when doing stuff to empty windows --- src/yelp-application.c | 9 +++++++++ src/yelp-window.c | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/yelp-application.c b/src/yelp-application.c index 4aafade9..057cafdc 100644 --- a/src/yelp-application.c +++ b/src/yelp-application.c @@ -543,6 +543,9 @@ yelp_application_add_bookmark (YelpBookmarks *bookmarks, GSettings *settings; YelpApplication *app = YELP_APPLICATION (bookmarks); + g_return_if_fail (page_id); + g_return_if_fail (doc_uri); + settings = application_get_doc_settings (app, doc_uri); if (settings) { @@ -788,7 +791,13 @@ window_resized (YelpWindow *window, GSettings *settings; uri = yelp_window_get_uri (window); + if (uri == NULL) + return FALSE; doc_uri = yelp_uri_get_document_uri (uri); + if (doc_uri == NULL) { + g_object_unref (uri); + return FALSE; + } settings = g_hash_table_lookup (priv->docsettings, doc_uri); if (settings) { diff --git a/src/yelp-window.c b/src/yelp-window.c index 98570c2f..7f1889ae 100644 --- a/src/yelp-window.c +++ b/src/yelp-window.c @@ -562,6 +562,7 @@ window_construct (YelpWindow *window) g_signal_connect (priv->view, "notify::yelp-uri", G_CALLBACK (view_uri_selected), window); g_signal_connect_swapped (priv->view, "notify::page-id", G_CALLBACK (window_set_bookmark_action), window); + window_set_bookmark_action (window); g_signal_connect (priv->view, "notify::root-title", G_CALLBACK (view_root_title), window); gtk_container_add (GTK_CONTAINER (scroll), GTK_WIDGET (priv->view)); gtk_widget_grab_focus (GTK_WIDGET (priv->view)); @@ -910,7 +911,7 @@ window_set_bookmark_action (YelpWindow *window) "yelp-uri", &uri, "page-id", &page_id, NULL); - if (page_id == NULL) { + if (page_id == NULL || uri == NULL) { gtk_action_set_sensitive (action_add, FALSE); gtk_action_set_sensitive (action_del, FALSE); goto done; -- 2.11.4.GIT