diff options
author | Simon Hausmann <[email protected]> | 2014-06-24 12:05:35 +0200 |
---|---|---|
committer | Simon Hausmann <[email protected]> | 2014-06-24 16:48:18 +0200 |
commit | cf93acbee66db96a6f7fab8607432b70ec5c0437 (patch) | |
tree | c99629d115d1dd54022c6827ff666b77e621864d /src/qml/jsruntime | |
parent | 745a71196c8893a35a80a679674bee396606f79b (diff) |
Exclude private methods and QObject::deleteLater from enumerable properties
This is a regression from Qt 5.1/5.0 introduced with 5.2. Private slots/methods
such as QObject::_q_reRegisterTimers() as well as QObject::deleteLater() are
not suitable for calls from JavaScript. deleteLater() in particular is covered
by the destroy() replacement slot.
Task-number: QTBUG-39744
Change-Id: I9b25f3c0d4095ba8e2e8e5ee47e37903b5def1f9
Reviewed-by: Michael Brasser <[email protected]>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index a02424a3dc..37956825f8 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -710,6 +710,11 @@ PropertyAttributes QObjectWrapper::query(const Managed *m, StringRef name) void QObjectWrapper::advanceIterator(Managed *m, ObjectIterator *it, StringRef name, uint *index, Property *p, PropertyAttributes *attributes) { + // Used to block access to QObject::destroyed() and QObject::deleteLater() from QML + static const int destroyedIdx1 = QObject::staticMetaObject.indexOfSignal("destroyed(QObject*)"); + static const int destroyedIdx2 = QObject::staticMetaObject.indexOfSignal("destroyed()"); + static const int deleteLaterIdx = QObject::staticMetaObject.indexOfSlot("deleteLater()"); + name = (String *)0; *index = UINT_MAX; @@ -726,9 +731,13 @@ void QObjectWrapper::advanceIterator(Managed *m, ObjectIterator *it, StringRef n return; } const int methodCount = mo->methodCount(); - if (it->arrayIndex < static_cast<uint>(propertyCount + methodCount)) { - name = that->engine()->newString(QString::fromUtf8(mo->method(it->arrayIndex - propertyCount).name())); + while (it->arrayIndex < static_cast<uint>(propertyCount + methodCount)) { + const int index = it->arrayIndex - propertyCount; + const QMetaMethod method = mo->method(index); ++it->arrayIndex; + if (method.access() == QMetaMethod::Private || index == deleteLaterIdx || index == destroyedIdx1 || index == destroyedIdx2) + continue; + name = that->engine()->newString(QString::fromUtf8(method.name())); *attributes = QV4::Attr_Data; p->value = that->get(name); return; |