mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 17:38:34 +02:00
Fixed crash with Cameras app
This commit is contained in:
parent
8a2c055adc
commit
e75c671a70
2 changed files with 10 additions and 7 deletions
|
@ -116,9 +116,9 @@ const QString POINT_REF_JOINT_NAME = "RightShoulder";
|
||||||
const float POINT_ALPHA_BLENDING = 1.0f;
|
const float POINT_ALPHA_BLENDING = 1.0f;
|
||||||
|
|
||||||
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager){
|
STATIC_SCRIPT_TYPES_INITIALIZER(+[](ScriptManager* manager){
|
||||||
auto scriptEngine = manager->engine().get();
|
auto scriptEngine = manager->engine();
|
||||||
|
|
||||||
registerMetaTypes(scriptEngine);
|
MyAvatar::registerMetaTypes(scriptEngine);
|
||||||
});
|
});
|
||||||
|
|
||||||
STATIC_SCRIPT_INITIALIZER(+[](ScriptManager* manager){
|
STATIC_SCRIPT_INITIALIZER(+[](ScriptManager* manager){
|
||||||
|
|
|
@ -48,7 +48,7 @@ static const void *internalPointsToQVariantProxy = (void *)0x13371000;
|
||||||
static const void *internalPointsToMethodProxy = (void *)0x13373000;
|
static const void *internalPointsToMethodProxy = (void *)0x13373000;
|
||||||
// This is used to pass object in ScriptVariantV8Proxy to methods of prototype object, for example passing AnimationPointer to AnimationObject
|
// This is used to pass object in ScriptVariantV8Proxy to methods of prototype object, for example passing AnimationPointer to AnimationObject
|
||||||
// Object is then converted using scriptvalue_cast for use inside the prototype
|
// Object is then converted using scriptvalue_cast for use inside the prototype
|
||||||
static const void *internalPointsToQVariant = (void *)0x13374000;
|
static const void *internalPointsToQVariantInProxy = (void *)0x13374000;
|
||||||
|
|
||||||
// Used strictly to replace the "this" object value for property access. May expand to a full context element
|
// Used strictly to replace the "this" object value for property access. May expand to a full context element
|
||||||
// if we find it necessary to, but hopefully not needed
|
// if we find it necessary to, but hopefully not needed
|
||||||
|
@ -727,8 +727,9 @@ ScriptVariantV8Proxy::ScriptVariantV8Proxy(ScriptEngineV8* engine, const QVarian
|
||||||
auto variantDataTemplate = v8::ObjectTemplate::New(isolate);
|
auto variantDataTemplate = v8::ObjectTemplate::New(isolate);
|
||||||
variantDataTemplate->SetInternalFieldCount(2);
|
variantDataTemplate->SetInternalFieldCount(2);
|
||||||
auto variantData = variantDataTemplate->NewInstance(engine->getContext()).ToLocalChecked();
|
auto variantData = variantDataTemplate->NewInstance(engine->getContext()).ToLocalChecked();
|
||||||
variantData->SetAlignedPointerInInternalField(0, const_cast<void*>(internalPointsToQVariant));
|
variantData->SetAlignedPointerInInternalField(0, const_cast<void*>(internalPointsToQVariantInProxy));
|
||||||
variantData->SetAlignedPointerInInternalField(1, reinterpret_cast<void*>(&_variant));
|
// Internal field doesn't point directly to QVariant, because then alignment would need to be guaranteed in all compilers
|
||||||
|
variantData->SetAlignedPointerInInternalField(1, reinterpret_cast<void*>(this));
|
||||||
_v8Object.Reset(isolate, v8::Local<v8::Object>::Cast(variantData));
|
_v8Object.Reset(isolate, v8::Local<v8::Object>::Cast(variantData));
|
||||||
_name = QString::fromLatin1(variant.typeName());
|
_name = QString::fromLatin1(variant.typeName());
|
||||||
}
|
}
|
||||||
|
@ -738,6 +739,7 @@ ScriptVariantV8Proxy::~ScriptVariantV8Proxy() {
|
||||||
v8::Locker locker(isolate);
|
v8::Locker locker(isolate);
|
||||||
v8::Isolate::Scope isolateScope(isolate);
|
v8::Isolate::Scope isolateScope(isolate);
|
||||||
v8::HandleScope handleScope(isolate);
|
v8::HandleScope handleScope(isolate);
|
||||||
|
// V8TODO: Add similar deletion handling as for object proxy
|
||||||
//_v8ObjectTemplate.Reset();
|
//_v8ObjectTemplate.Reset();
|
||||||
_v8Object.Reset();
|
_v8Object.Reset();
|
||||||
}
|
}
|
||||||
|
@ -817,10 +819,11 @@ QVariant* ScriptVariantV8Proxy::unwrapQVariantPointer(v8::Isolate* isolate, cons
|
||||||
if (v8Object->InternalFieldCount() != 2) {
|
if (v8Object->InternalFieldCount() != 2) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (v8Object->GetAlignedPointerFromInternalField(0) != internalPointsToQVariant) {
|
if (v8Object->GetAlignedPointerFromInternalField(0) != internalPointsToQVariantInProxy) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return reinterpret_cast<QVariant*>(v8Object->GetAlignedPointerFromInternalField(1));
|
auto proxy = reinterpret_cast<ScriptVariantV8Proxy*>(v8Object->GetAlignedPointerFromInternalField(1));
|
||||||
|
return &(proxy->_variant);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue