summaryrefslogtreecommitdiff
path: root/src/libs/qmljs/qmljsinterpreter.cpp
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2011-09-26 15:07:12 +0200
committerChristian Kamm <christian.d.kamm@nokia.com>2011-09-27 08:30:28 +0200
commitc7d8462bf8919fa887d264adcccdf1e38eb6422c (patch)
tree98d199c4da25cd7c75490459698df5d4f61791dc /src/libs/qmljs/qmljsinterpreter.cpp
parent5daf6705acfdf8e7def76b772d31794fcb1fc040 (diff)
downloadqt-creator-c7d8462bf8919fa887d264adcccdf1e38eb6422c.tar.gz
QmlJS: Fix threading issue in QmlObjectValue.
Still need to get rid of the lock in ValueOwner::registerValue. Change-Id: If9bbc548de54edf52805906aaaf730f5c66573dd Reviewed-on: http://codereview.qt-project.org/5542 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
Diffstat (limited to 'src/libs/qmljs/qmljsinterpreter.cpp')
-rw-r--r--src/libs/qmljs/qmljsinterpreter.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/libs/qmljs/qmljsinterpreter.cpp b/src/libs/qmljs/qmljsinterpreter.cpp
index 94518dbde9..3c57475f67 100644
--- a/src/libs/qmljs/qmljsinterpreter.cpp
+++ b/src/libs/qmljs/qmljsinterpreter.cpp
@@ -182,17 +182,6 @@ QmlObjectValue::QmlObjectValue(FakeMetaObject::ConstPtr metaObject, const QStrin
QmlObjectValue::~QmlObjectValue()
{}
-const Value *QmlObjectValue::findOrCreateSignature(int index, const FakeMetaMethod &method, QString *methodName) const
-{
- *methodName = method.methodName();
- const Value *value = _metaSignature.value(index);
- if (! value) {
- value = new MetaFunction(method, valueOwner());
- _metaSignature.insert(index, value);
- }
- return value;
-}
-
void QmlObjectValue::processMembers(MemberProcessor *processor) const
{
// process the meta enums
@@ -207,6 +196,19 @@ void QmlObjectValue::processMembers(MemberProcessor *processor) const
// all explicitly defined signal names
QSet<QString> explicitSignals;
+ // make MetaFunction instances lazily when first needed
+ QList<const Value *> *signatures = _metaSignatures;
+ if (!signatures) {
+ signatures = new QList<const Value *>;
+ signatures->reserve(_metaObject->methodCount());
+ for (int index = 0; index < _metaObject->methodCount(); ++index)
+ signatures->append(new MetaFunction(_metaObject->method(index), valueOwner()));
+ if (!_metaSignatures.testAndSetOrdered(0, signatures)) {
+ delete signatures;
+ signatures = _metaSignatures;
+ }
+ }
+
// process the meta methods
for (int index = 0; index < _metaObject->methodCount(); ++index) {
const FakeMetaMethod method = _metaObject->method(index);
@@ -214,7 +216,7 @@ void QmlObjectValue::processMembers(MemberProcessor *processor) const
continue;
QString methodName;
- const Value *signature = findOrCreateSignature(index, method, &methodName);
+ const Value *signature = signatures->at(index);
if (method.methodType() == FakeMetaMethod::Slot && method.access() == FakeMetaMethod::Public) {
processor->processSlot(methodName, signature);