aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4persistent_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/jsruntime/qv4persistent_p.h')
-rw-r--r--src/qml/jsruntime/qv4persistent_p.h25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4persistent_p.h b/src/qml/jsruntime/qv4persistent_p.h
index a0ade2068f..c1cd1f34df 100644
--- a/src/qml/jsruntime/qv4persistent_p.h
+++ b/src/qml/jsruntime/qv4persistent_p.h
@@ -154,9 +154,26 @@ public:
WeakValue &operator=(const WeakValue &other);
~WeakValue();
- void set(ExecutionEngine *engine, const Value &value);
- void set(ExecutionEngine *engine, ReturnedValue value);
- void set(ExecutionEngine *engine, Heap::Base *obj);
+ void set(ExecutionEngine *engine, const Value &value)
+ {
+ if (!val)
+ allocVal(engine);
+ *val = value;
+ }
+
+ void set(ExecutionEngine *engine, ReturnedValue value)
+ {
+ if (!val)
+ allocVal(engine);
+ *val = value;
+ }
+
+ void set(ExecutionEngine *engine, Heap::Base *obj)
+ {
+ if (!val)
+ allocVal(engine);
+ *val = obj;
+ }
ReturnedValue value() const {
return (val ? val->asReturnedValue() : Encode::undefined());
@@ -192,6 +209,8 @@ private:
Value *val;
private:
+ Q_NEVER_INLINE void allocVal(ExecutionEngine *engine);
+
void free();
};