[colord] Python GIR coding problem

Sanford Rockowitz rockowitz at minsoft.com
Mon Jul 1 17:35:43 PDT 2013


I'm trying to access colord from Python using the GIR bindings.  I can 
connect to colord and perform simple queries, but queries that return a 
list are not working.

Here's an example that attempts to distill the problem,  (The direct 
accesses for printing the client.ref_count and dev.ref_count values work 
on Ubuntu 13.04 by not Fedora 18, so are commented out. )

The problem arises  when trying to access  one device in the list 
returned by client.get_devices_sync(cancellable). Trying to do 
dev.connect_sync() on the device in the list causes a seg fault.  If I 
insert the dir(dev) line, that fails with the slightly more useful error 
message:

ERROR:../../../gi/_gobject/pygobject.c:618:pygobject_switch_to_toggle_ref: 
assertion failed: (self->obj->ref_count >= 1)
Aborted (core dumped)

What am I doing wrong?

Sanford



def simple_failure():
    print "(wrapcolord.simple_failure) Starting"
    cancellable = Gio.Cancellable.new();
    client = Colord.Client.new()
    print dir(client) # works
    # no client.ref_count attribute on Fedora
    # print "Before client.connect_sync(), client.ref_count=", 
client.ref_count      # 1
    client.connect_sync(cancellable)
    # print "After client.connect_sync(),  client.ref_count=%d" % 
client.ref_count   # 2
    print "daemon 
version=",client.get_daemon_version()                            # a 
simple call to show connection is working
    devices = client.get_devices_sync(cancellable)
    print '  len(devices) = ', 
len(devices)                                        # 4
    print dir(devices) # it's just a simple list
    for dev in devices:
       # print "   One device. dev.ref_count = ", 
dev.ref_count                      # 0 !!!
       print dir(dev) # Assertion fails and abort
dev.connect_sync(cancellable) # If print dir(dev) is commented out, seg 
fault here


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/colord/attachments/20130701/06c527ef/attachment.html>


More information about the colord mailing list