Fix bug#563 - "Unhandled signal emitting with invalid signature (which leads to application crash)"
This commit is contained in:
parent
4b6cc4d478
commit
e8c0ba238a
5 changed files with 16 additions and 16 deletions
|
|
@ -188,7 +188,7 @@ static bool emitNormalSignal(QObject* source, int signalIndex, const char* signa
|
||||||
Shiboken::AutoDecRef sequence(PySequence_Fast(args, 0));
|
Shiboken::AutoDecRef sequence(PySequence_Fast(args, 0));
|
||||||
int argsGiven = PySequence_Fast_GET_SIZE(sequence.object());
|
int argsGiven = PySequence_Fast_GET_SIZE(sequence.object());
|
||||||
|
|
||||||
if (argsGiven > argTypes.count()) {
|
if (argsGiven != argTypes.count()) {
|
||||||
PyErr_Format(PyExc_TypeError, "%s only accepts %d arguments, %d given!", signal, argTypes.count(), argsGiven);
|
PyErr_Format(PyExc_TypeError, "%s only accepts %d arguments, %d given!", signal, argTypes.count(), argsGiven);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ class TestConnectionWithInvalidSignature(TimedQApplication):
|
||||||
root = view.rootObject()
|
root = view.rootObject()
|
||||||
button = root.findChild(QtCore.QObject, "buttonMouseArea")
|
button = root.findChild(QtCore.QObject, "buttonMouseArea")
|
||||||
view.show()
|
view.show()
|
||||||
button.clicked.emit()
|
button.entered.emit()
|
||||||
self.assertEqual(rotatevalue.rotation, 100)
|
self.assertEqual(rotatevalue.rotation, 100)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ Rectangle {
|
||||||
id: buttonMouseArea
|
id: buttonMouseArea
|
||||||
objectName: "buttonMouseArea"
|
objectName: "buttonMouseArea"
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onEntered: {
|
||||||
rotatevalue.rotation = rotatevalue.val()
|
rotatevalue.rotation = rotatevalue.val()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@ class TestConnectionWithInvalidSignature(TimedQApplication):
|
||||||
view.setSource(QtCore.QUrl.fromLocalFile(adjust_filename('connect_python_qml.qml', __file__)))
|
view.setSource(QtCore.QUrl.fromLocalFile(adjust_filename('connect_python_qml.qml', __file__)))
|
||||||
root = view.rootObject()
|
root = view.rootObject()
|
||||||
button = root.findChild(QtCore.QObject, "buttonMouseArea")
|
button = root.findChild(QtCore.QObject, "buttonMouseArea")
|
||||||
self.assertRaises(TypeError, QtCore.QObject.connect, [button,QtCore.SIGNAL('clicked()'), self.onButtonFailClicked])
|
self.assertRaises(TypeError, QtCore.QObject.connect, [button,QtCore.SIGNAL('entered()'), self.onButtonFailClicked])
|
||||||
button.clicked.connect(self.onButtonClicked)
|
button.entered.connect(self.onButtonClicked)
|
||||||
button.clicked.emit()
|
button.entered.emit()
|
||||||
view.show()
|
view.show()
|
||||||
self.app.exec_()
|
self.app.exec_()
|
||||||
self.assert_(self.buttonClicked)
|
self.assert_(self.buttonClicked)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue