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
This commit is contained in:
Alexander Butenko 2010-02-02 21:31:15 +01:00 committed by Christian Dywan
parent 62dac745d6
commit ce43fb3c03

View file

@ -291,7 +291,10 @@ formhistory_window_object_cleared_cb (WebKitWebView* web_view,
JSContextRef js_context, JSContextRef js_context,
JSObjectRef js_window) 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 static void
@ -342,8 +345,6 @@ formhistory_deactivate_tabs (MidoriView* view,
MidoriExtension* extension) MidoriExtension* extension)
{ {
GtkWidget* web_view = gtk_bin_get_child (GTK_BIN (view)); 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 ( g_signal_handlers_disconnect_by_func (
web_view, formhistory_window_object_cleared_cb, NULL); web_view, formhistory_window_object_cleared_cb, NULL);
#if WEBKIT_CHECK_VERSION (1, 1, 4) #if WEBKIT_CHECK_VERSION (1, 1, 4)
@ -364,6 +365,8 @@ formhistory_deactivate_cb (MidoriExtension* extension,
sqlite3* db; sqlite3* db;
#endif #endif
g_signal_handlers_disconnect_by_func (
browser, formhistory_add_tab_cb, extension);
g_signal_handlers_disconnect_by_func ( g_signal_handlers_disconnect_by_func (
extension, formhistory_deactivate_cb, browser); extension, formhistory_deactivate_cb, browser);
g_signal_handlers_disconnect_by_func ( g_signal_handlers_disconnect_by_func (
@ -371,7 +374,7 @@ formhistory_deactivate_cb (MidoriExtension* extension,
midori_browser_foreach (browser, midori_browser_foreach (browser,
(GtkCallback)formhistory_deactivate_tabs, extension); (GtkCallback)formhistory_deactivate_tabs, extension);
jsforms = ""; katze_assign (jsforms, NULL);
if (global_keys) if (global_keys)
g_hash_table_destroy (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, global_keys = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify)g_free, (GDestroyNotify)g_free,
(GDestroyNotify)g_free); (GDestroyNotify)g_free);
if(!jsforms)
formhistory_prepare_js ();
#if HAVE_SQLITE #if HAVE_SQLITE
config_dir = midori_extension_get_config_dir (extension); config_dir = midori_extension_get_config_dir (extension);
katze_mkdir_with_parents (config_dir, 0700); katze_mkdir_with_parents (config_dir, 0700);