History

Fixed object deletion event, temporarily disabled watchdog log commands to make reading logs easier

ksuprynowicz committed 3 years ago

Commit 6301d231 parent 0d454eb6 files · +35 −23Browse files

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

Unified · Split

libraries/script-engine/src/v8/ScriptObjectV8Proxy.cpp+11−7
@@ -114,7 +114,7 @@ V8ScriptValue ScriptObjectV8Proxy::newQObject(ScriptEngineV8* engine, QObject* o · 113 unmodified lines
114 return V8ScriptValue(engine->getIsolate(), proxy.get()->toV8Value());114 return V8ScriptValue(engine->getIsolate(), proxy.get()->toV8Value());
115 }115 }
116 }116 }
117 // V8TODO add a V8 callback that removes pointer from the map so that it gets deleted117 // V8TODO add a V8 callback that removes pointer for the script engine owned ob from the map so that it gets deleted
118 // register the wrapper with the engine and make sure it cleans itself up118 // register the wrapper with the engine and make sure it cleans itself up
119 engine->_qobjectWrapperMap.insert(object, proxy);119 engine->_qobjectWrapperMap.insert(object, proxy);
120 engine->_qobjectWrapperMapV8.insert(object, proxy);120 engine->_qobjectWrapperMapV8.insert(object, proxy);
@@ -126,6 +126,10 @@ V8ScriptValue ScriptObjectV8Proxy::newQObject(ScriptEngineV8* engine, QObject* o · 5 unmodified lines
126 if (lookup != enginePtr->_qobjectWrapperMap.end()) {126 if (lookup != enginePtr->_qobjectWrapperMap.end()) {
127 enginePtr->_qobjectWrapperMap.erase(lookup);127 enginePtr->_qobjectWrapperMap.erase(lookup);
128 }128 }
129 auto lookupV8 = enginePtr->_qobjectWrapperMapV8.find(object);
130 if (lookupV8 != enginePtr->_qobjectWrapperMapV8.end()) {
131 enginePtr->_qobjectWrapperMapV8.erase(lookupV8);
132 }
129 });133 });
130 }134 }
131 135
@@ -138,7 +142,7 @@ ScriptObjectV8Proxy* ScriptObjectV8Proxy::unwrapProxy(const V8ScriptValue& val) · 6 unmodified lines
138 v8::HandleScope handleScope(const_cast<v8::Isolate*>(val.constGetIsolate()));142 v8::HandleScope handleScope(const_cast<v8::Isolate*>(val.constGetIsolate()));
139 auto v8Value = val.constGet();143 auto v8Value = val.constGet();
140 if (!v8Value->IsObject()) {144 if (!v8Value->IsObject()) {
141 qDebug(scriptengine) << "Cannot unwrap proxy - value is not an object";145 //qDebug(scriptengine) << "Cannot unwrap proxy - value is not an object";
142 return nullptr;146 return nullptr;
143 }147 }
144 v8::Local<v8::Object> v8Object = v8::Local<v8::Object>::Cast(v8Value);148 v8::Local<v8::Object> v8Object = v8::Local<v8::Object>::Cast(v8Value);
@@ -159,7 +163,7 @@ QObject* ScriptObjectV8Proxy::unwrap(const V8ScriptValue& val) { · 14 unmodified lines
159}163}
160 164
161ScriptObjectV8Proxy::~ScriptObjectV8Proxy() {165ScriptObjectV8Proxy::~ScriptObjectV8Proxy() {
162 qDebug(scriptengine) << "Deleting object proxy: " << name();166 if(_object) qDebug(scriptengine) << "Deleting object proxy: " << name();
163 if (_ownsObject) {167 if (_ownsObject) {
164 QObject* qobject = _object;168 QObject* qobject = _object;
165 if(qobject) qobject->deleteLater();169 if(qobject) qobject->deleteLater();
@@ -180,7 +184,7 @@ void ScriptObjectV8Proxy::investigate() { · 14 unmodified lines
180 184
181 const QMetaObject* metaObject = qobject->metaObject();185 const QMetaObject* metaObject = qobject->metaObject();
182 186
183 qDebug(scriptengine) << "Investigate: " << metaObject->className();187 //qDebug(scriptengine) << "Investigate: " << metaObject->className();
184 if (QString("Vec3") == metaObject->className()) {188 if (QString("Vec3") == metaObject->className()) {
185 printf("Vec3");189 printf("Vec3");
186 }190 }
@@ -194,7 +198,7 @@ void ScriptObjectV8Proxy::investigate() { · 7 unmodified lines
194 QMetaProperty prop = metaObject->property(idx);198 QMetaProperty prop = metaObject->property(idx);
195 if (!prop.isScriptable()) continue;199 if (!prop.isScriptable()) continue;
196 200
197 qDebug(scriptengine) << "Investigate: " << metaObject->className() << " Property: " << prop.name();201 //qDebug(scriptengine) << "Investigate: " << metaObject->className() << " Property: " << prop.name();
198 // always exclude child objects (at least until we decide otherwise)202 // always exclude child objects (at least until we decide otherwise)
199 int metaTypeId = prop.userType();203 int metaTypeId = prop.userType();
200 if (metaTypeId != QMetaType::UnknownType) {204 if (metaTypeId != QMetaType::UnknownType) {
@@ -217,7 +221,7 @@ void ScriptObjectV8Proxy::investigate() { · 16 unmodified lines
217 QHash<V8ScriptString, int> methodNames;221 QHash<V8ScriptString, int> methodNames;
218 for (int idx = startIdx; idx < num; ++idx) {222 for (int idx = startIdx; idx < num; ++idx) {
219 QMetaMethod method = metaObject->method(idx);223 QMetaMethod method = metaObject->method(idx);
220 qDebug(scriptengine) << "Investigate: " << metaObject->className() << " Method: " << method.name();224 //qDebug(scriptengine) << "Investigate: " << metaObject->className() << " Method: " << method.name();
221 225
222 // perhaps keep this comment? Calls (like AudioScriptingInterface::playSound) seem to expect non-public methods to be script-accessible226 // perhaps keep this comment? Calls (like AudioScriptingInterface::playSound) seem to expect non-public methods to be script-accessible
223 /* if (method.access() != QMetaMethod::Public) continue;*/227 /* if (method.access() != QMetaMethod::Public) continue;*/
@@ -318,7 +322,7 @@ ScriptObjectV8Proxy::QueryFlags ScriptObjectV8Proxy::queryProperty(const V8Scrip · 94 unmodified lines
318 // check for methods322 // check for methods
319 for (MethodDefMap::const_iterator trans = _methods.cbegin(); trans != _methods.cend(); ++trans) {323 for (MethodDefMap::const_iterator trans = _methods.cbegin(); trans != _methods.cend(); ++trans) {
320 v8::String::Utf8Value methodNameStr(_engine->getIsolate(), trans.value().name.constGet());324 v8::String::Utf8Value methodNameStr(_engine->getIsolate(), trans.value().name.constGet());
321 qDebug(scriptengine) << "queryProperty : " << *nameStr << " method: " << *methodNameStr;325 //qDebug(scriptengine) << "queryProperty : " << *nameStr << " method: " << *methodNameStr;
322 if (!(trans.value().name == name)) continue;326 if (!(trans.value().name == name)) continue;
323 *id = trans.key() | METHOD_TYPE;327 *id = trans.key() | METHOD_TYPE;
324 return flags & (HandlesReadAccess | HandlesWriteAccess);328 return flags & (HandlesReadAccess | HandlesWriteAccess);