After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 623330 - Passing cairo_t as in parameter
Passing cairo_t as in parameter
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2010-07-01 23:31 UTC by Owen Taylor
Modified: 2015-10-27 23:31 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Owen Taylor 2010-07-01 23:31:00 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);
Comment 1 Johan (not receiving bugmail) Dahlin 2010-07-09 12:33:43 UTC
Yes, this makes sense, I just mixed up reference with destroy I guess.
Comment 2 Cosimo Cecchi 2015-10-27 23:31:53 UTC
I made the change in master (5 years later).