diff options
Diffstat (limited to 'src/qml/jsruntime/qv4persistent.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4persistent.cpp | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/src/qml/jsruntime/qv4persistent.cpp b/src/qml/jsruntime/qv4persistent.cpp index a892194df3..987c322e47 100644 --- a/src/qml/jsruntime/qv4persistent.cpp +++ b/src/qml/jsruntime/qv4persistent.cpp @@ -358,14 +358,14 @@ WeakValue::WeakValue(const WeakValue &other) : val(0) { if (other.val) { - val = other.engine()->memoryManager->m_weakValues->allocate(); + allocVal(other.engine()); *val = *other.val; } } WeakValue::WeakValue(ExecutionEngine *engine, const Value &value) { - val = engine->memoryManager->m_weakValues->allocate(); + allocVal(engine); *val = value; } @@ -374,7 +374,7 @@ WeakValue &WeakValue::operator=(const WeakValue &other) if (!val) { if (!other.val) return *this; - val = other.engine()->memoryManager->m_weakValues->allocate(); + allocVal(other.engine()); } Q_ASSERT(engine() == other.engine()); @@ -388,25 +388,9 @@ WeakValue::~WeakValue() free(); } -void WeakValue::set(ExecutionEngine *engine, const Value &value) -{ - if (!val) - val = engine->memoryManager->m_weakValues->allocate(); - *val = value; -} - -void WeakValue::set(ExecutionEngine *engine, ReturnedValue value) -{ - if (!val) - val = engine->memoryManager->m_weakValues->allocate(); - *val = value; -} - -void WeakValue::set(ExecutionEngine *engine, Heap::Base *obj) +void WeakValue::allocVal(ExecutionEngine *engine) { - if (!val) - val = engine->memoryManager->m_weakValues->allocate(); - *val = obj; + val = engine->memoryManager->m_weakValues->allocate(); } void WeakValue::markOnce(ExecutionEngine *e) |