diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-01-29 13:01:21 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2016-01-29 13:01:22 +0100 |
commit | 1e421097f08876f5e2242be6f7a20db2aeb51692 (patch) | |
tree | c45b9323368cfdede67facd43c076a85322f12f6 /src/qml/jsruntime | |
parent | f4788a13e98aa4e5438327094524d7b8239893ec (diff) | |
parent | 666bc731a0ba930ca0cfda18daf836913fd91361 (diff) |
Merge remote-tracking branch 'origin/5.6' into dev
Change-Id: Iec1b2de53c275996364c4bab0123ccb3e6e9895e
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4include.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4persistent.cpp | 21 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4persistent_p.h | 8 |
3 files changed, 26 insertions, 5 deletions
diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index 606ba07adf..29f83da522 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -189,6 +189,8 @@ QV4::ReturnedValue QV4Include::method_include(QV4::CallContext *ctx) V4THROW_ERROR("Qt.include(): Can only be called from JavaScript files"); QUrl url(scope.engine->resolvedUrl(ctx->args()[0].toQStringNoThrow())); + if (scope.engine->qmlEngine() && scope.engine->qmlEngine()->urlInterceptor()) + url = scope.engine->qmlEngine()->urlInterceptor()->intercept(url, QQmlAbstractUrlInterceptor::JavaScriptFile); QV4::ScopedValue callbackFunction(scope, QV4::Primitive::undefinedValue()); if (ctx->argc() >= 2 && ctx->args()[1].as<QV4::FunctionObject>()) diff --git a/src/qml/jsruntime/qv4persistent.cpp b/src/qml/jsruntime/qv4persistent.cpp index 2a7a9a6ee7..f6d4046ec4 100644 --- a/src/qml/jsruntime/qv4persistent.cpp +++ b/src/qml/jsruntime/qv4persistent.cpp @@ -40,6 +40,7 @@ #include "qv4persistent_p.h" #include <private/qv4mm_p.h> #include "qv4object_p.h" +#include "qv4qobjectwrapper_p.h" #include "PageAllocation.h" using namespace QV4; @@ -387,7 +388,7 @@ WeakValue &WeakValue::operator=(const WeakValue &other) WeakValue::~WeakValue() { - PersistentValueStorage::free(val); + free(); } void WeakValue::set(ExecutionEngine *engine, const Value &value) @@ -418,3 +419,21 @@ void WeakValue::markOnce(ExecutionEngine *e) val->mark(e); } +void WeakValue::free() +{ + if (!val) + return; + + ExecutionEngine *e = engine(); + if (e && val->as<QObjectWrapper>()) { + // Some QV4::QObjectWrapper Value will be freed in WeakValue::~WeakValue() before MemoryManager::sweep() is being called, + // in this case we will never have a chance to call detroyObject() on those QV4::QObjectWrapper objects. + // Here we don't free these Value immediately, instead we keep track of them to free them later in MemoryManager::sweep() + e->memoryManager->m_pendingFreedObjectWrapperValue.push_back(val); + } else { + PersistentValueStorage::free(val); + } + + val = 0; +} + diff --git a/src/qml/jsruntime/qv4persistent_p.h b/src/qml/jsruntime/qv4persistent_p.h index b8f179c9eb..5b1926468a 100644 --- a/src/qml/jsruntime/qv4persistent_p.h +++ b/src/qml/jsruntime/qv4persistent_p.h @@ -184,15 +184,15 @@ public: bool isUndefined() const { return !val || val->isUndefined(); } bool isNullOrUndefined() const { return !val || val->isNullOrUndefined(); } - void clear() { - PersistentValueStorage::free(val); - val = 0; - } + void clear() { free(); } void markOnce(ExecutionEngine *e); private: Value *val; + +private: + void free(); }; } // namespace QV4 |