From 0e5cb28e09a22dc0ec49a4fa84060434fa4b901e Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Thu, 27 Oct 2011 23:17:16 +0200 Subject: [PATCH] Copy styles passed to midori_web_settings_add_style Style strings are usually allocated, unlike rule_id's. --- midori/midori-websettings.c | 11 ++++++----- midori/midori-websettings.h | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/midori/midori-websettings.c b/midori/midori-websettings.c index 477d5d82..1b0ca64f 100644 --- a/midori/midori-websettings.c +++ b/midori/midori-websettings.c @@ -1806,7 +1806,7 @@ midori_web_settings_process_stylesheets (MidoriWebSettings* settings) /** * midori_web_settings_add_style: - * @rule_id: a string identifier + * @rule_id: a static string identifier * @style: a CSS stylesheet * * Adds or replaces a custom stylesheet. @@ -1815,16 +1815,17 @@ midori_web_settings_process_stylesheets (MidoriWebSettings* settings) **/ void midori_web_settings_add_style (MidoriWebSettings* settings, - gchar* rule_id, - gchar* style) + const gchar* rule_id, + const gchar* style) { g_return_if_fail (MIDORI_IS_WEB_SETTINGS (settings)); g_return_if_fail (rule_id != NULL); g_return_if_fail (style != NULL); if (settings->user_stylesheets == NULL) - settings->user_stylesheets = g_hash_table_new (g_str_hash, NULL); - g_hash_table_insert (settings->user_stylesheets, rule_id, style); + settings->user_stylesheets = g_hash_table_new_full (g_str_hash, NULL, + NULL, g_free); + g_hash_table_insert (settings->user_stylesheets, (gchar*)rule_id, g_strdup (style)); midori_web_settings_process_stylesheets (settings); } diff --git a/midori/midori-websettings.h b/midori/midori-websettings.h index 80bf00b8..5e343442 100644 --- a/midori/midori-websettings.h +++ b/midori/midori-websettings.h @@ -160,8 +160,8 @@ midori_web_settings_new (void); void midori_web_settings_add_style (MidoriWebSettings* settings, - gchar* rule_id, - gchar* style); + const gchar* rule_id, + const gchar* style); void midori_web_settings_remove_style (MidoriWebSettings* settings, -- 2.39.5