summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2011-04-04 16:50:53 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2011-04-04 16:58:11 (GMT)
commit3b7e0cad481ca3a71f27259352ed0fd335150ba2 (patch)
treed1af74c1adbd16acc722902f96e67f61f56ad476
parent7527392f639903a42471d914528b25b13f0cde98 (diff)
downloadQt-3b7e0cad481ca3a71f27259352ed0fd335150ba2.zip
Qt-3b7e0cad481ca3a71f27259352ed0fd335150ba2.tar.gz
Qt-3b7e0cad481ca3a71f27259352ed0fd335150ba2.tar.bz2
Fix QMetaObject::indexOfSlot
The wrong offset was added
-rw-r--r--src/corelib/kernel/qmetaobject.cpp2
-rw-r--r--tests/auto/qmetaobject/tst_qmetaobject.cpp29
2 files changed, 30 insertions, 1 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 4bf4290..f0426f5 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -652,7 +652,7 @@ int QMetaObject::indexOfSlot(const char *slot) const
if (i < 0)
i = QMetaObjectPrivate::indexOfSlotRelative(&m, slot, true);
if (i >= 0)
- i += methodOffset();
+ i += m->methodOffset();
return i;
}
diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp
index d496c56..13e3bcd 100644
--- a/tests/auto/qmetaobject/tst_qmetaobject.cpp
+++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp
@@ -175,6 +175,9 @@ private slots:
void metaMethod();
+ void indexOfMethod_data();
+ void indexOfMethod();
+
signals:
void value6Changed();
void value7Changed(const QString &);
@@ -1077,5 +1080,31 @@ void tst_QMetaObject::metaMethod()
QCOMPARE(obj.slotResult, QString("sl13"));
}
+void tst_QMetaObject::indexOfMethod_data()
+{
+ QTest::addColumn<QObject *>("object");
+ QTest::addColumn<QByteArray>("name");
+ QTest::addColumn<bool>("isSignal");
+ QTest::newRow("indexOfMethod_data") << (QObject*)this << QByteArray("indexOfMethod_data()") << false;
+ QTest::newRow("deleteLater") << (QObject*)this << QByteArray("deleteLater()") << false;
+ QTest::newRow("value6changed") << (QObject*)this << QByteArray("value6Changed()") << true;
+ QTest::newRow("value7changed") << (QObject*)this << QByteArray("value7Changed(QString)") << true;
+ QTest::newRow("destroyed") << (QObject*)this << QByteArray("destroyed()") << true;
+ QTest::newRow("destroyed2") << (QObject*)this << QByteArray("destroyed(QObject*)") << true;
+}
+
+void tst_QMetaObject::indexOfMethod()
+{
+ QFETCH(QObject *, object);
+ QFETCH(QByteArray, name);
+ QFETCH(bool, isSignal);
+ int idx = object->metaObject()->indexOfMethod(name);
+ QVERIFY(idx >= 0);
+ QCOMPARE(object->metaObject()->method(idx).signature(), name.constData());
+ QCOMPARE(object->metaObject()->indexOfSlot(name), isSignal ? -1 : idx);
+ QCOMPARE(object->metaObject()->indexOfSignal(name), !isSignal ? -1 : idx);
+}
+
+
QTEST_MAIN(tst_QMetaObject)
#include "tst_qmetaobject.moc"