Re: [gtkmm] Glib critical messages on Property<>



Daniel Elstner wrote:

On Don, 2003-03-27 at 17:58, Murray Cumming Comneon com wrote:
Glib::Property<> wraps existing properties. It doesn't add properties. You
would need to use the Glib API for that. If you want to be able to add
properties from C++ code then please submit a gtkmm 2.4 bug.

Sorry, but that's not true :-)  The whole purpose of Glib::Property<> is
to be able to install custom properties via C++ code.

(main.exe:10701): GLib-GObject-CRITICAL **: file gvalue.c: line 103
(g_value_copy): assertion `g_value_type_compatible (G_VALUE_TYPE
(src_value), G_VALUE_TYPE (dest_value))' failed

Do I something wrong here? I searched in the docu and the FAQs but I found nothing about my problem. Are there any restrictions for Glib::Value<T*>?

I reckon the problem might be an add_attribute() call with incompatible
types, and not directly caused by Glib::Property<> itself.  IIRC
Glib::Property<> has been used with success for custom types before; try
checking the list archives.
Yes, problem caused by Glib::Value<T*> (GValue, actualy).

1. T* should be a pointer to class derived from GLib::Object.
2. You should ensure you did proper initialization of your class propery member in constructor. 3. And as Daniel said you have to watch you are using same T* pointers when handling property value (using add_attribute or directly).

I think, it is better to use Glib::Property<void *> to store a pointer to any custom class, casting functions gonna do dirk work for ya later. At least, in my "FAST" text cellrenderer I have no troubles with such things.

Regards,
-andrew





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