From cb4dc4c7e88d7535f0bc676b32712774a2e0a000 Mon Sep 17 00:00:00 2001 From: ksuprynowicz Date: Sun, 22 Jan 2023 00:44:23 +0100 Subject: [PATCH] Fixed location JS API --- interface/src/Application.cpp | 5 ++--- libraries/script-engine/src/v8/ScriptEngineV8.cpp | 4 ++-- libraries/shared/src/SettingHelpers.cpp | 6 ++++-- scripts/system/places/places.html | 1 + scripts/system/places/places.js | 12 ++++++------ 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 5f41d7ba8a..2ee62087cd 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -7506,9 +7506,8 @@ void Application::registerScriptEngineWithApplicationServices(const ScriptManage scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter, LocationScriptingInterface::locationSetter, "Window"); // register `location` on the global object. - //V8TODO causes a crash - //scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter, - // LocationScriptingInterface::locationSetter); + scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter, + LocationScriptingInterface::locationSetter); scriptEngine->registerFunction("OverlayWindow", clientScript ? QmlWindowClass::constructor : QmlWindowClass::restricted_constructor); #if !defined(Q_OS_ANDROID) && !defined(DISABLE_QML) diff --git a/libraries/script-engine/src/v8/ScriptEngineV8.cpp b/libraries/script-engine/src/v8/ScriptEngineV8.cpp index 390bf1e2f1..ac9a90ab10 100644 --- a/libraries/script-engine/src/v8/ScriptEngineV8.cpp +++ b/libraries/script-engine/src/v8/ScriptEngineV8.cpp @@ -727,8 +727,8 @@ void ScriptEngineV8::registerGetterSetter(const QString& name, ScriptEngine::Fun ScriptValue setterFunction = newFunction(setter, 1); ScriptValue getterFunction = newFunction(getter); - V8ScriptValue unwrappedGetter = ScriptValueV8Wrapper::fullUnwrap(this, setterFunction); - V8ScriptValue unwrappedSetter = ScriptValueV8Wrapper::fullUnwrap(this, getterFunction); + V8ScriptValue unwrappedGetter = ScriptValueV8Wrapper::fullUnwrap(this, getterFunction); + V8ScriptValue unwrappedSetter = ScriptValueV8Wrapper::fullUnwrap(this, setterFunction); v8::PropertyDescriptor propertyDescriptor(unwrappedGetter.get(), unwrappedSetter.get()); //V8TODO: Getters/setters are probably done in a different way in V8. Maybe object template is needed? diff --git a/libraries/shared/src/SettingHelpers.cpp b/libraries/shared/src/SettingHelpers.cpp index 5695472fae..7d059de5e7 100644 --- a/libraries/shared/src/SettingHelpers.cpp +++ b/libraries/shared/src/SettingHelpers.cpp @@ -133,11 +133,12 @@ QJsonDocument variantMapToJsonDocument(const QSettings::SettingsMap& map) { } switch (variantType) { - case QVariant::Hash: { + // V8TODO: why was this here? It seems that it supported + /*case QVariant::Hash: { qCritical() << "Unsupported variant type" << variant.typeName() << ";" << key << variant; Q_ASSERT(false); break; - } + }*/ case QVariant::Invalid: object.insert(key, QJsonValue()); @@ -149,6 +150,7 @@ QJsonDocument variantMapToJsonDocument(const QSettings::SettingsMap& map) { case QVariant::Bool: case QVariant::Double: case QVariant::Map: + case QVariant::Hash: case QVariant::List: object.insert(key, QJsonValue::fromVariant(variant)); break; diff --git a/scripts/system/places/places.html b/scripts/system/places/places.html index e9a131ccd5..d25f609e0d 100644 --- a/scripts/system/places/places.html +++ b/scripts/system/places/places.html @@ -264,6 +264,7 @@ } document.getElementById("listInfo").innerHTML = metaverseCounter + metaversePageInfo + " of " + metaverseList.length + "."; } else { + console.log(JSON.stringify(placeList)); var placeRecords = placeList.slice(); if (currentListFormat === "DOMAINS") { diff --git a/scripts/system/places/places.js b/scripts/system/places/places.js index bfb111c4da..240083cac0 100644 --- a/scripts/system/places/places.js +++ b/scripts/system/places/places.js @@ -504,13 +504,13 @@ } //####### seed random library ################ - Math.seed = 75; + var seed = 75; - Math.seededRandom = function(max, min) { + var seededRandom = function(max, min) { max = max || 1; min = min || 0; - Math.seed = (Math.seed * 9301 + 49297) % 233280; - var rnd = Math.seed / 233280; + seed = (seed * 9301 + 49297) % 233280; + var rnd = seed / 233280; return min + rnd * (max - min); } @@ -527,8 +527,8 @@ var d = new Date(); var n = d.getTime(); var currentSeed = Math.floor(n / PERSISTENCE_ORDERING_CYCLE); - Math.seed = score * currentSeed; - return zeroPad(Math.floor(Math.seededRandom() * 100000),5); + seed = score * currentSeed; + return zeroPad(Math.floor(seededRandom() * 100000),5); } //####### END of seed random library ################