GNOME Bugzilla – Bug 417116
Inconsistent Gnome::Gda::Value semantics
Last modified: 2011-01-16 23:39:36 UTC
Gnome::Gda::Value has different set() overloads, of which most do just g_value_set_*. g_value_set_* does not allow changing the value's type, so calling set("foo") on an uninitialized value (or one that holds another type than G_TYPE_STRING) raises an error. Other overloads use a gda_value_set_* function which does first unset the value and initialize it with the correct type again. Therefore, calling the set() overload that takes a GdaTime works on an uninitialized value. This is inconsistent and might confuse people. I think this is easy to fix once we agree on what to do in all cases. Allowing the Value to change its type during its lifetime is preferable, I guess, so adding g_value_unset()/g_value_init() calls to the set() functions that use g_value_set* might be enough.
Yes, let's do what gda_value_set* does. Maybe we can check the type before changing it, to maybe be more efficient. I wonder if C coders are meant to use the g_value_set_*() functions as well as the gda_value_set*() functions. This would then be confusing for them. But that would be a libgda bug.
Created attachment 84837 [details] [review] Make sure the value has the correct type before setting a new value I can commit this if you are OK with it. C coders have at least the gda_ vs. g_ prefix to differentiate between the two (in contrast to C++).
Yes, this looks good. Please go aheahd.
Patch committed.