[gjs/gnome-3-28] util-root: Allow null notification functions when rooting
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/gnome-3-28] util-root: Allow null notification functions when rooting
- Date: Sat, 1 Dec 2018 20:59:33 +0000 (UTC)
commit 1c011c3c648b3467a0ad36e3d4bec3fc9347366b
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Apr 15 17:52:42 2018 +0200
util-root: Allow null notification functions when rooting
This basically drops the safety net for whenever the context goes
away, and potentially leaking.. However unconditionally adding this
weak ref may result in quite expensive in memory relocations, the
caller may handle this in a smarter way.
Currently the only paths triggering this are in test folder, in
tests not explicitly tracking dispose behavior, so it may be "fine"
to leave as is.
https://gitlab.gnome.org/GNOME/gjs/issues/144
Closes: #144
(cherry picked from commit 99032dc3ad58c8c5290eee31b4b22c773467266b)
gjs/jsapi-util-root.h | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/gjs/jsapi-util-root.h b/gjs/jsapi-util-root.h
index 9ffcbaed..d64eccb7 100644
--- a/gjs/jsapi-util-root.h
+++ b/gjs/jsapi-util-root.h
@@ -248,10 +248,12 @@ public:
m_data = data;
m_root = new JS::PersistentRooted<T>(m_cx, thing);
- auto gjs_cx = static_cast<GjsContext *>(JS_GetContextPrivate(m_cx));
- g_assert(GJS_IS_CONTEXT(gjs_cx));
- g_object_weak_ref(G_OBJECT(gjs_cx), on_context_destroy, this);
- m_has_weakref = true;
+ if (notify) {
+ auto gjs_cx = static_cast<GjsContext *>(JS_GetContextPrivate(m_cx));
+ g_assert(GJS_IS_CONTEXT(gjs_cx));
+ g_object_weak_ref(G_OBJECT(gjs_cx), on_context_destroy, this);
+ m_has_weakref = true;
+ }
}
/* You can only assign directly to the GjsMaybeOwned wrapper in the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]