Update Javascript memory management a bit.
* bindings/vapi/javascriptcore-4.0.vapi: Don't pretend JS.String will be unreff'ed by vala, it wont. Add JS.GlobalContext.retain, in case it wants to be used. * src/client/components/client-web-view.vala (ClientWebView::ClientWebView): JavascriptResult instances are unref'ed when unowned.
This commit is contained in:
parent
772b874def
commit
503ca3b478
2 changed files with 19 additions and 3 deletions
|
|
@ -5,7 +5,11 @@
|
|||
* (version 2.1 or later). See the COPYING file in this distribution.
|
||||
*/
|
||||
|
||||
[CCode (cprefix = "JS", gir_namespace = "JavaScriptCore", gir_version = "4.0", lower_case_cprefix = "JS_", cheader_filename = "JavaScriptCore/JavaScript.h")]
|
||||
[CCode (cprefix = "JS",
|
||||
gir_namespace = "JavaScriptCore",
|
||||
gir_version = "4.0",
|
||||
lower_case_cprefix = "JS_",
|
||||
cheader_filename = "JavaScriptCore/JavaScript.h")]
|
||||
namespace JS {
|
||||
|
||||
[CCode (cname = "JSContextRef")]
|
||||
|
|
@ -31,8 +35,12 @@ namespace JS {
|
|||
[SimpleType]
|
||||
public struct GlobalContext : Context {
|
||||
|
||||
[CCode (cname = "JSGlobalContextRetain")]
|
||||
public bool retain();
|
||||
|
||||
[CCode (cname = "JSGlobalContextRelease")]
|
||||
public bool release();
|
||||
|
||||
}
|
||||
|
||||
[CCode (cname = "JSType", has_type_id = false)]
|
||||
|
|
@ -120,7 +128,7 @@ namespace JS {
|
|||
|
||||
}
|
||||
|
||||
[CCode (cname = "JSStringRef", ref_function = "JSStringRetain", unref_function = "JSStringRelease")]
|
||||
[CCode (cname = "JSStringRef")]
|
||||
[SimpleType]
|
||||
public struct String {
|
||||
|
||||
|
|
|
|||
|
|
@ -210,11 +210,17 @@ public class ClientWebView : WebKit.WebView {
|
|||
queue_resize();
|
||||
} catch (Geary.JS.Error err) {
|
||||
debug("Could not get preferred height: %s", err.message);
|
||||
} finally {
|
||||
result.unref();
|
||||
}
|
||||
});
|
||||
content_manager.script_message_received[REMOTE_IMAGE_LOAD_BLOCKED_MESSAGE].connect(
|
||||
(result) => {
|
||||
remote_image_load_blocked();
|
||||
try {
|
||||
remote_image_load_blocked();
|
||||
} finally {
|
||||
result.unref();
|
||||
}
|
||||
});
|
||||
content_manager.script_message_received[SELECTION_CHANGED_MESSAGE].connect(
|
||||
(result) => {
|
||||
|
|
@ -222,6 +228,8 @@ public class ClientWebView : WebKit.WebView {
|
|||
selection_changed(WebKitUtil.to_bool(result));
|
||||
} catch (Geary.JS.Error err) {
|
||||
debug("Could not get selection content: %s", err.message);
|
||||
} finally {
|
||||
result.unref();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue