Qt bindings

James Thorniley james at uncommonlygood.co.uk
Wed Jun 15 12:00:48 PDT 2005


Hi,

I was playing with the qt bindings in the 0.33 distribution and found that it 
was quite difficult to use the message arguments as I expected, specifically 
the copy constructor for the Message::iterator class seems to do a half deep 
half shallow copy[1]. I thought it would probably be best if it was a deep 
copy, but that seemed to be rather difficult as I'm not sure it's possible to 
safely deep copy a DBusMessageIter (since it contains pointers, memcpy does 
not work and there's no library function to do it for you).

Anyway I thought it would be easier if arguments were stored as a QValueList, 
and copied into / out of the DBusMessage at send/receive time. This way you 
can use the reliable methods provided by QValueList for dealing with the 
arguments in a message. So I knocked up a patch to do this.

Also, instead of abstracting arguments as a QVariant (which the current 
implementation does) I wrote a new class (DBusQt::Argument) which is 
basically the same as QVariant but supports all the possible dbus types (well 
in theory at least - it doesn't support everything yet, just strings and 
int32s, and it can do nested structs and arrays of arrays).

Once I got into it I also modified the out of memory handling, added 
DBusQt::Object to receive method invocations, and implemented async method 
calling in DBusQt::Connection.

The patch is a bit big to attach to an email, I've put it on the web along 
with some more explanations of what I've done.

http://www-users.york.ac.uk/~jrht100/dbusqt/

There are also some test stubs that use the qt bindings at that address.

Sorry I went ahead and modified so much in one go, but I was wondering if the 
maintainer of these bindings would be interested in merging some of these 
changes. I'd be happy to make some modifications if desired.

BTW these changes probably break binary compatibility for the qt bindings 
completely (haven't actually tested, but I made quite a few changes). I don't 
know if that's important.

James Thorniley

1.
Message::iterator::iterator( const iterator& itr )
{
  d = new IteratorData;
  d->iter = itr.d->iter;
  d->var  = itr.d->var;
  d->end  = itr.d->end;
}
d->iter is a pointer, d->var and d->end are not - looks like a bit of a 
problem to me


More information about the dbus mailing list