aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmltypeloader.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2016-07-19 10:13:26 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2016-07-19 18:19:46 +0000
commit6a1667bc4e6d1074f547434d714cd47ed8ebfc41 (patch)
tree84285121878205ec1f5a2c2f5ddff3a20c1fc27f /src/qml/qml/qqmltypeloader.cpp
parente0e50532d29d02c8bcbab01dbfb72377102eaf8f (diff)
Improve robustness of qml cache expiry checking
Instead of relying on two time stamps in the file system (source file and cache file), make the determination on whether the source file is newer than the cache solely depend on the time stamp of only the source file. This means that when cache files are stored in archives for example their modification date does not need to be preserved upon extraction. Change-Id: I0b4362663868c6fb9bd7e106028161b2d67274d4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/qml/qqmltypeloader.cpp')
-rw-r--r--src/qml/qml/qqmltypeloader.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 8deb41c505..adeec52b74 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -2305,14 +2305,16 @@ void QQmlTypeData::dataReceived(const Data &data)
if (tryLoadFromDiskCache())
return;
+ qint64 sourceTimeStamp;
QString error;
- QString code = QString::fromUtf8(data.readAll(&error));
+ QString code = QString::fromUtf8(data.readAll(&error, &sourceTimeStamp));
if (!error.isEmpty()) {
setError(error);
return;
}
QQmlEngine *qmlEngine = typeLoader()->engine();
m_document.reset(new QmlIR::Document(QV8Engine::getV4(qmlEngine)->debugger != 0));
+ m_document->jsModule.sourceTimeStamp = sourceTimeStamp;
QmlIR::IRBuilder compiler(QV8Engine::get(qmlEngine)->illegalNames());
if (!compiler.generateFromQml(code, finalUrlString(), m_document.data())) {
QList<QQmlError> errors;
@@ -2833,15 +2835,16 @@ struct EmptyCompilationUnit : public QV4::CompiledData::CompilationUnit
void QQmlScriptBlob::dataReceived(const Data &data)
{
+ QV4::ExecutionEngine *v4 = QV8Engine::getV4(m_typeLoader->engine());
+ QmlIR::Document irUnit(v4->debugger != 0);
+
QString error;
- QString source = QString::fromUtf8(data.readAll(&error));
+ QString source = QString::fromUtf8(data.readAll(&error, &irUnit.jsModule.sourceTimeStamp));
if (!error.isEmpty()) {
setError(error);
return;
}
- QV4::ExecutionEngine *v4 = QV8Engine::getV4(m_typeLoader->engine());
- QmlIR::Document irUnit(v4->debugger != 0);
QmlIR::ScriptDirectivesCollector collector(&irUnit.jsParserEngine, &irUnit.jsGenerator);
QList<QQmlError> errors;
@@ -3006,11 +3009,13 @@ void QQmlQmldirData::initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *
Q_UNIMPLEMENTED();
}
-QByteArray QQmlDataBlob::Data::readAll(QString *error) const
+QByteArray QQmlDataBlob::Data::readAll(QString *error, qint64 *sourceTimeStamp) const
{
Q_ASSERT(!d.isNull());
error->clear();
if (d.isT1()) {
+ if (sourceTimeStamp)
+ *sourceTimeStamp = 0;
return *d.asT1();
}
QFile f(*d.asT2());
@@ -3018,6 +3023,8 @@ QByteArray QQmlDataBlob::Data::readAll(QString *error) const
*error = f.errorString();
return QByteArray();
}
+ if (sourceTimeStamp)
+ *sourceTimeStamp = QFileInfo(f).lastModified().toMSecsSinceEpoch();
QByteArray data(f.size(), Qt::Uninitialized);
if (f.read(data.data(), data.length()) != data.length()) {
*error = f.errorString();