Showing the changes to libraries/script-engine/src/v8/ScriptObjectV8Proxy.cpp (1 of 2 files). Show all
Unified · Split
| @@ -48,7 +48,7 @@ static const void *internalPointsToQVariantProxy = (void *)0x13371000; · 47 unmodified lines | ||
| 48 | 48 | static const void *internalPointsToMethodProxy = (void *)0x13373000; |
| 49 | 49 | // This is used to pass object in ScriptVariantV8Proxy to methods of prototype object, for example passing AnimationPointer to AnimationObject |
| 50 | 50 | // Object is then converted using scriptvalue_cast for use inside the prototype |
| 51 | −static const void *internalPointsToQVariant = (void *)0x13374000; | |
| 51 | +static const void *internalPointsToQVariantInProxy = (void *)0x13374000; | |
| 52 | 52 | |
| 53 | 53 | // Used strictly to replace the "this" object value for property access. May expand to a full context element |
| 54 | 54 | // if we find it necessary to, but hopefully not needed |
| @@ -727,8 +727,9 @@ ScriptVariantV8Proxy::ScriptVariantV8Proxy(ScriptEngineV8* engine, const QVarian · 672 unmodified lines | ||
| 727 | 727 | auto variantDataTemplate = v8::ObjectTemplate::New(isolate); |
| 728 | 728 | variantDataTemplate->SetInternalFieldCount(2); |
| 729 | 729 | auto variantData = variantDataTemplate->NewInstance(engine->getContext()).ToLocalChecked(); |
| 730 | − variantData->SetAlignedPointerInInternalField(0, const_cast<void*>(internalPointsToQVariant)); | |
| 731 | − variantData->SetAlignedPointerInInternalField(1, reinterpret_cast<void*>(&_variant)); | |
| 730 | + variantData->SetAlignedPointerInInternalField(0, const_cast<void*>(internalPointsToQVariantInProxy)); | |
| 731 | + // Internal field doesn't point directly to QVariant, because then alignment would need to be guaranteed in all compilers | |
| 732 | + variantData->SetAlignedPointerInInternalField(1, reinterpret_cast<void*>(this)); | |
| 732 | 733 | _v8Object.Reset(isolate, v8::Local<v8::Object>::Cast(variantData)); |
| 733 | 734 | _name = QString::fromLatin1(variant.typeName()); |
| 734 | 735 | } |
| @@ -738,6 +739,7 @@ ScriptVariantV8Proxy::~ScriptVariantV8Proxy() { · 3 unmodified lines | ||
| 738 | 739 | v8::Locker locker(isolate); |
| 739 | 740 | v8::Isolate::Scope isolateScope(isolate); |
| 740 | 741 | v8::HandleScope handleScope(isolate); |
| 742 | + // V8TODO: Add similar deletion handling as for object proxy | |
| 741 | 743 | //_v8ObjectTemplate.Reset(); |
| 742 | 744 | _v8Object.Reset(); |
| 743 | 745 | } |
| @@ -817,10 +819,11 @@ QVariant* ScriptVariantV8Proxy::unwrapQVariantPointer(v8::Isolate* isolate, cons · 73 unmodified lines | ||
| 817 | 819 | if (v8Object->InternalFieldCount() != 2) { |
| 818 | 820 | return nullptr; |
| 819 | 821 | } |
| 820 | − if (v8Object->GetAlignedPointerFromInternalField(0) != internalPointsToQVariant) { | |
| 822 | + if (v8Object->GetAlignedPointerFromInternalField(0) != internalPointsToQVariantInProxy) { | |
| 821 | 823 | return nullptr; |
| 822 | 824 | } |
| 823 | − return reinterpret_cast<QVariant*>(v8Object->GetAlignedPointerFromInternalField(1)); | |
| 825 | + auto proxy = reinterpret_cast<ScriptVariantV8Proxy*>(v8Object->GetAlignedPointerFromInternalField(1)); | |
| 826 | + return &(proxy->_variant); | |
| 824 | 827 | } |
| 825 | 828 | |
| 826 | 829 | |