After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 720042 - Using Gdk.Color and Gdk.RGBA in Gtk.ListStore doesn't work
Using Gdk.Color and Gdk.RGBA in Gtk.ListStore doesn't work
Status: RESOLVED OBSOLETE
Product: pygobject
Classification: Bindings
Component: introspection
3.8.x
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
: 787814 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-12-07 21:38 UTC by Kai Willadsen
Modified: 2018-01-10 20:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test case (807 bytes, text/x-python)
2013-12-07 21:38 UTC, Kai Willadsen
Details

Description Kai Willadsen 2013-12-07 21:38:17 UTC
Created attachment 263726 [details]
Test case

Creating and using Gdk.Color and Gdk.RGBA works fine, but as soon as these are pushed into a TreeStore or ListStore, they lose their actual values. I notice some boxed type changes in 3.9+, so it's possible that this is already fixed.

Test case attached. With 3.8.3, Gdk.RGBAs are all (0, 0, 0, 0), and Gdk.Colors are all (0, 0, <some random blue value>).
Comment 1 Simon Feltman 2013-12-08 09:00:16 UTC
(In reply to comment #0)
> ..I notice
> some boxed type changes in 3.9+, so it's possible that this is already fixed.

Verified this still seems to be a problem in master. There is a fairly easy workaround though:

liststore = Gtk.ListStore(str, object, object, str)

This will store boxed refs to the Python objects which wrap the color struct (GObject.TYPE_PYOBJECT).
Comment 2 Kai Willadsen 2013-12-13 22:48:37 UTC
Thanks for the workaround; at the moment I'm actually using the colour string as in the test case and that's fine too. It would be nice to fix however, just to have more self-documenting code.
Comment 3 Simon Feltman 2014-01-08 21:58:28 UTC
I've debugged this and found the problem to be with value retrieval. The RGBA and Color structs make their way into the ListStore properly but getting the value out (via get_value), does not correctly do a boxed copy:

https://git.gnome.org/browse/pygobject/tree/gi/pygi-marshal-to-py.c?id=3.11.3#n836

py_obj = pyg_value_as_pyobject (arg->v_pointer, FALSE);

This needs to pass something else besides FALSE. Most likely it should be similar to what the _pygi_boxed_new this below does, taking into account transfer mode and is_allocated (and actually a quick check verifies it fixes this specific case). But first we need to add tests for retrieval of a GValue holding a boxed with different combinations of transfer and caller allocation flags to be totally sure.
Comment 4 Reuben Rissler 2017-09-18 11:27:32 UTC
*** Bug 787814 has been marked as a duplicate of this bug. ***
Comment 5 GNOME Infrastructure Team 2018-01-10 20:35:13 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pygobject/issues/59.