GNOME Bugzilla – Bug 623330
Passing cairo_t as in parameter
Last modified: 2015-10-27 23:31:53 UTC
static JSBool context_to_g_argument(JSContext *context, jsval value, GITypeInfo *type_info, const char *arg_name, GjsArgumentType argument_type, GITransfer transfer, gboolean may_be_null, GArgument *arg) { JSObject *obj; cairo_t *cr; obj = JSVAL_TO_OBJECT(value); cr = gjs_cairo_context_get_context(context, obj); if (!cr) return JS_FALSE; if (transfer == GI_TRANSFER_EVERYTHING) cairo_destroy(cr); arg->v_pointer = cr; return JS_TRUE; } The transfer == GI_TRANSFER_EVERYTHING check doens't make any sense for me. For background: * gjs_cairo_context_get_context() doesn't add a reference to the context * arg.c:type_needs_release() is false for any foreign type, as far as I can see. So, we won't free in arguments after the function call. So the code would look correct to me if it was: if (transfer == GI_TRANSFER_EVERYTHING) cairo_reference(cr);
Yes, this makes sense, I just mixed up reference with destroy I guess.
I made the change in master (5 years later).