aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-03-24 14:31:05 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-24 16:00:55 +0100
commit03a0773b1001728ca52d6cd5429e73445274ae81 (patch)
treed7e0d6d8da14d6c112ee885bc2214bf261ce8d85 /tests
parent18f21746d7e58bec0a819d84fe17f245a8439ae8 (diff)
Fix infinite loop in method overload resolution
When resolving overloaded slots in a situation without property cache, then we need to detect that we've reached the end of the overload lists and exit from RelatedMethod with zero. Task-number: QTBUG-37157 Change-Id: Ifaab8cc1b377725c99c1bb89bb9bb74d5a0af1b8 Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index ed6b5a9d42..3357aa7643 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -163,6 +163,9 @@ tst_QJSEngine::~tst_QJSEngine()
{
}
+Q_DECLARE_METATYPE(Qt::KeyboardModifier)
+Q_DECLARE_METATYPE(Qt::KeyboardModifiers)
+
class OverloadedSlots : public QObject
{
Q_OBJECT
@@ -175,6 +178,7 @@ signals:
void slotWithoutArgCalled();
void slotWithSingleArgCalled(const QString &arg);
void slotWithArgumentsCalled(const QString &arg1, const QString &arg2, const QString &arg3);
+ void slotWithOverloadedArgumentsCalled(const QString &arg, Qt::KeyboardModifier modifier, Qt::KeyboardModifiers moreModifiers);
public slots:
void slotToCall() { emit slotWithoutArgCalled(); }
@@ -183,6 +187,10 @@ public slots:
{
slotWithArgumentsCalled(arg, arg2, arg3);
}
+ void slotToCall(const QString &arg, Qt::KeyboardModifier modifier, Qt::KeyboardModifiers blah = Qt::ShiftModifier)
+ {
+ emit slotWithOverloadedArgumentsCalled(arg, modifier, blah);
+ }
};
void tst_QJSEngine::callQObjectSlot()
@@ -228,6 +236,18 @@ void tst_QJSEngine::callQObjectSlot()
QCOMPARE(arguments.at(1).toString(), QString("arg2"));
QCOMPARE(arguments.at(2).toString(), QString("arg3"));
}
+
+ {
+ QSignalSpy spy(&dummy, SIGNAL(slotWithOverloadedArgumentsCalled(QString, Qt::KeyboardModifier, Qt::KeyboardModifiers)));
+ eng.evaluate(QStringLiteral("dummy.slotToCall('arg', %1);").arg(QString::number(Qt::ControlModifier)));
+ QCOMPARE(spy.count(), 1);
+
+ const QList<QVariant> arguments = spy.first();
+ QCOMPARE(arguments.at(0).toString(), QString("arg"));
+ QCOMPARE(arguments.at(1).toInt(), int(Qt::ControlModifier));
+ QCOMPARE(int(qvariant_cast<Qt::KeyboardModifiers>(arguments.at(2))), int(Qt::ShiftModifier));
+
+ }
}
void tst_QJSEngine::constructWithParent()