summaryrefslogtreecommitdiff
path: root/gi/object.h
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2021-03-24 07:15:47 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2021-04-22 22:58:57 +0200
commit02899a7bd092af071ec4deaa2fdc3aaaaa3179f0 (patch)
treefd43b715bea621e857a54ab9158f94cc2e99a45d /gi/object.h
parenta90459e4ae873e257b55adf4e4cb43f875bf0d33 (diff)
downloadgjs-02899a7bd092af071ec4deaa2fdc3aaaaa3179f0.tar.gz
object: Never try to add a toggle reference on a disposed object
This should never happen as it would never be released afterwards, so protect the call in all the cases, triggering a warning (but without throwing as it's not a pure JS error) and return a bool so that we can handle this case better (in fact if this happens we should not consider the object toggle-reffed). As per this we can now also warn about access to disposed object also when trying to set a new expand property to a disposed object (adding tests ensuring that this won't affect pre-set properties).
Diffstat (limited to 'gi/object.h')
-rw-r--r--gi/object.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/gi/object.h b/gi/object.h
index 2e7b04fb..fd04caf6 100644
--- a/gi/object.h
+++ b/gi/object.h
@@ -382,7 +382,7 @@ class ObjectInstance : public GIWrapperInstance<ObjectBase, ObjectPrototype,
void track_gobject_finalization();
void ignore_gobject_finalization();
void check_js_object_finalized(void);
- void ensure_uses_toggle_ref(JSContext* cx);
+ bool ensure_uses_toggle_ref(JSContext* cx);
[[nodiscard]] bool check_gobject_disposed(const char* for_what) const;
GJS_JSAPI_RETURN_CONVENTION
bool signal_match_arguments_from_object(JSContext* cx,