mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 23:36:44 +02:00
error check/log on execution, too
This commit is contained in:
parent
34e9c5debc
commit
b62f3e550a
3 changed files with 11 additions and 5 deletions
|
@ -360,7 +360,9 @@ void EntityServer::scriptRequestFinished() {
|
||||||
if (hasCorrectSyntax(program)) {
|
if (hasCorrectSyntax(program)) {
|
||||||
_entityEditFilterEngine.evaluate(scriptContents);
|
_entityEditFilterEngine.evaluate(scriptContents);
|
||||||
if (!hadUncaughtExceptions(_entityEditFilterEngine, urlString)) {
|
if (!hadUncaughtExceptions(_entityEditFilterEngine, urlString)) {
|
||||||
std::static_pointer_cast<EntityTree>(_tree)->initEntityEditFilterEngine(&_entityEditFilterEngine);
|
std::static_pointer_cast<EntityTree>(_tree)->initEntityEditFilterEngine(&_entityEditFilterEngine, [this]() {
|
||||||
|
return hadUncaughtExceptions(_entityEditFilterEngine, _entityEditFilter);
|
||||||
|
});
|
||||||
scriptRequest->deleteLater();
|
scriptRequest->deleteLater();
|
||||||
if (_scriptRequestLoop.isRunning()) {
|
if (_scriptRequestLoop.isRunning()) {
|
||||||
_scriptRequestLoop.quit();
|
_scriptRequestLoop.quit();
|
||||||
|
|
|
@ -918,8 +918,9 @@ void EntityTree::fixupTerseEditLogging(EntityItemProperties& properties, QList<Q
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTree::initEntityEditFilterEngine(QScriptEngine* engine) {
|
void EntityTree::initEntityEditFilterEngine(QScriptEngine* engine, std::function<bool()> entityEditFilterHadUncaughtExceptions) {
|
||||||
_entityEditFilterEngine = engine;
|
_entityEditFilterEngine = engine;
|
||||||
|
_entityEditFilterHadUncaughtExceptions = entityEditFilterHadUncaughtExceptions;
|
||||||
auto global = _entityEditFilterEngine->globalObject();
|
auto global = _entityEditFilterEngine->globalObject();
|
||||||
_entityEditFilterFunction = global.property("filter");
|
_entityEditFilterFunction = global.property("filter");
|
||||||
_hasEntityEditFilter = _entityEditFilterFunction.isFunction();
|
_hasEntityEditFilter = _entityEditFilterFunction.isFunction();
|
||||||
|
@ -942,12 +943,14 @@ bool EntityTree::filterProperties(EntityItemProperties& propertiesIn, EntityItem
|
||||||
args << inputValues;
|
args << inputValues;
|
||||||
|
|
||||||
QScriptValue result = _entityEditFilterFunction.call(_nullObjectForFilter, args);
|
QScriptValue result = _entityEditFilterFunction.call(_nullObjectForFilter, args);
|
||||||
|
if (_entityEditFilterHadUncaughtExceptions()) {
|
||||||
|
result = QScriptValue();
|
||||||
|
}
|
||||||
|
|
||||||
propertiesOut.copyFromScriptValue(result, false);
|
|
||||||
bool accepted = result.isObject(); // filters should return null or false to completely reject edit or add
|
bool accepted = result.isObject(); // filters should return null or false to completely reject edit or add
|
||||||
if (accepted) {
|
if (accepted) {
|
||||||
|
propertiesOut.copyFromScriptValue(result, false);
|
||||||
// Javascript objects are == only if they are the same object. To compare arbitrary values, we need to use JSON.
|
// Javascript objects are == only if they are the same object. To compare arbitrary values, we need to use JSON.
|
||||||
|
|
||||||
auto out = QJsonValue::fromVariant(result.toVariant());
|
auto out = QJsonValue::fromVariant(result.toVariant());
|
||||||
wasChanged = in != out;
|
wasChanged = in != out;
|
||||||
if (wasChanged) {
|
if (wasChanged) {
|
||||||
|
|
|
@ -262,7 +262,7 @@ public:
|
||||||
|
|
||||||
void notifyNewCollisionSoundURL(const QString& newCollisionSoundURL, const EntityItemID& entityID);
|
void notifyNewCollisionSoundURL(const QString& newCollisionSoundURL, const EntityItemID& entityID);
|
||||||
|
|
||||||
void initEntityEditFilterEngine(QScriptEngine* engine);
|
void initEntityEditFilterEngine(QScriptEngine* engine, std::function<bool()> entityEditFilterHadUncaughtExceptions);
|
||||||
|
|
||||||
static const float DEFAULT_MAX_TMP_ENTITY_LIFETIME;
|
static const float DEFAULT_MAX_TMP_ENTITY_LIFETIME;
|
||||||
|
|
||||||
|
@ -356,6 +356,7 @@ protected:
|
||||||
QScriptEngine* _entityEditFilterEngine{};
|
QScriptEngine* _entityEditFilterEngine{};
|
||||||
QScriptValue _entityEditFilterFunction{};
|
QScriptValue _entityEditFilterFunction{};
|
||||||
QScriptValue _nullObjectForFilter{};
|
QScriptValue _nullObjectForFilter{};
|
||||||
|
std::function<bool()> _entityEditFilterHadUncaughtExceptions;
|
||||||
|
|
||||||
QStringList _entityScriptSourceWhitelist;
|
QStringList _entityScriptSourceWhitelist;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue