From ce43fb3c03b72547eca6104362b90c60ab1d4cfb Mon Sep 17 00:00:00 2001 From: Alexander Butenko Date: Tue, 2 Feb 2010 21:31:15 +0100 Subject: [PATCH] Rebuild formhistory script on reload and do not leak the script 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 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/extensions/formhistory.c b/extensions/formhistory.c index 8404ea19..6c1548e0 100644 --- a/extensions/formhistory.c +++ b/extensions/formhistory.c @@ -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); -- 2.39.5