From: Patrick Steinhardt Date: Sat, 20 May 2017 08:36:40 +0000 (+0200) Subject: setting: always clear scripts previous to adding global ones X-Git-Url: https://git.owens.tech///git?a=commitdiff_plain;h=34233193cba4bf1b0e91f3210660e20fc58e0be8;p=vimb.git setting: always clear scripts previous to adding global ones Previous to adding user scripts to the content manager, we should always clear existing scripts. Otherwise, e.g. in the sequence :set user-scripts=off :set user-scripts=on we'd end up with the same global scripts injected twice. Fix the issue by unconditionally clearing all user scripts previous to adding scripts. --- diff --git a/src/setting.c b/src/setting.c index de33832..ee7cb19 100644 --- a/src/setting.c +++ b/src/setting.c @@ -607,6 +607,7 @@ static int user_scripts(Client *c, const char *name, DataType type, void *value, gboolean enabled = *(gboolean*)value; ucm = webkit_web_view_get_user_content_manager(c->webview); + webkit_user_content_manager_remove_all_scripts(ucm); if (enabled) { if (vb.files[FILES_SCRIPT] @@ -621,8 +622,6 @@ static int user_scripts(Client *c, const char *name, DataType type, void *value, webkit_user_script_unref(script); g_free(source); } - } else { - webkit_user_content_manager_remove_all_scripts(ucm); } /* Inject the global scripts. */