Hi,

I have been experiencing issues when emitting a signal with a QVariant signature containing a Python object. The issue seems to stem from the Chimera::Storage::address() function which returns the data part of the QVariant even if the wrapped object used to be a QVariant itself. I have attached a test case and a patch against PyQt 4.8.2-bb053c0310a3 nightly which fixes the issue for me.

--
Philip Lorenz
from PyQt4.QtCore import *
import sip

class VariantTest(QObject):
  valueChanged = pyqtSignal((QVariant, QString))

  def __init__(self):
    QObject.__init__(self)
    self._obj = object()

  def fire(self):
    self.valueChanged.emit(self._obj, "Abc")
    
  def recv(self, variant, string):
    print variant.toPyObject(), string
    

app = QCoreApplication([])
a = VariantTest()
b = VariantTest()
a.valueChanged.connect(b.recv)
a.fire()
app.exec_()
diff -Naur 
PyQt-x11-gpl-snapshot-4.8.2-bb053c0310a3.orig//qpy/QtCore/qpycore_chimera_storage.cpp
 PyQt-x11-gpl-snapshot-4.8.2-bb053c0310a3/qpy/QtCore/qpycore_chimera_storage.cpp
--- 
PyQt-x11-gpl-snapshot-4.8.2-bb053c0310a3.orig//qpy/QtCore/qpycore_chimera_storage.cpp
       2010-11-20 14:05:21.000000000 +0100
+++ 
PyQt-x11-gpl-snapshot-4.8.2-bb053c0310a3/qpy/QtCore/qpycore_chimera_storage.cpp 
    2010-11-20 14:06:20.000000000 +0100
@@ -85,7 +85,10 @@
 void *Chimera::Storage::address()
 {
     if (!isPointerType())
-        return _value_storage.data();
+        if (_parsed_type->typeDef() == sipType_QVariant)
+            return &_value_storage;
+        else
+            return _value_storage.data();
 
     if (_parsed_type->name().endsWith('*'))
         return &_ptr_storage;
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to