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
114114 return V8ScriptValue(engine->getIsolate(), proxy.get()->toV8Value());
115115 }
116116 }
117− // V8TODO add a V8 callback that removes pointer from the map so that it gets deleted
117+ // V8TODO add a V8 callback that removes pointer for the script engine owned ob from the map so that it gets deleted
118118 // register the wrapper with the engine and make sure it cleans itself up
119119 engine->_qobjectWrapperMap.insert(object, proxy);
120120 engine->_qobjectWrapperMapV8.insert(object, proxy);
@@ -126,6 +126,10 @@ V8ScriptValue ScriptObjectV8Proxy::newQObject(ScriptEngineV8* engine, QObject* o · 5 unmodified lines
126126 if (lookup != enginePtr->_qobjectWrapperMap.end()) {
127127 enginePtr->_qobjectWrapperMap.erase(lookup);
128128 }
129+ auto lookupV8 = enginePtr->_qobjectWrapperMapV8.find(object);
130+ if (lookupV8 != enginePtr->_qobjectWrapperMapV8.end()) {
131+ enginePtr->_qobjectWrapperMapV8.erase(lookupV8);
132+ }
129133 });
130134 }
131135
@@ -138,7 +142,7 @@ ScriptObjectV8Proxy* ScriptObjectV8Proxy::unwrapProxy(const V8ScriptValue& val) · 6 unmodified lines
138142 v8::HandleScope handleScope(const_cast<v8::Isolate*>(val.constGetIsolate()));
139143 auto v8Value = val.constGet();
140144 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";
142146 return nullptr;
143147 }
144148 v8::Local<v8::Object> v8Object = v8::Local<v8::Object>::Cast(v8Value);
@@ -159,7 +163,7 @@ QObject* ScriptObjectV8Proxy::unwrap(const V8ScriptValue& val) { · 14 unmodified lines
159163 }
160164
161165 ScriptObjectV8Proxy::~ScriptObjectV8Proxy() {
162− qDebug(scriptengine) << "Deleting object proxy: " << name();
166+ if(_object) qDebug(scriptengine) << "Deleting object proxy: " << name();
163167 if (_ownsObject) {
164168 QObject* qobject = _object;
165169 if(qobject) qobject->deleteLater();
@@ -180,7 +184,7 @@ void ScriptObjectV8Proxy::investigate() { · 14 unmodified lines
180184
181185 const QMetaObject* metaObject = qobject->metaObject();
182186
183− qDebug(scriptengine) << "Investigate: " << metaObject->className();
187+ //qDebug(scriptengine) << "Investigate: " << metaObject->className();
184188 if (QString("Vec3") == metaObject->className()) {
185189 printf("Vec3");
186190 }
@@ -194,7 +198,7 @@ void ScriptObjectV8Proxy::investigate() { · 7 unmodified lines
194198 QMetaProperty prop = metaObject->property(idx);
195199 if (!prop.isScriptable()) continue;
196200
197− qDebug(scriptengine) << "Investigate: " << metaObject->className() << " Property: " << prop.name();
201+ //qDebug(scriptengine) << "Investigate: " << metaObject->className() << " Property: " << prop.name();
198202 // always exclude child objects (at least until we decide otherwise)
199203 int metaTypeId = prop.userType();
200204 if (metaTypeId != QMetaType::UnknownType) {
@@ -217,7 +221,7 @@ void ScriptObjectV8Proxy::investigate() { · 16 unmodified lines
217221 QHash<V8ScriptString, int> methodNames;
218222 for (int idx = startIdx; idx < num; ++idx) {
219223 QMetaMethod method = metaObject->method(idx);
220− qDebug(scriptengine) << "Investigate: " << metaObject->className() << " Method: " << method.name();
224+ //qDebug(scriptengine) << "Investigate: " << metaObject->className() << " Method: " << method.name();
221225
222226 // perhaps keep this comment? Calls (like AudioScriptingInterface::playSound) seem to expect non-public methods to be script-accessible
223227 /* if (method.access() != QMetaMethod::Public) continue;*/
@@ -318,7 +322,7 @@ ScriptObjectV8Proxy::QueryFlags ScriptObjectV8Proxy::queryProperty(const V8Scrip · 94 unmodified lines
318322 // check for methods
319323 for (MethodDefMap::const_iterator trans = _methods.cbegin(); trans != _methods.cend(); ++trans) {
320324 v8::String::Utf8Value methodNameStr(_engine->getIsolate(), trans.value().name.constGet());
321− qDebug(scriptengine) << "queryProperty : " << *nameStr << " method: " << *methodNameStr;
325+ //qDebug(scriptengine) << "queryProperty : " << *nameStr << " method: " << *methodNameStr;
322326 if (!(trans.value().name == name)) continue;
323327 *id = trans.key() | METHOD_TYPE;
324328 return flags & (HandlesReadAccess | HandlesWriteAccess);