Re: Chaining Up (GLib Tutorial Error)



On 10/28/07, Stefan Kost <ensonic hora-obscura de> wrote:
> >> (Unless there is something horribly wrong with my implementation of
> >> _GET_CLASS...)
> >>
> >> This works fine until we create CClass, a direct descendant of BClass.
> >> When CClass is using the default 'method_to_call' code, e.g. in
> >> finalize, B_GET_CLASS actually returns CClass. parent_class is now
> >> BClass, and 'method_to_call' invokes itself, leading eventually to stack
> >> overflow.
> >>
>
> B_GET_CLASS should always give you BClass and never CClass imho.

I think the point here is that B_GET_CLASS will simply return the
class structure of the given instance casted to a BClass, but if you
pass a C instance you still get the class structure for C, and the
parent will be a BClass (and thus the inifinite loop). There's simply
no way around this other than using the pointer G_DEFINE_TYPE_* stores
for each class definition instead of trying to get the information at
runtime, which is what Emmanuele was trying to say (I think).

Cheers, Xan


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