From: Vincent Cappe Date: Sun, 19 Feb 2012 16:44:15 +0000 (+0100) Subject: When removing bookmarks, folder must not be NULL X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62f0ef746c182ba6b0d61fd1199e8ac0a4ff759d;p=midori When removing bookmarks, folder must not be NULL If folder is NULL, we end up with "(NULL)" in sqlite. Modified patch to use katze_str_non_null. Fixes: https://bugs.launchpad.net/midori/+bug/926914 --- diff --git a/katze/katze-utils.h b/katze/katze-utils.h index 93637760..274aebb2 100644 --- a/katze/katze-utils.h +++ b/katze/katze-utils.h @@ -58,6 +58,20 @@ G_BEGIN_DECLS **/ #define katze_strv_assign(lvalue, rvalue) lvalue = (g_strfreev (lvalue), rvalue) +/** + * katze_str_non_null: + * @str: a string, or %NULL + * + * Returns "" if @str is %NULL. + * + * Since: 0.4.4 + **/ +static inline const gchar* +katze_str_non_null (const gchar* str) +{ + return str ? str : ""; +} + GtkWidget* katze_property_proxy (gpointer object, const gchar* property, diff --git a/midori/main.c b/midori/main.c index e1b53a5f..51a913f8 100644 --- a/midori/main.c +++ b/midori/main.c @@ -531,14 +531,14 @@ midori_bookmarks_remove_item_cb (KatzeArray* array, "DELETE FROM bookmarks WHERE uri = '%q' " " AND folder = '%q'", katze_item_get_uri (item), - katze_item_get_meta_string (item, "folder")); + katze_str_non_null (katze_item_get_meta_string (item, "folder"))); else sqlcmd = sqlite3_mprintf ( "DELETE FROM bookmarks WHERE title = '%q'" " AND folder = '%q'", katze_item_get_name (item), - katze_item_get_meta_string (item, "folder")); + katze_str_non_null (katze_item_get_meta_string (item, "folder"))); if (sqlite3_exec (db, sqlcmd, NULL, NULL, &errmsg) != SQLITE_OK) { diff --git a/midori/midori-searchaction.c b/midori/midori-searchaction.c index c4a97121..bc814d99 100644 --- a/midori/midori-searchaction.c +++ b/midori/midori-searchaction.c @@ -877,12 +877,6 @@ midori_search_action_editor_name_changed_cb (GtkWidget* entry, GTK_RESPONSE_ACCEPT, text && *text); } -static inline const gchar* -STR_NON_NULL (const gchar* string) -{ - return string ? string : ""; -} - static void midori_search_action_get_editor (MidoriSearchAction* search_action, gboolean new_engine) @@ -943,7 +937,7 @@ midori_search_action_get_editor (MidoriSearchAction* search_action, gtk_entry_set_activates_default (GTK_ENTRY (entry_name), TRUE); if (!new_engine) gtk_entry_set_text (GTK_ENTRY (entry_name), - STR_NON_NULL (katze_item_get_name (item))); + katze_str_non_null (katze_item_get_name (item))); gtk_box_pack_start (GTK_BOX (hbox), entry_name, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (content_area), hbox); gtk_widget_show_all (hbox); @@ -957,7 +951,7 @@ midori_search_action_get_editor (MidoriSearchAction* search_action, gtk_entry_set_activates_default (GTK_ENTRY (entry_description), TRUE); if (!new_engine) gtk_entry_set_text (GTK_ENTRY (entry_description) - , STR_NON_NULL (katze_item_get_text (item))); + , katze_str_non_null (katze_item_get_text (item))); gtk_box_pack_start (GTK_BOX (hbox), entry_description, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (content_area), hbox); gtk_widget_show_all (hbox); @@ -977,7 +971,7 @@ midori_search_action_get_editor (MidoriSearchAction* search_action, gtk_entry_set_activates_default (GTK_ENTRY (entry_uri), TRUE); if (!new_engine) gtk_entry_set_text (GTK_ENTRY (entry_uri) - , STR_NON_NULL (katze_item_get_uri (item))); + , katze_str_non_null (katze_item_get_uri (item))); gtk_box_pack_start (GTK_BOX (hbox), entry_uri, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (content_area), hbox); gtk_widget_show_all (hbox); @@ -991,7 +985,7 @@ midori_search_action_get_editor (MidoriSearchAction* search_action, gtk_entry_set_activates_default (GTK_ENTRY (entry_icon), TRUE); if (!new_engine) gtk_entry_set_text (GTK_ENTRY (entry_icon) - , STR_NON_NULL (katze_item_get_icon (item))); + , katze_str_non_null (katze_item_get_icon (item))); gtk_box_pack_start (GTK_BOX (hbox), entry_icon, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (content_area), hbox); gtk_widget_show_all (hbox); @@ -1005,7 +999,7 @@ midori_search_action_get_editor (MidoriSearchAction* search_action, gtk_entry_set_activates_default (GTK_ENTRY (entry_token), TRUE); if (!new_engine) gtk_entry_set_text (GTK_ENTRY (entry_token) - , STR_NON_NULL (katze_item_get_token (item))); + , katze_str_non_null (katze_item_get_token (item))); gtk_box_pack_start (GTK_BOX (hbox), entry_token, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (content_area), hbox); gtk_widget_show_all (hbox);