setIsEvaluating(false);
addToObject(owner);
callback = &subscriptionCallback;
+
+ /*
+ If this is a cloned method, connect to the 'original'. For example,
+ for the signal 'void aSignal(int parameter = 0)', if the method
+ index refers to 'aSignal()', get the index of 'aSignal(int)'.
+ This ensures that 'parameter' will be available from QML.
+ */
+ if (signal.attributes() & QMetaMethod::Cloned) {
+ do {
+ --m_index;
+ } while (scope->metaObject()->method(m_index).attributes() & QMetaMethod::Cloned);
+ }
QQmlNotifierEndpoint::connect(scope, m_index, engine);
}
--- /dev/null
+import Test 1.0
+import QtQuick 2.0
+
+MyQmlObject {
+ property real signalCount: 0
+ property real signalArg: 0
+
+ signal noArgSignal
+ signal argSignal(real arg)
+
+ function emitNoArgSignal() { noArgSignal(); }
+ function emitArgSignal() { argSignal(22); }
+
+ onSignalWithDefaultArg: {
+ signalArg = parameter
+ signalCount++
+ }
+
+ Component.onCompleted: {
+ noArgSignal.connect(signalWithDefaultArg)
+ argSignal.connect(signalWithDefaultArg)
+ }
+}
void propertyInit();
void remoteLoadCrash();
+ void signalWithDefaultArg();
// regression tests for crashes
void crash1();
delete o;
}
+void tst_qqmllanguage::signalWithDefaultArg()
+{
+ QQmlComponent component(&engine, TEST_FILE("signalWithDefaultArg.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("signalCount").toInt(), 0);
+ QCOMPARE(object->property("signalArg").toInt(), 0);
+
+ emit object->signalWithDefaultArg();
+ QCOMPARE(object-> property("signalCount").toInt(), 1);
+ QCOMPARE(object->property("signalArg").toInt(), 5);
+
+ emit object->signalWithDefaultArg(15);
+ QCOMPARE(object->property("signalCount").toInt(), 2);
+ QCOMPARE(object->property("signalArg").toInt(), 15);
+
+ const QMetaObject *metaObject = object->metaObject();
+
+ metaObject->invokeMethod(object, "emitNoArgSignal");
+ QCOMPARE(object->property("signalCount").toInt(), 3);
+ QCOMPARE(object->property("signalArg").toInt(), 5);
+
+ metaObject->invokeMethod(object, "emitArgSignal");
+ QCOMPARE(object->property("signalCount").toInt(), 4);
+ QCOMPARE(object->property("signalArg").toInt(), 22);
+
+ delete object;
+}
+
// QTBUG-20639
void tst_qqmllanguage::globalEnums()
{