]> spindle.queued.net Git - midori/commitdiff
Rebuild formhistory script on reload and do not leak the script
authorAlexander Butenko <a.butenka@gmail.com>
Tue, 2 Feb 2010 20:31:15 +0000 (21:31 +0100)
committerChristian Dywan <christian@twotoasts.de>
Tue, 2 Feb 2010 20:32:20 +0000 (21:32 +0100)
1. Don't leak the script in formhistory_window_object_cleared_cb ()
2. Disconnect add-tab signal in the right place
3. Rebuild the base javascript code on extension reload

extensions/formhistory.c

index 8404ea19c4c4fa59dfe8aa2f843271f3a9f8158e..6c1548e02756c8230f0c5396b63575b5fa10a6a3 100644 (file)
@@ -291,7 +291,10 @@ formhistory_window_object_cleared_cb (WebKitWebView*  web_view,
                                       JSContextRef    js_context,
                                       JSObjectRef     js_window)
 {
-    sokoke_js_script_eval (js_context, formhistory_build_js (), NULL);
+    gchar* script;
+    script = formhistory_build_js ();
+    sokoke_js_script_eval (js_context, script, NULL);
+    g_free (script);
 }
 
 static void
@@ -342,8 +345,6 @@ formhistory_deactivate_tabs (MidoriView*      view,
                              MidoriExtension* extension)
 {
     GtkWidget* web_view = gtk_bin_get_child (GTK_BIN (view));
-    g_signal_handlers_disconnect_by_func (
-       browser, formhistory_add_tab_cb, extension);
     g_signal_handlers_disconnect_by_func (
        web_view, formhistory_window_object_cleared_cb, NULL);
     #if WEBKIT_CHECK_VERSION (1, 1, 4)
@@ -364,6 +365,8 @@ formhistory_deactivate_cb (MidoriExtension* extension,
     sqlite3* db;
     #endif
 
+    g_signal_handlers_disconnect_by_func (
+       browser, formhistory_add_tab_cb, extension);
     g_signal_handlers_disconnect_by_func (
         extension, formhistory_deactivate_cb, browser);
     g_signal_handlers_disconnect_by_func (
@@ -371,7 +374,7 @@ formhistory_deactivate_cb (MidoriExtension* extension,
     midori_browser_foreach (browser,
         (GtkCallback)formhistory_deactivate_tabs, extension);
 
-    jsforms = "";
+    katze_assign (jsforms, NULL);
     if (global_keys)
         g_hash_table_destroy (global_keys);
 
@@ -428,6 +431,8 @@ formhistory_activate_cb (MidoriExtension* extension,
     global_keys = g_hash_table_new_full (g_str_hash, g_str_equal,
                                (GDestroyNotify)g_free,
                                (GDestroyNotify)g_free);
+    if(!jsforms)
+        formhistory_prepare_js ();
     #if HAVE_SQLITE
     config_dir = midori_extension_get_config_dir (extension);
     katze_mkdir_with_parents (config_dir, 0700);