mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-16 12:20:12 +02:00
Add cap on entities scripting thread stop time
This commit is contained in:
parent
f2f89ca062
commit
7e82494a66
3 changed files with 8 additions and 1 deletions
|
@ -83,8 +83,13 @@ void EntityTreeRenderer::resetEntitiesScriptEngine() {
|
|||
|
||||
auto newEngine = new ScriptEngine(NO_SCRIPT, QString("Entities %1").arg(++_entitiesScriptEngineCount));
|
||||
_entitiesScriptEngine = QSharedPointer<ScriptEngine>(newEngine, [](ScriptEngine* engine){
|
||||
// Gracefully exit
|
||||
engine->unloadAllEntityScripts();
|
||||
engine->stop();
|
||||
|
||||
// Disgracefully exit, if necessary
|
||||
QTimer::singleShot(ScriptEngine::MAX_SCRIPT_EVALUATION_TIME, engine, &ScriptEngine::abort);
|
||||
|
||||
engine->deleteLater();
|
||||
});
|
||||
|
||||
|
|
|
@ -304,7 +304,6 @@ void ScriptEngine::wait() {
|
|||
QCoreApplication::processEvents();
|
||||
|
||||
// If the final evaluation takes too long, then tell the script engine to stop evaluating
|
||||
static const auto MAX_SCRIPT_EVALUATION_TIME = USECS_PER_SECOND;
|
||||
static const auto MAX_SCRIPT_QUITTING_TIME = 0.5 * MAX_SCRIPT_EVALUATION_TIME;
|
||||
auto elapsedUsecs = usecTimestampNow() - startedWaiting;
|
||||
if (elapsedUsecs > MAX_SCRIPT_EVALUATION_TIME) {
|
||||
|
|
|
@ -67,6 +67,8 @@ public:
|
|||
class ScriptEngine : public QScriptEngine, public ScriptUser, public EntitiesScriptEngineProvider {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static const auto MAX_SCRIPT_EVALUATION_TIME = USECS_PER_SECOND;
|
||||
|
||||
ScriptEngine(const QString& scriptContents = NO_SCRIPT, const QString& fileNameString = QString(""));
|
||||
|
||||
~ScriptEngine();
|
||||
|
@ -164,6 +166,7 @@ public:
|
|||
public slots:
|
||||
void callAnimationStateHandler(QScriptValue callback, AnimVariantMap parameters, QStringList names, bool useNames, AnimVariantResultHandler resultHandler);
|
||||
void updateMemoryCost(const qint64&);
|
||||
void abort() { abortEvaluation(); }
|
||||
|
||||
signals:
|
||||
void scriptLoaded(const QString& scriptFilename);
|
||||
|
|
Loading…
Reference in a new issue