Re: Overriding property defaults



Tim Janik <timj gtk org> writes:

> > The minimum to be able to do this without breaking source
> > compatibility is adding _copy and _set_default functions to
> > GParamSpecTypeInfo.
> 
> adding _set_default functions isn't sufficient, what if ranges
> change in a child class, or G_PARAM_CONSTRUCT_ONLY suddnely
> becomes a normal read/write property.
> what if a child doesn't want to inherit a certain parent class
> property because it takes care of its value internally?

The range of what is acceptable to do when overriding a parent
property is _very_ small

The child can:

 - Change the default value
 - Make the validator more restrictive

With the second being something you'd want to do only very occasionally.
It is wrong, in my opinion for:

 - The child to make the validator less restrictive. (This would
   break the parent widget.)
 - The child to override the setter/getter for the property
   to do something else. (This probably breaks the parent widget.)
 - The child to change the documentation. (Just wrong - the documentation
   of a property can't be different in two places.)

Removing a property altogether is certainly highly dubious.

> so basically children need to be able to override parent properties
> full scale, but that's best done with the g_param_spec_*() functions,
> just the property lister needs to mask them out.

Can you be specific about what you are thinking of?

                                        Owen




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