mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 16:14:35 +02:00
Fixed object containing UniquePersistent
This commit is contained in:
parent
9fd2f4ed08
commit
8e718262bd
6 changed files with 39 additions and 1 deletions
|
@ -906,7 +906,7 @@ void ScriptManager::run() {
|
||||||
|
|
||||||
// TODO: Integrate this with signals/slots instead of reimplementing throttling for ScriptManager
|
// TODO: Integrate this with signals/slots instead of reimplementing throttling for ScriptManager
|
||||||
while (!_isFinished) {
|
while (!_isFinished) {
|
||||||
qCDebug(scriptengine) << "In script event loop";
|
//qCDebug(scriptengine) << "In script event loop";
|
||||||
|
|
||||||
auto beforeSleep = clock::now();
|
auto beforeSleep = clock::now();
|
||||||
|
|
||||||
|
|
|
@ -203,6 +203,11 @@ QObject* ScriptObjectV8Proxy::unwrap(const V8ScriptValue& val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptObjectV8Proxy::~ScriptObjectV8Proxy() {
|
ScriptObjectV8Proxy::~ScriptObjectV8Proxy() {
|
||||||
|
auto isolate = _engine->getIsolate();
|
||||||
|
v8::Locker locker(isolate);
|
||||||
|
v8::Isolate::Scope isolateScope(isolate);
|
||||||
|
v8::HandleScope handleScope(isolate);
|
||||||
|
_v8Object.Reset();
|
||||||
if(_object) qDebug(scriptengine) << "Deleting object proxy: " << name();
|
if(_object) qDebug(scriptengine) << "Deleting object proxy: " << name();
|
||||||
if (_ownsObject) {
|
if (_ownsObject) {
|
||||||
QObject* qobject = _object;
|
QObject* qobject = _object;
|
||||||
|
@ -664,6 +669,15 @@ ScriptVariantV8Proxy::ScriptVariantV8Proxy(ScriptEngineV8* engine, const QVarian
|
||||||
_name = QString::fromLatin1(variant.typeName());
|
_name = QString::fromLatin1(variant.typeName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScriptVariantV8Proxy::~ScriptVariantV8Proxy() {
|
||||||
|
auto isolate = _engine->getIsolate();
|
||||||
|
v8::Locker locker(isolate);
|
||||||
|
v8::Isolate::Scope isolateScope(isolate);
|
||||||
|
v8::HandleScope handleScope(isolate);
|
||||||
|
_v8ObjectTemplate.Reset();
|
||||||
|
_v8Object.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
V8ScriptValue ScriptVariantV8Proxy::newVariant(ScriptEngineV8* engine, const QVariant& variant, V8ScriptValue proto) {
|
V8ScriptValue ScriptVariantV8Proxy::newVariant(ScriptEngineV8* engine, const QVariant& variant, V8ScriptValue proto) {
|
||||||
auto isolate = engine->getIsolate();
|
auto isolate = engine->getIsolate();
|
||||||
v8::Locker locker(isolate);
|
v8::Locker locker(isolate);
|
||||||
|
@ -1147,6 +1161,14 @@ void ScriptMethodV8Proxy::call(const v8::FunctionCallbackInfo<v8::Value>& argume
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
ScriptSignalV8Proxy::~ScriptSignalV8Proxy() {
|
||||||
|
auto isolate = _engine->getIsolate();
|
||||||
|
v8::Locker locker(isolate);
|
||||||
|
v8::Isolate::Scope isolateScope(isolate);
|
||||||
|
v8::HandleScope handleScope(isolate);
|
||||||
|
_v8Context.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
QString ScriptSignalV8Proxy::fullName() const {
|
QString ScriptSignalV8Proxy::fullName() const {
|
||||||
Q_ASSERT(_object);
|
Q_ASSERT(_object);
|
||||||
if (!_object) return "";
|
if (!_object) return "";
|
||||||
|
|
|
@ -129,6 +129,7 @@ private: // storage
|
||||||
class ScriptVariantV8Proxy final {
|
class ScriptVariantV8Proxy final {
|
||||||
public: // construction
|
public: // construction
|
||||||
ScriptVariantV8Proxy(ScriptEngineV8* engine, const QVariant& variant, V8ScriptValue scriptProto, ScriptObjectV8Proxy* proto);
|
ScriptVariantV8Proxy(ScriptEngineV8* engine, const QVariant& variant, V8ScriptValue scriptProto, ScriptObjectV8Proxy* proto);
|
||||||
|
~ScriptVariantV8Proxy();
|
||||||
|
|
||||||
static V8ScriptValue newVariant(ScriptEngineV8* engine, const QVariant& variant, V8ScriptValue proto);
|
static V8ScriptValue newVariant(ScriptEngineV8* engine, const QVariant& variant, V8ScriptValue proto);
|
||||||
static ScriptVariantV8Proxy* unwrapProxy(const V8ScriptValue& val);
|
static ScriptVariantV8Proxy* unwrapProxy(const V8ScriptValue& val);
|
||||||
|
@ -232,6 +233,8 @@ public: // construction
|
||||||
_v8Context.Reset(_engine->getIsolate(), _engine->getContext());
|
_v8Context.Reset(_engine->getIsolate(), _engine->getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~ScriptSignalV8Proxy();
|
||||||
|
|
||||||
private: // implementation
|
private: // implementation
|
||||||
virtual int qt_metacall(QMetaObject::Call call, int id, void** arguments) override;
|
virtual int qt_metacall(QMetaObject::Call call, int id, void** arguments) override;
|
||||||
int discoverMetaCallIdx();
|
int discoverMetaCallIdx();
|
||||||
|
|
|
@ -31,6 +31,16 @@ V8ScriptValueIterator::V8ScriptValueIterator(ScriptEngineV8* engine, v8::Local<v
|
||||||
_currentIndex = -1;
|
_currentIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
V8ScriptValueIterator::~V8ScriptValueIterator() {
|
||||||
|
auto isolate = _engine->getIsolate();
|
||||||
|
v8::Locker locker(isolate);
|
||||||
|
v8::Isolate::Scope isolateScope(isolate);
|
||||||
|
v8::HandleScope handleScope(isolate);
|
||||||
|
_propertyNames.Reset();
|
||||||
|
_object.Reset();
|
||||||
|
_context.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
bool V8ScriptValueIterator::hasNext() const {
|
bool V8ScriptValueIterator::hasNext() const {
|
||||||
return _currentIndex < _length - 1;
|
return _currentIndex < _length - 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
class V8ScriptValueIterator {
|
class V8ScriptValueIterator {
|
||||||
public:
|
public:
|
||||||
V8ScriptValueIterator(ScriptEngineV8* engine, v8::Local<v8::Value> object);
|
V8ScriptValueIterator(ScriptEngineV8* engine, v8::Local<v8::Value> object);
|
||||||
|
~V8ScriptValueIterator();
|
||||||
bool hasNext() const;
|
bool hasNext() const;
|
||||||
QString name() const;
|
QString name() const;
|
||||||
void next();
|
void next();
|
||||||
|
|
|
@ -70,6 +70,7 @@ V8ScriptValue ScriptValueV8Wrapper::fullUnwrap(ScriptEngineV8* engine, const Scr
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptValue ScriptValueV8Wrapper::call(const ScriptValue& thisObject, const ScriptValueList& args) {
|
ScriptValue ScriptValueV8Wrapper::call(const ScriptValue& thisObject, const ScriptValueList& args) {
|
||||||
|
Q_ASSERT(_engine == _value.getEngine());
|
||||||
auto isolate = _engine->getIsolate();
|
auto isolate = _engine->getIsolate();
|
||||||
v8::Locker locker(isolate);
|
v8::Locker locker(isolate);
|
||||||
v8::Isolate::Scope isolateScope(isolate);
|
v8::Isolate::Scope isolateScope(isolate);
|
||||||
|
@ -104,6 +105,7 @@ ScriptValue ScriptValueV8Wrapper::call(const ScriptValue& thisObject, const Scri
|
||||||
qCDebug(scriptengine) << "Function call failed: \"" << _engine->formatErrorMessageFromTryCatch(tryCatch);
|
qCDebug(scriptengine) << "Function call failed: \"" << _engine->formatErrorMessageFromTryCatch(tryCatch);
|
||||||
}
|
}
|
||||||
v8::Local<v8::Value> result;
|
v8::Local<v8::Value> result;
|
||||||
|
Q_ASSERT(_engine == _value.getEngine());
|
||||||
if (maybeResult.ToLocal(&result)) {
|
if (maybeResult.ToLocal(&result)) {
|
||||||
return ScriptValue(new ScriptValueV8Wrapper(_engine, V8ScriptValue(_engine, result)));
|
return ScriptValue(new ScriptValueV8Wrapper(_engine, V8ScriptValue(_engine, result)));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue