History

Fixed crash with Cameras app

ksuprynowicz committed 3 years ago

Commit e75c6711 parent 8a2c0552 files · +10 −7Browse files

Showing the changes to libraries/script-engine/src/v8/ScriptObjectV8Proxy.cpp (1 of 2 files). Show all

Unified · Split

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