PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 550 - Can't call PySide slot from QtScript when the args are a list of anything.
: Can't call PySide slot from QtScript when the args are a list of anything.
Status: CLOSED INVALID
Product: PySide
Classification: Unclassified
Component: QtScript
: 1.0.0 beta1
: All All
: P3 normal
Assigned To: Hugo Parente Lima
:
:
:
  Show dependency treegraph
 
Reported: 2010-12-16 15:18 EET by Hugo Parente Lima
Modified: 2011-01-21 15:44 EET (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hugo Parente Lima 2010-12-16 15:18:37 EET
Quoting Jukka Välimaa:

Here's a complete example. I run the file containing this, and the only
message printed is the error I wrote about above; the method is never
called. If I use int in the test method, everything works fine.

--------------------------------------------------------------------------------------
from PySide import QtCore
from PySide.QtGui import QApplication
from PySide.QtScript import QScriptEngine, QScriptValue

app = QApplication([])

class Test(QtCore.QObject):
    @QtCore.Slot(list)
    def test(self, param):
        print 'test method called, param is', type(param), param

engine = QScriptEngine()
test = Test()
test_qobject = engine.newQObject(test)
engine.globalObject().setProperty('test', test_qobject)

val = engine.evaluate("test.test([1, 2, 3])")
print val.toString()
---------------------------------------------------------------------------------------------
Comment 1 Matti Airas 2010-12-16 16:34:46 EET
Thanks for the bug. Since this would appear to be a "normal" bug, I'll
prioritize this P3. The bug will be fixed once the preceding P2 and P3 bugs
have been dealt with.
Comment 2 Matti Airas 2010-12-16 16:35:56 EET
Oh, and if you think this should be prioritized higher, tell me why, and I can
change the prioritization.
Comment 3 renato filho 2011-01-03 12:16:19 EET
Try to change the Slot decorator to:

@QtCore.Slot('QList<int>')

this will work, some types on python is not exported to Qt like QVariant,
QHash, QLinkedList and others, because of this we have this decorator with
string as argument.
Comment 4 Hugo Parente Lima 2011-01-03 14:45:01 EET
Even worst... it results in a segfault.
Comment 5 Hugo Parente Lima 2011-01-11 15:52:44 EET
I fixed crash discovered by renato, and about the signature mismatch the
solution is a bit awkward but works:

-------------------------------------------------------------------------------------
from PySide.QtCore import *
from PySide.QtScript import *

app = QCoreApplication([])

class Test(QObject):
    @Slot('QVariant', result=unicode)
    def test(self, param):
        return 'test method called, param is %s %s' % (type(param), param)

engine = QScriptEngine()
test = Test()
test_qobject = engine.newQObject(test)
engine.globalObject().setProperty('test', test_qobject)

val = engine.evaluate("test.test([1, 2, 3])")
print val.toString()
-------------------------------------------------------------------------------------

This solution works on both: PyQt4 API1/2 and PySide.

I'll mark the bug as invalid as the current solution already work and the bug
discovered and fixed in the comments was not direct related to the reported
problem.
Comment 6 renato filho 2011-01-21 15:44:44 EET
release beta4