diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-07-19 14:11:20 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-07-19 18:20:02 +0000 |
commit | 877ce4d446b34375096f5e7fae30101405d7ea95 (patch) | |
tree | a4e9d992720bad2ccc1be6edc5c4880c4b4e31ce /src/qml/qml/qqmltypeloader.cpp | |
parent | ffebff97a9eee8aacce059a2a671ee634d11064c (diff) |
Add support for caching of .js files imported from QML sources
This requires only minimal changes.
Change-Id: I89e16bad97bf26669f8e4f4336ac6d32e5027c35
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/qml/qqmltypeloader.cpp')
-rw-r--r-- | src/qml/qml/qqmltypeloader.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index adeec52b74..52fed14ecb 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -2836,6 +2836,19 @@ struct EmptyCompilationUnit : public QV4::CompiledData::CompilationUnit void QQmlScriptBlob::dataReceived(const Data &data) { QV4::ExecutionEngine *v4 = QV8Engine::getV4(m_typeLoader->engine()); + + if (diskCache() && !forceDiskCacheRefresh()) { + QQmlRefPointer<QV4::CompiledData::CompilationUnit> unit = v4->iselFactory->createUnitForLoading(); + QString error; + if (unit->loadFromDisk(url(), &error)) { + initializeFromCompilationUnit(unit); + return; + } else { + qDebug() << "Error loading" << url().toString() << "from disk cache:" << error; + } + } + + QmlIR::Document irUnit(v4->debugger != 0); QString error; @@ -2869,6 +2882,13 @@ void QQmlScriptBlob::dataReceived(const Data &data) // The js unit owns the data and will free the qml unit. unit->data = unitData; + if (diskCache() || forceDiskCacheRefresh()) { + QString errorString; + if (!unit->saveToDisk(&errorString)) { + qDebug() << "Error saving cached version of" << unit->url().toString() << "to disk:" << errorString; + } + } + initializeFromCompilationUnit(unit); } |