summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2012-01-06 13:20:38 +1000
committerQt by Nokia <qt-info@nokia.com>2012-01-06 12:41:55 +0100
commit58dc831e557eb533bf40c9ff7b79d01d58b6de98 (patch)
tree8e51c0bd80ea091c8549fe34b9dc7f42a440b840
parente1d4fabc5d2f7ec5a2f84a6c7c76cdb054552ca6 (diff)
downloadqtscript-58dc831e557eb533bf40c9ff7b79d01d58b6de98.tar.gz
Fix QScriptEngine::ExcludeDeleteLater and metaobject-related autotests
ba635d7e74472f3a54c0c4686966af46d9035c6f in qtbase adds a signal to QObject. This breaks some code in QtScript which hardcoded the list of expected metamethods on QObject, and some other code which hardcoded the index of the deleteLater slot. Fix it. This is a minimal fix which does not address the underlying fragility. Task-number: QTBUG-23502 Change-Id: Id1269f9d8af01e12587ba8ff2fecf942a7231aff Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com> Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
-rw-r--r--src/script/bridge/qscriptqobject.cpp5
-rw-r--r--tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp12
2 files changed, 13 insertions, 4 deletions
diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp
index cee8319..6a9726a 100644
--- a/src/script/bridge/qscriptqobject.cpp
+++ b/src/script/bridge/qscriptqobject.cpp
@@ -151,8 +151,11 @@ private:
static bool hasMethodAccess(const QMetaMethod &method, int index, const QScriptEngine::QObjectWrapOptions &opt)
{
+ // FIXME: this is fragile and may break if signals/slots are added to/removed from QObject.
+ // See QTBUG-23502
+ const int deleteLaterIndex = 3;
return (method.access() != QMetaMethod::Private)
- && ((index != 2) || !(opt & QScriptEngine::ExcludeDeleteLater))
+ && ((index != deleteLaterIndex) || !(opt & QScriptEngine::ExcludeDeleteLater))
&& (!(opt & QScriptEngine::ExcludeSlots) || (method.methodType() != QMetaMethod::Slot));
}
diff --git a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
index 740d5a6..76acee6 100644
--- a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
+++ b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
@@ -2871,8 +2871,10 @@ void tst_QScriptExtQObject::enumerate_data()
<< "p1" << "p2" << "p4" << "p6"
// dynamic properties
<< "dp1" << "dp2" << "dp3"
- // inherited slots
+ // inherited signals
<< "destroyed(QObject*)" << "destroyed()"
+ << "objectNameChanged(QString)"
+ // inherited slots
<< "deleteLater()"
// not included because it's private:
// << "_q_reregisterTimers(void*)"
@@ -2889,8 +2891,10 @@ void tst_QScriptExtQObject::enumerate_data()
<< "p1" << "p2" << "p4" << "p6"
// dynamic properties
<< "dp1" << "dp2" << "dp3"
- // inherited slots
+ // inherited signals
<< "destroyed(QObject*)" << "destroyed()"
+ << "objectNameChanged(QString)"
+ // inherited slots
<< "deleteLater()"
// not included because it's private:
// << "_q_reregisterTimers(void*)"
@@ -2970,8 +2974,9 @@ void tst_QScriptExtQObject::enumerate_data()
<< "p1" << "p2" << "p4" << "p6"
// dynamic properties
<< "dp1" << "dp2" << "dp3"
- // inherited slots
+ // inherited signals
<< "destroyed(QObject*)" << "destroyed()"
+ << "objectNameChanged(QString)"
// not included because it's private:
// << "_q_reregisterTimers(void*)"
// signals
@@ -2991,6 +2996,7 @@ void tst_QScriptExtQObject::enumerate_data()
<< "dp1" << "dp2" << "dp3"
// inherited signals
<< "destroyed(QObject*)" << "destroyed()"
+ << "objectNameChanged(QString)"
// signals
<< "mySignal()");
}