aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativecompileddata.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2011-09-05 17:31:41 +1000
committerQt by Nokia <qt-info@nokia.com>2011-09-29 06:12:49 +0200
commit703c808a5649169dd6b9605af273374cd62951d1 (patch)
tree7248cc72bfa632a51c814d6622f0b12a7f2bd443 /src/declarative/qml/qdeclarativecompileddata.cpp
parent600e56ad053362dd5d4150f5dec6b93c2fee575b (diff)
Asynchronous component instantiation
This introduces two main: * the QML compiler executes in a separate thread * item instantiation can be interrupted and resumed to allow it to be split across multiple frames. Task-number: QTBUG-21151 Change-Id: I9631c62bb77da3a2e0c37f0da3719533fdce4fef Reviewed-on: http://codereview.qt-project.org/5676 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/declarative/qml/qdeclarativecompileddata.cpp')
-rw-r--r--src/declarative/qml/qdeclarativecompileddata.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/declarative/qml/qdeclarativecompileddata.cpp b/src/declarative/qml/qdeclarativecompileddata.cpp
index a1bdca26fa..6815967f57 100644
--- a/src/declarative/qml/qdeclarativecompileddata.cpp
+++ b/src/declarative/qml/qdeclarativecompileddata.cpp
@@ -101,13 +101,25 @@ int QDeclarativeCompiledData::indexForUrl(const QUrl &data)
}
QDeclarativeCompiledData::QDeclarativeCompiledData(QDeclarativeEngine *engine)
-: QDeclarativeCleanup(engine), importCache(0), root(0), rootPropertyCache(0)
+: engine(engine), importCache(0), root(0), rootPropertyCache(0)
{
+ Q_ASSERT(engine);
+
bytecode.reserve(1024);
}
+void QDeclarativeCompiledData::destroy()
+{
+ if (engine && hasEngine())
+ QDeclarativeEnginePrivate::deleteInEngineThread(engine, this);
+ else
+ delete this;
+}
+
QDeclarativeCompiledData::~QDeclarativeCompiledData()
{
+ clear();
+
for (int ii = 0; ii < types.count(); ++ii) {
if (types.at(ii).component)
types.at(ii).component->release();
@@ -129,18 +141,13 @@ QDeclarativeCompiledData::~QDeclarativeCompiledData()
if (rootPropertyCache)
rootPropertyCache->release();
-
- qDeleteAll(cachedClosures);
-
- for (int ii = 0; ii < v8bindings.count(); ++ii)
- qPersistentDispose(v8bindings[ii]);
}
void QDeclarativeCompiledData::clear()
{
- qDeleteAll(cachedClosures);
- for (int ii = 0; ii < cachedClosures.count(); ++ii)
- cachedClosures[ii] = 0;
+ for (int ii = 0; ii < v8bindings.count(); ++ii)
+ qPersistentDispose(v8bindings[ii]);
+ v8bindings.clear();
}
const QMetaObject *QDeclarativeCompiledData::TypeReference::metaObject() const
@@ -246,4 +253,10 @@ QDeclarativeInstruction::Type QDeclarativeCompiledData::instructionType(const QD
#endif
}
+void QDeclarativeCompiledData::initialize(QDeclarativeEngine *engine)
+{
+ Q_ASSERT(!hasEngine());
+ QDeclarativeCleanup::addToEngine(engine);
+}
+
QT_END_NAMESPACE