Re: boxed types and copies
- From: Owen Taylor <otaylor redhat com>
- To: Tim Janik <timj gtk org>
- Cc: Havoc Pennington <hp redhat com>, Gtk+ Developers <gtk-devel-list gnome org>
- Subject: Re: boxed types and copies
- Date: 12 Dec 2000 19:58:09 -0500
Tim Janik <timj gtk org> writes:
> On 12 Dec 2000, Havoc Pennington wrote:
>
> >
> > Hi,
> >
> > The recent gtk_signal_emit() change broke the text widget - I'm using
> > GTK_TYPE_TEXT_ITER, GTK_TYPE_STRING, etc. for the signal signature,
> > at James' request, so Python can emit these signals.
> >
> > However these signal args MUST be passed by reference, it is far too
> > slow to copy the inserted string, and the iterator is supposed to be
> > modified by the signal handlers.
> >
> > Moving gtk_signal_emit() to the GValue collector causes it to
> > copy-by-value every boxed argument. So I either have to move back to
> > GTK_TYPE_POINTER and break language bindings, or leave GtkTextBuffer
> > broken.
>
> hm, i'm kinda two folded on that issue.
>
> on the one hand, the easy thing to do is to restore gtk_signal_emit(),
> but then, your signals that use these boxed types are really only
> usable with gtk_signal_emit() (not g_signal_emit()).
> beyond that, code that deals with your boxed values will get things wrong,
> since you copy the structure while you actually want it passed by
> reference.
> i think owen has a similar thing with selection data or something...
> basically, boxed values that aren't usefully copyable, must be reference
> counted so they can be passed by reference.
> the reference counting doesn't need to be exposed, you can have static
> ref/unref and pass that in to g_boxed_type_register_static().
>
> owen, what do you say? boxed types need to be either copy-able or
> reference counted, otherwise LBs or editors can't pass them around
> and store them away anyways. doing that static hack for gtk_signal_emit()
> just defers the problem and makes things work for just this moment in our
> limited testgtk universe.
During emissions, the person emitting signal owns the things that it
is passing into the signal; thus there is no need to make copies of them.
gtk_widget_size_request() needs to pass in the GtkRequisition by value, and
not make a copy.
Also GtkRequisition should not be GTK_TYPE_POINTER since it needs to be
useable from language bindings?
Does GtkRequition thus have to be ref-counted?
Whether an object is ref-counted or copied by value should not determine
whether it is possible to pass it in by reference via a GValue.
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]