[PyQt] QVariantHash bug in PyQt 4.5.1 (+patch)
Simon Edwards
simon at simonzone.com
Thu Jul 9 10:45:45 BST 2009
Hello,
Phil Thompson wrote:
> On Wed, 08 Jul 2009 20:03:08 +0200, Simon Edwards <simon at simonzone.com>
> wrote:
>> The good folks at the Pardus Linux distribution brought a bug to my
>> attention where QHash<String,QVariant> objects (aka QVariantHash) would
>> be mapped to empty Python dicts.
>>
>> I've dug into the SIP and PyQt and found the problem and have simple
>> fix. See the attached patch.
>>
>> This bug affects a rather important part of the KDE desktop (plasmoids),
>> and therefore directly affects the Pardus release (due in ~2 weeks) and
>> the KDE 4.3 release (due end of this month). An updated PyQt would be
>> very welcome, the sooner the better.
>
> Would you say that QVariantList and QVariantMap have the same problem?
Yes. qvariant.h defines the following:
typedef QList<QVariant> QVariantList;
typedef QMap<QString, QVariant> QVariantMap;
typedef QHash<QString, QVariant> QVariantHash;
QVariantList, QVariantMap and QVariantHash are not subclasses of
QVariant, so casting them to QVariant is illegal. As a matter of
interest, QVariant::toHash() starts with a new QHash object which is
then filled in upon successful conversion. In the buggy situation the
conversion fails (it checks types internally) and the empty QHash is
returned, which matches what we've seen in KDE's Plasma.
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