webext: Free JavaScript objects
Webkit documentation says JavaScript objects refcount is always increased, and has to be released always.
This commit is contained in:
+8
-2
@@ -25,6 +25,7 @@ readsock(GIOChannel *s, GIOCondition c, gpointer unused)
|
|||||||
static char js[48], msg[MSGBUFSZ];
|
static char js[48], msg[MSGBUFSZ];
|
||||||
WebKitWebPage *page;
|
WebKitWebPage *page;
|
||||||
JSCContext *jsc;
|
JSCContext *jsc;
|
||||||
|
JSCValue *jsv;
|
||||||
GError *gerr = NULL;
|
GError *gerr = NULL;
|
||||||
gsize msgsz;
|
gsize msgsz;
|
||||||
|
|
||||||
@@ -48,6 +49,7 @@ readsock(GIOChannel *s, GIOCondition c, gpointer unused)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
jsc = webkit_frame_get_js_context(webkit_web_page_get_main_frame(page));
|
jsc = webkit_frame_get_js_context(webkit_web_page_get_main_frame(page));
|
||||||
|
jsv = NULL;
|
||||||
|
|
||||||
switch (msg[1]) {
|
switch (msg[1]) {
|
||||||
case 'h':
|
case 'h':
|
||||||
@@ -56,7 +58,7 @@ readsock(GIOChannel *s, GIOCondition c, gpointer unused)
|
|||||||
snprintf(js, sizeof(js),
|
snprintf(js, sizeof(js),
|
||||||
"window.scrollBy(window.innerWidth/100*%hhd,0);",
|
"window.scrollBy(window.innerWidth/100*%hhd,0);",
|
||||||
msg[2]);
|
msg[2]);
|
||||||
jsc_context_evaluate(jsc, js, -1);
|
jsv = jsc_context_evaluate(jsc, js, -1);
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
if (msgsz != 3)
|
if (msgsz != 3)
|
||||||
@@ -64,10 +66,14 @@ readsock(GIOChannel *s, GIOCondition c, gpointer unused)
|
|||||||
snprintf(js, sizeof(js),
|
snprintf(js, sizeof(js),
|
||||||
"window.scrollBy(0,window.innerHeight/100*%hhd);",
|
"window.scrollBy(0,window.innerHeight/100*%hhd);",
|
||||||
msg[2]);
|
msg[2]);
|
||||||
jsc_context_evaluate(jsc, js, -1);
|
jsv = jsc_context_evaluate(jsc, js, -1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_object_unref(jsc);
|
||||||
|
if (jsv)
|
||||||
|
g_object_unref(jsv);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user