Re: Single toggle reference only



Yevgen Muntyan wrote:
Owen Taylor wrote:
On Sat, 2007-10-20 at 17:58 -0500, Yevgen Muntyan wrote:
Hi there,

Is there a technical reason why toggle references
allow only a single user? Namely, why

" Multiple toggle references may be added to the same
gobject, however if there are multiple toggle references
to an object, none of them will ever be notified until all
but one are removed."

Why doesn't it emit a notification when reference count
drops to N instead of 1, where N is number of
g_object_add_toggle_ref() calls?
Say you have the following scenario:

                                   GTK+ internal reference
                                         || A
\/ C# application data => C# proxy <=> [ GObject ]
                                  B      /\
                                         || C
                                         \/
                             java implementation of object
Your suggestion is that the toggle references B and C should be notified when the strong reference A is dropped. But then the
reference to the Java object would be converted to a weak
reference and the Java object improperly collected, even though
it is still referenced from the C# application.

But it would happen only if C# kept the object, i.e. if it
didn't drop its toggle reference. I'd think it contradicts
the purpose of toggle references; it could be banned.
Unless there is a use for toggle references other than
attaching proxies which are kind of glued to the object.

Sorry, nevermind. I got it.
Perhaps some GObjectProxy could work? A language
binding would then either take normal reference to
an object or "talk" to the proxy object. Need to draw
a picture.

Best regards,
Yevgen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]