Showing the changes to libraries/script-engine/src/v8/ScriptObjectV8Proxy.cpp (1 of 6 files). Show all
Unified · Split
| @@ -114,7 +114,7 @@ V8ScriptValue ScriptObjectV8Proxy::newQObject(ScriptEngineV8* engine, QObject* o · 113 unmodified lines | ||
| 114 | 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 deleted | |
| 117 | + // V8TODO add a V8 callback that removes pointer for the script engine owned ob from the map so that it gets deleted | |
| 118 | 118 | // register the wrapper with the engine and make sure it cleans itself up |
| 119 | 119 | engine->_qobjectWrapperMap.insert(object, proxy); |
| 120 | 120 | engine->_qobjectWrapperMapV8.insert(object, proxy); |
| @@ -126,6 +126,10 @@ V8ScriptValue ScriptObjectV8Proxy::newQObject(ScriptEngineV8* engine, QObject* o · 5 unmodified lines | ||
| 126 | 126 | if (lookup != enginePtr->_qobjectWrapperMap.end()) { |
| 127 | 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 | 142 | v8::HandleScope handleScope(const_cast<v8::Isolate*>(val.constGetIsolate())); |
| 139 | 143 | auto v8Value = val.constGet(); |
| 140 | 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 | 146 | return nullptr; |
| 143 | 147 | } |
| 144 | 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 | |
| 161 | 165 | ScriptObjectV8Proxy::~ScriptObjectV8Proxy() { |
| 162 | − qDebug(scriptengine) << "Deleting object proxy: " << name(); | |
| 166 | + if(_object) qDebug(scriptengine) << "Deleting object proxy: " << name(); | |
| 163 | 167 | if (_ownsObject) { |
| 164 | 168 | QObject* qobject = _object; |
| 165 | 169 | if(qobject) qobject->deleteLater(); |
| @@ -180,7 +184,7 @@ void ScriptObjectV8Proxy::investigate() { · 14 unmodified lines | ||
| 180 | 184 | |
| 181 | 185 | const QMetaObject* metaObject = qobject->metaObject(); |
| 182 | 186 | |
| 183 | − qDebug(scriptengine) << "Investigate: " << metaObject->className(); | |
| 187 | + //qDebug(scriptengine) << "Investigate: " << metaObject->className(); | |
| 184 | 188 | if (QString("Vec3") == metaObject->className()) { |
| 185 | 189 | printf("Vec3"); |
| 186 | 190 | } |
| @@ -194,7 +198,7 @@ void ScriptObjectV8Proxy::investigate() { · 7 unmodified lines | ||
| 194 | 198 | QMetaProperty prop = metaObject->property(idx); |
| 195 | 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 | 202 | // always exclude child objects (at least until we decide otherwise) |
| 199 | 203 | int metaTypeId = prop.userType(); |
| 200 | 204 | if (metaTypeId != QMetaType::UnknownType) { |
| @@ -217,7 +221,7 @@ void ScriptObjectV8Proxy::investigate() { · 16 unmodified lines | ||
| 217 | 221 | QHash<V8ScriptString, int> methodNames; |
| 218 | 222 | for (int idx = startIdx; idx < num; ++idx) { |
| 219 | 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 | 226 | // perhaps keep this comment? Calls (like AudioScriptingInterface::playSound) seem to expect non-public methods to be script-accessible |
| 223 | 227 | /* if (method.access() != QMetaMethod::Public) continue;*/ |
| @@ -318,7 +322,7 @@ ScriptObjectV8Proxy::QueryFlags ScriptObjectV8Proxy::queryProperty(const V8Scrip · 94 unmodified lines | ||
| 318 | 322 | // check for methods |
| 319 | 323 | for (MethodDefMap::const_iterator trans = _methods.cbegin(); trans != _methods.cend(); ++trans) { |
| 320 | 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 | 326 | if (!(trans.value().name == name)) continue; |
| 323 | 327 | *id = trans.key() | METHOD_TYPE; |
| 324 | 328 | return flags & (HandlesReadAccess | HandlesWriteAccess); |