[Xfce4-commits] <midori:master> Copy styles passed to midori_web_settings_add_style

Christian Dywan noreply at xfce.org
Thu Oct 27 23:24:01 CEST 2011


Updating branch refs/heads/master
         to 0e5cb28e09a22dc0ec49a4fa84060434fa4b901e (commit)
       from 3a49943d10f9a408ac31fdb6874c2bc2583ac8b2 (commit)

commit 0e5cb28e09a22dc0ec49a4fa84060434fa4b901e
Author: Christian Dywan <christian at twotoasts.de>
Date:   Thu Oct 27 23:17:16 2011 +0200

    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 477d5d8..1b0ca64 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 80bf00b..5e34344 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,


More information about the Xfce4-commits mailing list