[colord] python Colord.Device.get_default_profile()
Richard Hughes
hughsient at gmail.com
Wed Feb 26 01:13:39 PST 2014
On 26 February 2014 02:40, Sanford Rockowitz <rockowitz at minsoft.com> wrote:
> Not sure if I'm misusing/misunderstanding the Python API, or if there's a
> bug here.
A bug I think -- this fails:
device = client.find_device_sync(device_id, GIO_CANCELLABLE)
device.connect_sync(GIO_CANCELLABLE)
profiles = device.get_profiles()
default_profile = device.get_default_profile()
...this works:
device = client.find_device_sync(device_id, GIO_CANCELLABLE)
device.connect_sync(GIO_CANCELLABLE)
#profiles = device.get_profiles()
default_profile = device.get_default_profile()
For the first snippet, breaking on cd_device_get_default_profile()
shows the device->priv->profiles array being empty. Odder.
profiles = device.get_profiles()
print profiles
profiles = device.get_profiles()
print profiles
gives:
[<Profile object at 0xb65690 (CdProfile at 0xbdab50)>]
[]
So the action of getting the profiles clears the array. The only thing
that clears that array is cd_device_set_profiles_array_from_variant(),
which is only called on device connect. valgrind doesn't seem to
complain about memory accesses, although I don't know if that is
supposed to work in GObjectIntrospection python.
So, I set up gdb to break on cd_profile_finalize -- this gets fired
after get_profiles() gets called the second time, before the [] gets
printed, from pygobject_dealloc. This is what I would have expected to
see if the introspection was marked (transfer full) -- but the
Colord-1.0.gir file clearly has <return-value
transfer-ownership="container">.
Very odd. Any ideas? In the meantime you can do profiles[0] to get the
default profile, but we need to fix this.
Richard
More information about the colord
mailing list