Thanks this helps.

On 10 June 2010 07:41, Abderrahim Kitouni <[email protected]> wrote:

> Hi,
>                   في ث، 08-06-2010 عند 18:41 +0930 ، كتب James Moschou:
> > Hi
> >
> > I'm having trouble debugging my application, I'm getting references
> suddenly
> > becoming null, and I'm finding the existing explanations surrounding
> memory
> > management in vala confusing.
> >
> > The explanation at http://live.gnome.org/Vala/ReferenceHandling has got:
> > > Vala prevents you from assigning an unowned reference to a strong (i.e.
> > not unowned) reference. However, you can transfer the ownership to
> another
> > reference with (owned)
> >
> > But then the tutorial at http://live.gnome.org/Vala/Tutorial has got:
> > > If the calling code is written as
> > > Object o = get_unowned_ref();
> > > Vala will try to either obtain a reference of or a duplicate of the
> > instance the unowned reference pointing to
> >
> > Since I'm not getting compiling errors or warnings I assume that the
> latter
> > is what's happening, but I still don't know exactly what's happening. Is
> it
> > making a copy, increasing the ref count by 1 or transferring ownership?
>
> 1. Vala doesn't transfer ownership by default, you need to explicitly
> use an (owned) cast.
> 2. If the class is ref counted, it'll increase its ref count
> Else, if it is [Immutable] (e. g. string), it'll make a copy.
> Else, it will tell you to explicitly call the copy method.
>
> A strong reference should never become null by itself, so it's either an
> unowned reference, or the function you're using returned null for some
> reason.
>
> HTH,
> Abderrahim
>
>
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to