[PyQt] Bug in SIP w.r.t. signals, typedefs and mapped types

Simon Edwards simon at simonzone.com
Sun Aug 17 00:44:29 BST 2008


Hello Phil,

While working on integrating Python into KDE4's Plasma I hit a crasher 
when using @pyqtSignature where one of the arguments for the slot is a 
typedef which in turn in a mapped type:

@pyqtSignature("dataUpdated(const QString &, const 
Plasma::DataEngine::Data &)")

Plasma::DataEngine::Data is a typedef for QHash<QString,QVariant>.

This would crash when the signal is sent to the slot. After a heap of 
debugging I've figured out goes wrong. When the signal comes in the 
Plasma::DataEngine::Data type was being converted to QHash. Later when 
sip looks for the mapped type in order to do the conversion, it can't 
find what it is looking for but sip continues and dereferences a null 
pointer.

The cause is in the code generated for the plasma module. The 
typedefsTable looks something like this:

static sipTypedefDef typedefsTable[] = {
   ...
   {"Plasma::DataEngine::Data", mtype_sat, "QHash", NULL},
   ...
};

The extra types for the QHash are stripped off. The table should look 
more like:

static sipTypedefDef typedefsTable[] = {
   ...
   {"Plasma::DataEngine::Data", mtype_sat, "QHash<QString,QVariant>", NULL},
   ...
};


cheers,

-- 
Simon Edwards             | KDE-NL, Guidance tools, Guarddog Firewall
simon at simonzone.com       | http://www.simonzone.com/software/
Nijmegen, The Netherlands | "ZooTV? You made the right choice."


More information about the PyQt mailing list