Merge pull request #444 from overte-org/fix/private_access_v8

Hide private methods and QObject signals from script engine
This commit is contained in:
ksuprynowicz 2023-06-04 16:34:21 +02:00 committed by GitHub
commit 5d08f3483a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 5 deletions

View file

@ -271,7 +271,7 @@ void ScriptObjectV8Proxy::investigate() {
QMetaMethod method = metaObject->method(idx);
// perhaps keep this comment? Calls (like AudioScriptingInterface::playSound) seem to expect non-public methods to be script-accessible
/* if (method.access() != QMetaMethod::Public) continue;*/
if (method.access() == QMetaMethod::Private) continue;
bool isSignal = false;
QByteArray szName = method.name();
@ -280,6 +280,12 @@ void ScriptObjectV8Proxy::investigate() {
case QMetaMethod::Constructor:
continue;
case QMetaMethod::Signal:
if (szName == "destroyed") {
continue;
}
if (szName == "objectNameChanged") {
continue;
}
isSignal = true;
break;
case QMetaMethod::Slot:
@ -389,6 +395,7 @@ ScriptObjectV8Proxy::QueryFlags ScriptObjectV8Proxy::queryProperty(const V8Scrip
v8::Local<v8::Context> context = _engine->getContext();
v8::Context::Scope contextScope(context);
QString nameStr(*v8::String::Utf8Value(isolate, name.constGet()));
// V8TODO: registering methods on V8 side would make API calls a lot faster
// check for methods
MethodNameMap::const_iterator method = _methodNameMap.find(nameStr);

View file

@ -39,8 +39,8 @@ var DEFAULT_SCRIPTS_COMBINED = [
"system/onEscape.js",
"system/onFirstRun.js",
"system/appreciate/appreciate_app.js",
"system/places/places.js",
"developer/debugging/scriptMemoryReport.js"
"system/places/places.js"
//"developer/debugging/scriptMemoryReport.js"
];
var DEFAULT_SCRIPTS_SEPARATE = [
"system/controllers/controllerScripts.js",

View file

@ -41,8 +41,7 @@ var CONTOLLER_SCRIPTS = [
"controllerModules/trackedHandTablet.js"
];
Script.include("../../developer/debugging/scriptMemoryReport.js");
//Script.include("developer/debugging/scriptMemoryReport.js");
//Script.include("../../developer/debugging/scriptMemoryReport.js");
var DEBUG_MENU_ITEM = "Debug defaultScripts.js";