Re: Glib - Object Properties
- From: Tristan Van Berkom <tvb gnome org>
- To: Shay Harding <sharding ccbill com>
- Cc: gtk-list gnome org
- Subject: Re: Glib - Object Properties
- Date: Tue, 14 Jun 2005 11:10:53 -0400
Shay Harding wrote:
Hello,
I am new to Glib and have been working through constructing an object. I
have an object working, but am having issues with the properties. I have
the properties working (kind of), but some things don't make sense to me
and was hoping someone could explain.
I have searched the web and mailing list archives, but can only find
data circa 2004 or less and am not really sure if it still pertains
today.
Currently, I can get/set properties no problem. The issues I am having
pertain to how to trap errors during object construction for
CONSTRUCT_ONLY properties. If I have a property with flags set to:
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE
then I supposedly can only set the property while calling
g_object_new(). This is only kind of true. If I attempt to set the
property after g_object_new() is called, Glib simply emits a warning,
but still allows the property to be set. Actually, this is only true if
I call g_object_set_property() within my xxx_set_property() function.
The problem is g_object_set_property() returns void so I have no way to
catch errors (i.e. property set outside of a constructor).
How can CONSTRUCT_ONLY actually be enforced and not emit warnings to
stdout/stderr? From what I can tell, I can't even write my own code to
do this since I have no access to the static global 'pspec_pool' and the
GParamSpec passed to my xxx_set_property() function after construct is
NULL (incidentally it seems to always be NULL after the object is
constructed even without CONSTRUCT_ONLY set in flags).
Thanks for any insight as to why this all works like this and any advice
on enforcing policies.
Hi,
"Construct only" properties were only enforced in GTK+ >= 2.4,
If you are using the latest GTK+, then your xxx_set_property method
"shouldn't get envoked" when setting properties on your object.
You should never call g_object_set_property () from inside your
xxx_set_property method, this will result in endless recursion,
the set_property method is a private method used only to actualy
persist the transported GValue on your actual instance.
Cheers,
-Tristan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]