aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-07-02 09:58:13 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-07-02 10:32:33 +0200
commit41e924eb6e1c690bc81d095fc5e8f57244aae964 (patch)
treeb459dfa150530443901be68471df88c69ca7a7d4 /src/qml/qml
parentd51afdb74fdcb9a5c7e1fdaa763325c78d794d06 (diff)
parent87a5889029aed8c53a4b02a42804d036614db36b (diff)
Merge remote-tracking branch 'origin/5.3' into dev
Conflicts: .qmake.conf examples/quick/scenegraph/openglunderqml/squircle.h src/quick/doc/src/qmltypereference.qdoc src/quick/scenegraph/qsgthreadedrenderloop.cpp Change-Id: Ife4f4b897044a7ffcd0710493c6aed1d87cf1ef9
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlcomponent.cpp6
-rw-r--r--src/qml/qml/qqmlcomponent_p.h6
-rw-r--r--src/qml/qml/qqmlengine.cpp9
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp26
-rw-r--r--src/qml/qml/qqmlobjectcreator_p.h18
5 files changed, 45 insertions, 20 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index c247c7f5a6..d44b918abe 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -150,7 +150,7 @@ V8_DEFINE_EXTENSION(QQmlComponentExtension, componentExtension);
// QQmlEngine *engine = qmlContext(this)->engine();
QQmlComponent component(engine, QUrl::fromLocalFile("MyItem.qml"));
QQuickItem *childItem = qobject_cast<QQuickItem*>(component.create());
- childItem->setParent(this);
+ childItem->setParentItem(this);
}
\endcode
@@ -880,7 +880,7 @@ QQmlComponentPrivate::beginCreate(QQmlContextData *context)
enginePriv->referenceScarceResources();
QObject *rv = 0;
- state.creator = new QQmlObjectCreator(context, cc, creationContext);
+ state.creator.reset(new QQmlObjectCreator(context, cc, creationContext));
rv = state.creator->create(start);
if (!rv)
state.errors = state.creator->errors;
@@ -920,7 +920,7 @@ void QQmlComponentPrivate::beginDeferred(QQmlEnginePrivate *enginePriv,
Q_ASSERT(ddata->deferredData);
QQmlData::DeferredData *deferredData = ddata->deferredData;
QQmlContextData *creationContext = 0;
- state->creator = new QQmlObjectCreator(deferredData->context->parent, deferredData->compiledData, creationContext);
+ state->creator.reset(new QQmlObjectCreator(deferredData->context->parent, deferredData->compiledData, creationContext));
if (!state->creator->populateDeferredProperties(object))
state->errors << state->creator->errors;
}
diff --git a/src/qml/qml/qqmlcomponent_p.h b/src/qml/qml/qqmlcomponent_p.h
index e8ae540148..2c70d7b100 100644
--- a/src/qml/qml/qqmlcomponent_p.h
+++ b/src/qml/qml/qqmlcomponent_p.h
@@ -106,15 +106,13 @@ public:
struct ConstructionState {
ConstructionState()
- : creator(0)
- , completePending(false)
+ : completePending(false)
{}
~ConstructionState()
{
- delete creator;
}
- QQmlObjectCreator *creator;
+ QScopedPointer<QQmlObjectCreator> creator;
QList<QQmlError> errors;
bool completePending;
};
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 61246b92d8..17e5c55efb 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -2306,20 +2306,17 @@ static inline QString shellNormalizeFileName(const QString &name)
// The correct declaration of the SHGetPathFromIDList symbol is
// being used in mingw-w64 as of r6215, which is a v3 snapshot.
#if defined(Q_CC_MINGW) && (!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 3)
- ITEMIDLIST file;
- if (FAILED(SHParseDisplayName(nameC, NULL, &file, 0, NULL)))
- return name;
- TCHAR buffer[MAX_PATH];
- if (!SHGetPathFromIDList(&file, buffer))
+ ITEMIDLIST *file;
+ if (FAILED(SHParseDisplayName(nameC, NULL, reinterpret_cast<LPITEMIDLIST>(&file), 0, NULL)))
return name;
#else
PIDLIST_ABSOLUTE file;
if (FAILED(SHParseDisplayName(nameC, NULL, &file, 0, NULL)))
return name;
+#endif
TCHAR buffer[MAX_PATH];
if (!SHGetPathFromIDList(file, buffer))
return name;
-#endif
QString canonicalName = QString::fromWCharArray(buffer);
// Upper case drive letter
if (canonicalName.size() > 2 && canonicalName.at(1) == QLatin1Char(':'))
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 5eaea7d9f4..8fae12326f 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -91,7 +91,7 @@ QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QQmlCompile
init(parentContext);
sharedState = new QQmlObjectCreatorSharedState;
- sharedState.setFlag(); // We own it, so we must delete it
+ topLevelCreator = true;
sharedState->componentAttached = 0;
sharedState->allCreatedBindings.allocate(compiledData->totalBindingsCount);
sharedState->allParserStatusCallbacks.allocate(compiledData->totalParserStatusCount);
@@ -115,6 +115,7 @@ QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QQmlCompile
init(parentContext);
sharedState = inheritedSharedState;
+ topLevelCreator = false;
}
void QQmlObjectCreator::init(QQmlContextData *providedParentContext)
@@ -139,9 +140,9 @@ void QQmlObjectCreator::init(QQmlContextData *providedParentContext)
QQmlObjectCreator::~QQmlObjectCreator()
{
- if (sharedState.flag()) {
+ if (topLevelCreator) {
{
- QRecursionWatcher<QQmlObjectCreatorSharedState, &QQmlObjectCreatorSharedState::recursionNode> watcher(sharedState.data());
+ QQmlObjectCreatorRecursionWatcher watcher(this);
}
for (int i = 0; i < sharedState->allCreatedBindings.count(); ++i) {
QQmlAbstractBinding *b = sharedState->allCreatedBindings.at(i);
@@ -153,7 +154,10 @@ QQmlObjectCreator::~QQmlObjectCreator()
if (ps)
ps->d = 0;
}
- delete sharedState.data();
+ while (sharedState->componentAttached) {
+ QQmlComponentAttached *a = sharedState->componentAttached;
+ a->rem();
+ }
}
}
@@ -1177,7 +1181,7 @@ QQmlContextData *QQmlObjectCreator::finalize(QQmlInstantiationInterrupt &interru
Q_ASSERT(phase == ObjectsCreated || phase == Finalizing);
phase = Finalizing;
- QRecursionWatcher<QQmlObjectCreatorSharedState, &QQmlObjectCreatorSharedState::recursionNode> watcher(sharedState.data());
+ QQmlObjectCreatorRecursionWatcher watcher(this);
ActiveOCRestorer ocRestorer(this, QQmlEnginePrivate::get(engine));
{
@@ -1262,6 +1266,11 @@ void QQmlObjectCreator::clear()
while (!sharedState->allCreatedObjects.isEmpty())
delete sharedState->allCreatedObjects.pop();
+ while (sharedState->componentAttached) {
+ QQmlComponentAttached *a = sharedState->componentAttached;
+ a->rem();
+ }
+
phase = Done;
}
@@ -1334,3 +1343,10 @@ bool QQmlObjectCreator::populateInstance(int index, QObject *instance, QObject *
}
+
+
+QQmlObjectCreatorRecursionWatcher::QQmlObjectCreatorRecursionWatcher(QQmlObjectCreator *creator)
+ : sharedState(creator->sharedState)
+ , watcher(creator->sharedState.data())
+{
+}
diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h
index 379a3b2970..ad2d67624f 100644
--- a/src/qml/qml/qqmlobjectcreator_p.h
+++ b/src/qml/qml/qqmlobjectcreator_p.h
@@ -57,7 +57,7 @@ struct QQmlTypeCompiler;
class QQmlInstantiationInterrupt;
struct QQmlVmeProfiler;
-struct QQmlObjectCreatorSharedState
+struct QQmlObjectCreatorSharedState : public QSharedData
{
QQmlContextData *rootContext;
QQmlContextData *creationContext;
@@ -128,7 +128,8 @@ private:
const QVector<QQmlPropertyCache *> &propertyCaches;
const QVector<QByteArray> &vmeMetaObjectData;
QHash<int, int> objectIndexToId;
- QFlagPointer<QQmlObjectCreatorSharedState> sharedState;
+ QExplicitlySharedDataPointer<QQmlObjectCreatorSharedState> sharedState;
+ bool topLevelCreator;
void *activeVMEDataForRootContext;
QObject *_qobject;
@@ -142,6 +143,19 @@ private:
QQmlVMEMetaObject *_vmeMetaObject;
QQmlListProperty<void> _currentList;
QV4::ExecutionContext *_qmlContext;
+
+ friend struct QQmlObjectCreatorRecursionWatcher;
+};
+
+struct QQmlObjectCreatorRecursionWatcher
+{
+ QQmlObjectCreatorRecursionWatcher(QQmlObjectCreator *creator);
+
+ bool hasRecursed() const { return watcher.hasRecursed(); }
+
+private:
+ QExplicitlySharedDataPointer<QQmlObjectCreatorSharedState> sharedState;
+ QRecursionWatcher<QQmlObjectCreatorSharedState, &QQmlObjectCreatorSharedState::recursionNode> watcher;
};
QT_END_NAMESPACE