summaryrefslogtreecommitdiff
path: root/fxjs/cfx_v8.h
diff options
context:
space:
mode:
Diffstat (limited to 'fxjs/cfx_v8.h')
-rw-r--r--fxjs/cfx_v8.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/fxjs/cfx_v8.h b/fxjs/cfx_v8.h
index 08a18935ea..04468d5281 100644
--- a/fxjs/cfx_v8.h
+++ b/fxjs/cfx_v8.h
@@ -20,7 +20,7 @@ class CFX_V8 {
explicit CFX_V8(v8::Isolate* pIsolate);
virtual ~CFX_V8();
- v8::Isolate* GetIsolate() const { return m_isolate; }
+ v8::Isolate* GetIsolate() const { return m_pIsolate.Get(); }
v8::Local<v8::Value> NewNull();
v8::Local<v8::Value> NewUndefined();
@@ -59,10 +59,11 @@ class CFX_V8 {
v8::Local<v8::Value> pValue);
protected:
- void SetIsolate(v8::Isolate* pIsolate) { m_isolate = pIsolate; }
+ void SetIsolate(v8::Isolate* pIsolate) { m_pIsolate = pIsolate; }
+ void DisposeIsolate();
private:
- v8::Isolate* m_isolate;
+ UnownedPtr<v8::Isolate> m_pIsolate;
};
class CFX_V8ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
@@ -72,4 +73,9 @@ class CFX_V8ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
void Free(void* data, size_t length) override;
};
+// Use with std::unique_ptr<v8::Isolate> to dispose of isolates correctly.
+struct CFX_V8IsolateDeleter {
+ inline void operator()(v8::Isolate* ptr) { ptr->Dispose(); }
+};
+
#endif // FXJS_CFX_V8_H_