Fixed location JS API

This commit is contained in:
ksuprynowicz 2023-01-22 00:44:23 +01:00
parent 4f4c8931a9
commit cb4dc4c7e8
5 changed files with 15 additions and 13 deletions

View file

@ -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)

View file

@ -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?

View file

@ -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;

View file

@ -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") {

View file

@ -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 ################