History

Merge branch 'master' into fix/script-engine-abuse

Ryan Huffman committed 9 years ago

Commit 601aa512 parents 51586ae fcd6c0a686 files · +48509 −6625Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 686 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+181−104
@@ -72,6 +72,8 @@ static const QScriptEngine::QObjectWrapOptions DEFAULT_QOBJECT_WRAP_OPTIONS = · 71 unmodified lines
7272 Q_DECLARE_METATYPE(QScriptEngine::FunctionSignature)
7373 int functionSignatureMetaID = qRegisterMetaType<QScriptEngine::FunctionSignature>();
7474
75+Q_LOGGING_CATEGORY(scriptengineScript, "hifi.scriptengine.script")
76+
7577 static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){
7678 QString message = "";
7779 for (int i = 0; i < context->argumentCount(); i++) {
@@ -80,12 +82,14 @@ static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){ · 2 unmodified lines
8082 }
8183 message += context->argument(i).toString();
8284 }
83− qCDebug(scriptengine).noquote() << "script:print()<<" << message; // noquote() so that \n is treated as newline
85+ qCDebug(scriptengineScript).noquote() << "script:print()<<" << message; // noquote() so that \n is treated as newline
8486
8587 message = message.replace("\\", "\\\\")
8688 .replace("\n", "\\n")
8789 .replace("\r", "\\r")
8890 .replace("'", "\\'");
91+
92+ // FIXME - this approach neeeds revisiting. print() comes here, which ends up doing an evaluate?
8993 engine->evaluate("Script.print('" + message + "')");
9094
9195 return QScriptValue();
@@ -130,20 +134,20 @@ QString encodeEntityIdIntoEntityUrl(const QString& url, const QString& entityID) · 38 unmodified lines
130134 return url + " [EntityID:" + entityID + "]";
131135 }
132136
133−static bool hasCorrectSyntax(const QScriptProgram& program) {
137+static bool hasCorrectSyntax(const QScriptProgram& program, ScriptEngine* reportingEngine) {
134138 const auto syntaxCheck = QScriptEngine::checkSyntax(program.sourceCode());
135139 if (syntaxCheck.state() != QScriptSyntaxCheckResult::Valid) {
136140 const auto error = syntaxCheck.errorMessage();
137141 const auto line = QString::number(syntaxCheck.errorLineNumber());
138142 const auto column = QString::number(syntaxCheck.errorColumnNumber());
139143 const auto message = QString("[SyntaxError] %1 in %2:%3(%4)").arg(error, program.fileName(), line, column);
140− qCWarning(scriptengine) << qPrintable(message);
144+ reportingEngine->scriptErrorMessage(qPrintable(message));
141145 return false;
142146 }
143147 return true;
144148 }
145149
146−static bool hadUncaughtExceptions(QScriptEngine& engine, const QString& fileName) {
150+static bool hadUncaughtExceptions(QScriptEngine& engine, const QString& fileName, ScriptEngine* reportingEngine) {
147151 if (engine.hasUncaughtException()) {
148152 const auto backtrace = engine.uncaughtExceptionBacktrace();
149153 const auto exception = engine.uncaughtException().toString();
@@ -155,7 +159,7 @@ static bool hadUncaughtExceptions(QScriptEngine& engine, const QString& fileName · 5 unmodified lines
155159 static const auto lineSeparator = "\n ";
156160 message += QString("\n[Backtrace]%1%2").arg(lineSeparator, backtrace.join(lineSeparator));
157161 }
158− qCWarning(scriptengine) << qPrintable(message);
162+ reportingEngine->scriptErrorMessage(qPrintable(message));
159163 return true;
160164 }
161165 return false;
@@ -170,20 +174,20 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNam · 8 unmodified lines
170174 DependencyManager::get<ScriptEngines>()->addScriptEngine(this);
171175
172176 connect(this, &QScriptEngine::signalHandlerException, this, [this](const QScriptValue& exception) {
173− hadUncaughtExceptions(*this, _fileNameString);
177+ hadUncaughtExceptions(*this, _fileNameString, this);
174178 });
175179
176180 setProcessEventsInterval(MSECS_PER_SECOND);
177181 }
178182
179183 ScriptEngine::~ScriptEngine() {
180− qCDebug(scriptengine) << "Script Engine shutting down:" << getFilename();
184+ scriptInfoMessage("Script Engine shutting down:" + getFilename());
181185
182186 auto scriptEngines = DependencyManager::get<ScriptEngines>();
183187 if (scriptEngines) {
184188 scriptEngines->removeScriptEngine(this);
185189 } else {
186− qCWarning(scriptengine) << "Script destroyed after ScriptEngines!";
190+ scriptWarningMessage("Script destroyed after ScriptEngines!");
187191 }
188192 }
189193
@@ -274,7 +278,7 @@ void ScriptEngine::runDebuggable() { · 84 unmodified lines
274278 }
275279 _lastUpdate = now;
276280 // Debug and clear exceptions
277− hadUncaughtExceptions(*this, _fileNameString);
281+ hadUncaughtExceptions(*this, _fileNameString, this);
278282 });
279283
280284 timer->start(10);
@@ -359,7 +363,7 @@ void ScriptEngine::waitTillDoneRunning() { · 78 unmodified lines
359363 QThread::yieldCurrentThread();
360364 }
361365
362− qCDebug(scriptengine) << "Script Engine has stopped:" << getFilename();
366+ scriptInfoMessage("Script Engine has stopped:" + getFilename());
363367 }
364368 }
365369
@@ -398,10 +402,25 @@ void ScriptEngine::scriptContentsAvailable(const QUrl& url, const QString& scrip · 32 unmodified lines
398402 emit scriptLoaded(url.toString());
399403 }
400404
405+void ScriptEngine::scriptErrorMessage(const QString& message) {
406+ qCCritical(scriptengine) << message;
407+ emit errorMessage(message);
408+}
409+
410+void ScriptEngine::scriptWarningMessage(const QString& message) {
411+ qCWarning(scriptengine) << message;
412+ emit warningMessage(message);
413+}
414+
415+void ScriptEngine::scriptInfoMessage(const QString& message) {
416+ qCInfo(scriptengine) << message;
417+ emit infoMessage(message);
418+}
419+
401420 // FIXME - switch this to the new model of ScriptCache callbacks
402421 void ScriptEngine::errorInLoadingScript(const QUrl& url) {
403− qCDebug(scriptengine) << "ERROR Loading file:" << url.toString() << "line:" << __LINE__;
404− emit errorLoadingScript(_fileNameString); // ??
422+ scriptErrorMessage("ERROR Loading file:" + url.toString());
423+ emit errorLoadingScript(_fileNameString);
405424 }
406425
407426 // Even though we never pass AnimVariantMap directly to and from javascript, the queued invokeMethod of
@@ -553,7 +572,7 @@ void ScriptEngine::init() { · 145 unmodified lines
553572 void ScriptEngine::registerValue(const QString& valueName, QScriptValue value) {
554573 if (QThread::currentThread() != thread()) {
555574 #ifdef THREAD_DEBUGGING
556− qDebug() << "*** WARNING *** ScriptEngine::registerValue() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "]";
575+ qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::registerValue() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "]";
557576 #endif
558577 QMetaObject::invokeMethod(this, "registerValue",
559578 Q_ARG(const QString&, valueName),
@@ -583,7 +602,7 @@ void ScriptEngine::registerValue(const QString& valueName, QScriptValue value) { · 23 unmodified lines
583602 void ScriptEngine::registerGlobalObject(const QString& name, QObject* object) {
584603 if (QThread::currentThread() != thread()) {
585604 #ifdef THREAD_DEBUGGING
586− qDebug() << "*** WARNING *** ScriptEngine::registerGlobalObject() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] name:" << name;
605+ qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::registerGlobalObject() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] name:" << name;
587606 #endif
588607 QMetaObject::invokeMethod(this, "registerGlobalObject",
589608 Q_ARG(const QString&, name),
@@ -591,7 +610,7 @@ void ScriptEngine::registerGlobalObject(const QString& name, QObject* object) { · 1 unmodified line
591610 return;
592611 }
593612 #ifdef THREAD_DEBUGGING
594− qDebug() << "ScriptEngine::registerGlobalObject() called on thread [" << QThread::currentThread() << "] name:" << name;
613+ qCDebug(scriptengine) << "ScriptEngine::registerGlobalObject() called on thread [" << QThread::currentThread() << "] name:" << name;
595614 #endif
596615
597616 if (!globalObject().property(name).isValid()) {
@@ -607,7 +626,7 @@ void ScriptEngine::registerGlobalObject(const QString& name, QObject* object) { · 9 unmodified lines
607626 void ScriptEngine::registerFunction(const QString& name, QScriptEngine::FunctionSignature functionSignature, int numArguments) {
608627 if (QThread::currentThread() != thread()) {
609628 #ifdef THREAD_DEBUGGING
610− qDebug() << "*** WARNING *** ScriptEngine::registerFunction() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] name:" << name;
629+ qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::registerFunction() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] name:" << name;
611630 #endif
612631 QMetaObject::invokeMethod(this, "registerFunction",
613632 Q_ARG(const QString&, name),
@@ -616,7 +635,7 @@ void ScriptEngine::registerFunction(const QString& name, QScriptEngine::Function · 2 unmodified lines
616635 return;
617636 }
618637 #ifdef THREAD_DEBUGGING
619− qDebug() << "ScriptEngine::registerFunction() called on thread [" << QThread::currentThread() << "] name:" << name;
638+ qCDebug(scriptengine) << "ScriptEngine::registerFunction() called on thread [" << QThread::currentThread() << "] name:" << name;
620639 #endif
621640
622641 QScriptValue scriptFun = newFunction(functionSignature, numArguments);
@@ -626,7 +645,7 @@ void ScriptEngine::registerFunction(const QString& name, QScriptEngine::Function · 3 unmodified lines
626645 void ScriptEngine::registerFunction(const QString& parent, const QString& name, QScriptEngine::FunctionSignature functionSignature, int numArguments) {
627646 if (QThread::currentThread() != thread()) {
628647 #ifdef THREAD_DEBUGGING
629− qDebug() << "*** WARNING *** ScriptEngine::registerFunction() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] parent:" << parent << "name:" << name;
648+ qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::registerFunction() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] parent:" << parent << "name:" << name;
630649 #endif
631650 QMetaObject::invokeMethod(this, "registerFunction",
632651 Q_ARG(const QString&, name),
@@ -635,7 +654,7 @@ void ScriptEngine::registerFunction(const QString& parent, const QString& name, · 2 unmodified lines
635654 return;
636655 }
637656 #ifdef THREAD_DEBUGGING
638− qDebug() << "ScriptEngine::registerFunction() called on thread [" << QThread::currentThread() << "] parent:" << parent << "name:" << name;
657+ qCDebug(scriptengine) << "ScriptEngine::registerFunction() called on thread [" << QThread::currentThread() << "] parent:" << parent << "name:" << name;
639658 #endif
640659
641660 QScriptValue object = globalObject().property(parent);
@@ -649,7 +668,7 @@ void ScriptEngine::registerGetterSetter(const QString& name, QScriptEngine::Func · 7 unmodified lines
649668 QScriptEngine::FunctionSignature setter, const QString& parent) {
650669 if (QThread::currentThread() != thread()) {
651670 #ifdef THREAD_DEBUGGING
652− qDebug() << "*** WARNING *** ScriptEngine::registerGetterSetter() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
671+ qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::registerGetterSetter() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
653672 " name:" << name << "parent:" << parent;
654673 #endif
655674 QMetaObject::invokeMethod(this, "registerGetterSetter",
@@ -660,7 +679,7 @@ void ScriptEngine::registerGetterSetter(const QString& name, QScriptEngine::Func · 4 unmodified lines
660679 return;
661680 }
662681 #ifdef THREAD_DEBUGGING
663− qDebug() << "ScriptEngine::registerGetterSetter() called on thread [" << QThread::currentThread() << "] name:" << name << "parent:" << parent;
682+ qCDebug(scriptengine) << "ScriptEngine::registerGetterSetter() called on thread [" << QThread::currentThread() << "] name:" << name << "parent:" << parent;
664683 #endif
665684
666685 QScriptValue setterFunction = newFunction(setter, 1);
@@ -682,7 +701,7 @@ void ScriptEngine::registerGetterSetter(const QString& name, QScriptEngine::Func · 15 unmodified lines
682701 void ScriptEngine::removeEventHandler(const EntityItemID& entityID, const QString& eventName, QScriptValue handler) {
683702 if (QThread::currentThread() != thread()) {
684703 #ifdef THREAD_DEBUGGING
685− qDebug() << "*** WARNING *** ScriptEngine::removeEventHandler() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
704+ qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::removeEventHandler() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
686705 "entityID:" << entityID << " eventName:" << eventName;
687706 #endif
688707 QMetaObject::invokeMethod(this, "removeEventHandler",
@@ -692,7 +711,7 @@ void ScriptEngine::removeEventHandler(const EntityItemID& entityID, const QStrin · 3 unmodified lines
692711 return;
693712 }
694713 #ifdef THREAD_DEBUGGING
695− qDebug() << "ScriptEngine::removeEventHandler() called on thread [" << QThread::currentThread() << "] entityID:" << entityID << " eventName : " << eventName;
714+ qCDebug(scriptengine) << "ScriptEngine::removeEventHandler() called on thread [" << QThread::currentThread() << "] entityID:" << entityID << " eventName : " << eventName;
696715 #endif
697716
698717 if (!_registeredHandlers.contains(entityID)) {
@@ -712,7 +731,7 @@ void ScriptEngine::removeEventHandler(const EntityItemID& entityID, const QStrin · 13 unmodified lines
712731 void ScriptEngine::addEventHandler(const EntityItemID& entityID, const QString& eventName, QScriptValue handler) {
713732 if (QThread::currentThread() != thread()) {
714733 #ifdef THREAD_DEBUGGING
715− qDebug() << "*** WARNING *** ScriptEngine::addEventHandler() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
734+ qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::addEventHandler() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
716735 "entityID:" << entityID << " eventName:" << eventName;
717736 #endif
718737
@@ -723,7 +742,7 @@ void ScriptEngine::addEventHandler(const EntityItemID& entityID, const QString& · 4 unmodified lines
723742 return;
724743 }
725744 #ifdef THREAD_DEBUGGING
726− qDebug() << "ScriptEngine::addEventHandler() called on thread [" << QThread::currentThread() << "] entityID:" << entityID << " eventName : " << eventName;
745+ qCDebug(scriptengine) << "ScriptEngine::addEventHandler() called on thread [" << QThread::currentThread() << "] entityID:" << entityID << " eventName : " << eventName;
727746 #endif
728747
729748 if (_registeredHandlers.count() == 0) { // First time any per-entity handler has been added in this script...
@@ -785,7 +804,7 @@ void ScriptEngine::addEventHandler(const EntityItemID& entityID, const QString& · 55 unmodified lines
785804 _registeredHandlers[entityID] = RegisteredEventHandlers();
786805 }
787806 CallbackList& handlersForEvent = _registeredHandlers[entityID][eventName];
788− CallbackData handlerData = {handler, currentEntityIdentifier, currentSandboxURL};
807+ CallbackData handlerData = { handler, currentEntityIdentifier, currentSandboxURL };
789808 handlersForEvent << handlerData; // Note that the same handler can be added many times. See removeEntityEventHandler().
790809 }
791810
@@ -798,7 +817,7 @@ QScriptValue ScriptEngine::evaluate(const QString& sourceCode, const QString& fi · 6 unmodified lines
798817 if (QThread::currentThread() != thread()) {
799818 QScriptValue result;
800819 #ifdef THREAD_DEBUGGING
801− qDebug() << "*** WARNING *** ScriptEngine::evaluate() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
820+ qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::evaluate() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
802821 "sourceCode:" << sourceCode << " fileName:" << fileName << "lineNumber:" << lineNumber;
803822 #endif
804823 QMetaObject::invokeMethod(this, "evaluate", Qt::BlockingQueuedConnection,
@@ -811,7 +830,7 @@ QScriptValue ScriptEngine::evaluate(const QString& sourceCode, const QString& fi · 6 unmodified lines
811830
812831 // Check syntax
813832 const QScriptProgram program(sourceCode, fileName, lineNumber);
814− if (!hasCorrectSyntax(program)) {
833+ if (!hasCorrectSyntax(program, this)) {
815834 return QScriptValue();
816835 }
817836
@@ -819,7 +838,7 @@ QScriptValue ScriptEngine::evaluate(const QString& sourceCode, const QString& fi · 1 unmodified line
819838 const auto result = QScriptEngine::evaluate(program);
820839 --_evaluatesPending;
821840
822− const auto hadUncaughtException = hadUncaughtExceptions(*this, program.fileName());
841+ const auto hadUncaughtException = hadUncaughtExceptions(*this, program.fileName(), this);
823842 emit evaluationFinished(result, hadUncaughtException);
824843 return result;
825844 }
@@ -863,23 +882,48 @@ void ScriptEngine::run() { · 37 unmodified lines
863882 // Throttle to SCRIPT_FPS
864883 // We'd like to try to keep the script at a solid SCRIPT_FPS update rate. And so we will
865884 // calculate a sleepUntil to be the time from our start time until the original target
866− // sleepUntil for this frame.
867− const std::chrono::microseconds FRAME_DURATION(USECS_PER_SECOND / SCRIPT_FPS + 1);
868− clock::time_point targetSleepUntil(startTime + thisFrame++ * FRAME_DURATION);
869−
870− // However, if our sleepUntil is not at least our average update time into the future
871− // it means our script is taking too long in it's updates, and we want to punish the
872− // script a little bit. So we will force the sleepUntil to be at least our averageUpdate
873− // time into the future.
885+ // sleepUntil for this frame. This approach will allow us to "catch up" in the event
886+ // that some of our script udpates/frames take a little bit longer than the target average
887+ // to execute.
888+ // NOTE: if we go to variable SCRIPT_FPS, then we will need to reconsider this approach
889+ const std::chrono::microseconds TARGET_SCRIPT_FRAME_DURATION(USECS_PER_SECOND / SCRIPT_FPS + 1);
890+ clock::time_point targetSleepUntil(startTime + (thisFrame++ * TARGET_SCRIPT_FRAME_DURATION));
891+
892+ // However, if our sleepUntil is not at least our average update and timer execution time
893+ // into the future it means our script is taking too long in its updates, and we want to
894+ // punish the script a little bit. So we will force the sleepUntil to be at least our
895+ // averageUpdate + averageTimerPerFrame time into the future.
874896 auto averageUpdate = totalUpdates / thisFrame;
875− auto sleepUntil = std::max(targetSleepUntil, beforeSleep + averageUpdate);
897+ auto averageTimerPerFrame = _totalTimerExecution / thisFrame;
898+ auto averageTimerAndUpdate = averageUpdate + averageTimerPerFrame;
899+ auto sleepUntil = std::max(targetSleepUntil, beforeSleep + averageTimerAndUpdate);
876900
877901 // We don't want to actually sleep for too long, because it causes our scripts to hang
878902 // on shutdown and stop... so we want to loop and sleep until we've spent our time in
879903 // purgatory, constantly checking to see if our script was asked to end
904+ bool processedEvents = false;
880905 while (!_isFinished && clock::now() < sleepUntil) {
906+
881907 QCoreApplication::processEvents(); // before we sleep again, give events a chance to process
882− auto thisSleepUntil = std::min(sleepUntil, clock::now() + FRAME_DURATION);
908+ processedEvents = true;
909+
910+ // If after processing events, we're past due, exit asap
911+ if (clock::now() >= sleepUntil) {
912+ break;
913+ }
914+
915+ // determine how long before the next timer should fire, we'd ideally like to sleep just
916+ // that long, so the next processEvents() will allow the timers to fire on time.
917+ const std::chrono::microseconds minTimerTimeRemaining(USECS_PER_MSEC * getTimersRemainingTime());
918+
919+ // However, if we haven't yet slept at least as long as our average timer per frame, then we will
920+ // punish the timers to at least wait as long as the average run time of the timers.
921+ auto untilTimer = std::max(minTimerTimeRemaining, averageTimerPerFrame);
922+
923+ // choose the closest time point, our
924+ auto remainingSleepUntil = std::chrono::duration_cast<std::chrono::microseconds>(sleepUntil - clock::now());
925+ auto closestUntil = std::min(remainingSleepUntil, untilTimer);
926+ auto thisSleepUntil = std::min(sleepUntil, clock::now() + closestUntil);
883927 std::this_thread::sleep_until(thisSleepUntil);
884928 }
885929
@@ -904,7 +948,10 @@ void ScriptEngine::run() { · 18 unmodified lines
904948 break;
905949 }
906950
907− QCoreApplication::processEvents();
951+ // Only call this if we didn't processEvents as part of waiting for next frame
952+ if (!processedEvents) {
953+ QCoreApplication::processEvents();
954+ }
908955
909956 if (_isFinished) {
910957 break;
@@ -936,10 +983,10 @@ void ScriptEngine::run() { · 25 unmodified lines
936983 _lastUpdate = now;
937984
938985 // Debug and clear exceptions
939− hadUncaughtExceptions(*this, _fileNameString);
986+ hadUncaughtExceptions(*this, _fileNameString, this);
940987 }
941988
942− qCDebug(scriptengine) << "Script Engine stopping:" << getFilename();
989+ scriptInfoMessage("Script Engine stopping:" + getFilename());
943990
944991 stopAllTimers(); // make sure all our timers are stopped if the script is ending
945992 emit scriptEnding();
@@ -967,6 +1014,21 @@ void ScriptEngine::run() { · 21 unmodified lines
9671014 emit doneRunning();
9681015 }
9691016
1017+quint64 ScriptEngine::getTimersRemainingTime() {
1018+ quint64 minimumTime = USECS_PER_SECOND; // anything larger than this can be ignored
1019+ QMutableHashIterator<QTimer*, CallbackData> i(_timerFunctionMap);
1020+ while (i.hasNext()) {
1021+ i.next();
1022+ QTimer* timer = i.key();
1023+ int remainingTime = timer->remainingTime();
1024+ if (remainingTime >= 0) {
1025+ minimumTime = std::min((quint64)remainingTime, minimumTime);
1026+ }
1027+ }
1028+ return minimumTime;
1029+}
1030+
1031+
9701032 // NOTE: This is private because it must be called on the same thread that created the timers, which is why
9711033 // we want to only call it in our own run "shutdown" processing.
9721034 void ScriptEngine::stopAllTimers() {
@@ -1012,7 +1074,7 @@ void ScriptEngine::stop(bool marshal) { · 39 unmodified lines
10121074 void ScriptEngine::callAnimationStateHandler(QScriptValue callback, AnimVariantMap parameters, QStringList names, bool useNames, AnimVariantResultHandler resultHandler) {
10131075 if (QThread::currentThread() != thread()) {
10141076 #ifdef THREAD_DEBUGGING
1015− qDebug() << "*** WARNING *** ScriptEngine::callAnimationStateHandler() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] name:" << name;
1077+ qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::callAnimationStateHandler() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] name:" << name;
10161078 #endif
10171079 QMetaObject::invokeMethod(this, "callAnimationStateHandler",
10181080 Q_ARG(QScriptValue, callback),
@@ -1046,7 +1108,7 @@ void ScriptEngine::timerFired() { · 27 unmodified lines
10461108 {
10471109 auto engine = DependencyManager::get<ScriptEngines>();
10481110 if (!engine || engine->isStopped()) {
1049− qCDebug(scriptengine) << "Script.timerFired() while shutting down is ignored... parent script:" << getFilename();
1111+ scriptWarningMessage("Script.timerFired() while shutting down is ignored... parent script:" + getFilename());
10501112 return; // bail early
10511113 }
10521114 }
@@ -1062,7 +1124,12 @@ void ScriptEngine::timerFired() { · 9 unmodified lines
10621124
10631125 // call the associated JS function, if it exists
10641126 if (timerData.function.isValid()) {
1127+ auto preTimer = p_high_resolution_clock::now();
10651128 callWithEnvironment(timerData.definingEntityIdentifier, timerData.definingSandboxURL, timerData.function, timerData.function, QScriptValueList());
1129+ auto postTimer = p_high_resolution_clock::now();
1130+ auto elapsed = (postTimer - preTimer);
1131+ _totalTimerExecution += std::chrono::duration_cast<std::chrono::microseconds>(elapsed);
1132+
10661133 }
10671134 }
10681135
@@ -1072,12 +1139,18 @@ QObject* ScriptEngine::setupTimerWithInterval(const QScriptValue& function, int · 3 unmodified lines
10721139 QTimer* newTimer = new QTimer(this);
10731140 newTimer->setSingleShot(isSingleShot);
10741141
1142+ // The default timer type is not very accurate below about 200ms http://doc.qt.io/qt-5/qt.html#TimerType-enum
1143+ static const int MIN_TIMEOUT_FOR_COARSE_TIMER = 200;
1144+ if (intervalMS < MIN_TIMEOUT_FOR_COARSE_TIMER) {
1145+ newTimer->setTimerType(Qt::PreciseTimer);
1146+ }
1147+
10751148 connect(newTimer, &QTimer::timeout, this, &ScriptEngine::timerFired);
10761149
10771150 // make sure the timer stops when the script does
10781151 connect(this, &ScriptEngine::scriptEnding, newTimer, &QTimer::stop);
10791152
1080− CallbackData timerData = {function, currentEntityIdentifier, currentSandboxURL};
1153+ CallbackData timerData = {function, currentEntityIdentifier, currentSandboxURL };
10811154 _timerFunctionMap.insert(newTimer, timerData);
10821155
10831156 newTimer->start(intervalMS);
@@ -1086,7 +1159,7 @@ QObject* ScriptEngine::setupTimerWithInterval(const QScriptValue& function, int · 2 unmodified lines
10861159
10871160 QObject* ScriptEngine::setInterval(const QScriptValue& function, int intervalMS) {
10881161 if (DependencyManager::get<ScriptEngines>()->isStopped()) {
1089− qCDebug(scriptengine) << "Script.setInterval() while shutting down is ignored... parent script:" << getFilename();
1162+ scriptWarningMessage("Script.setInterval() while shutting down is ignored... parent script:" + getFilename());
10901163 return NULL; // bail early
10911164 }
10921165
@@ -1095,7 +1168,7 @@ QObject* ScriptEngine::setInterval(const QScriptValue& function, int intervalMS) · 2 unmodified lines
10951168
10961169 QObject* ScriptEngine::setTimeout(const QScriptValue& function, int timeoutMS) {
10971170 if (DependencyManager::get<ScriptEngines>()->isStopped()) {
1098− qCDebug(scriptengine) << "Script.setTimeout() while shutting down is ignored... parent script:" << getFilename();
1171+ scriptWarningMessage("Script.setTimeout() while shutting down is ignored... parent script:" + getFilename());
10991172 return NULL; // bail early
11001173 }
11011174
@@ -1155,8 +1228,8 @@ void ScriptEngine::print(const QString& message) { · 53 unmodified lines
11551228 // all of the files have finished loading.
11561229 void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callback) {
11571230 if (DependencyManager::get<ScriptEngines>()->isStopped()) {
1158− qCDebug(scriptengine) << "Script.include() while shutting down is ignored..."
1159− << "includeFiles:" << includeFiles << "parent script:" << getFilename();
1231+ scriptWarningMessage("Script.include() while shutting down is ignored... includeFiles:"
1232+ + includeFiles.join(",") + "parent script:" + getFilename());
11601233 return; // bail early
11611234 }
11621235 QList<QUrl> urls;
@@ -1176,14 +1249,15 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac · 13 unmodified lines
11761249 // Guard against meaningless query and fragment parts.
11771250 // Do NOT use PreferLocalFile as its behavior is unpredictable (e.g., on defaultScriptsLocation())
11781251 const auto strippingFlags = QUrl::RemoveFilename | QUrl::RemoveQuery | QUrl::RemoveFragment;
1179− for (QString file : includeFiles) {
1252+ for (QString includeFile : includeFiles) {
1253+ QString file = ResourceManager::normalizeURL(includeFile);
11801254 QUrl thisURL;
11811255 bool isStandardLibrary = false;
11821256 if (file.startsWith("/~/")) {
11831257 thisURL = expandScriptUrl(QUrl::fromLocalFile(expandScriptPath(file)));
11841258 QUrl defaultScriptsLoc = defaultScriptsLocation();
11851259 if (!defaultScriptsLoc.isParentOf(thisURL)) {
1186− qDebug() << "ScriptEngine::include -- skipping" << file << "-- outside of standard libraries";
1260+ scriptWarningMessage("Script.include() -- skipping" + file + "-- outside of standard libraries");
11871261 continue;
11881262 }
11891263 isStandardLibrary = true;
@@ -1191,20 +1265,16 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac · 1 unmodified line
11911265 thisURL = resolvePath(file);
11921266 }
11931267
1194− if (!_includedURLs.contains(thisURL)) {
1195− if (!isStandardLibrary && !currentSandboxURL.isEmpty() && (thisURL.scheme() == "file") &&
1196− (currentSandboxURL.scheme() != "file" ||
1197− !thisURL.toString(strippingFlags).startsWith(currentSandboxURL.toString(strippingFlags), getSensitivity()))) {
1198− qCWarning(scriptengine) << "Script.include() ignoring file path"
1199− << thisURL << "outside of original entity script" << currentSandboxURL;
1200− } else {
1201− // We could also check here for CORS, but we don't yet.
1202− // It turns out that QUrl.resolve will not change hosts and copy authority, so we don't need to check that here.
1203− urls.append(thisURL);
1204− _includedURLs << thisURL;
1205− }
1268+ if (!isStandardLibrary && !currentSandboxURL.isEmpty() && (thisURL.scheme() == "file") &&
1269+ (currentSandboxURL.scheme() != "file" ||
1270+ !thisURL.toString(strippingFlags).startsWith(currentSandboxURL.toString(strippingFlags), getSensitivity()))) {
1271+
1272+ scriptWarningMessage("Script.include() ignoring file path" + thisURL.toString()
1273+ + "outside of original entity script" + currentSandboxURL.toString());
12061274 } else {
1207− qCDebug(scriptengine) << "Script.include() ignoring previously included url:" << thisURL;
1275+ // We could also check here for CORS, but we don't yet.
1276+ // It turns out that QUrl.resolve will not change hosts and copy authority, so we don't need to check that here.
1277+ urls.append(thisURL);
12081278 }
12091279 }
12101280
@@ -1222,15 +1292,22 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac · 11 unmodified lines
12221292 for (QUrl url : urls) {
12231293 QString contents = data[url];
12241294 if (contents.isNull()) {
1225− qCDebug(scriptengine) << "Error loading file: " << url << "line:" << __LINE__;
1295+ scriptErrorMessage("Error loading file: " + url.toString());
12261296 } else {
1227− // Set the parent url so that path resolution will be relative
1228− // to this script's url during its initial evaluation
1229− _parentURL = url.toString();
1230− auto operation = [&]() {
1231− evaluate(contents, url.toString());
1232− };
1233− doWithEnvironment(capturedEntityIdentifier, capturedSandboxURL, operation);
1297+ std::lock_guard<std::recursive_mutex> lock(_lock);
1298+ if (!_includedURLs.contains(url)) {
1299+ _includedURLs << url;
1300+ // Set the parent url so that path resolution will be relative
1301+ // to this script's url during its initial evaluation
1302+ _parentURL = url.toString();
1303+ auto operation = [&]() {
1304+ evaluate(contents, url.toString());
1305+ };
1306+
1307+ doWithEnvironment(capturedEntityIdentifier, capturedSandboxURL, operation);
1308+ } else {
1309+ scriptWarningMessage("Script.include() skipping evaluation of previously included url:" + url.toString());
1310+ }
12341311 }
12351312 }
12361313 _parentURL = parentURL;
@@ -1258,8 +1335,8 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac · 21 unmodified lines
12581335
12591336 void ScriptEngine::include(const QString& includeFile, QScriptValue callback) {
12601337 if (DependencyManager::get<ScriptEngines>()->isStopped()) {
1261− qCDebug(scriptengine) << "Script.include() while shutting down is ignored... "
1262− << "includeFile:" << includeFile << "parent script:" << getFilename();
1338+ scriptWarningMessage("Script.include() while shutting down is ignored... includeFile:"
1339+ + includeFile + "parent script:" + getFilename());
12631340 return; // bail early
12641341 }
12651342
@@ -1273,13 +1350,13 @@ void ScriptEngine::include(const QString& includeFile, QScriptValue callback) { · 7 unmodified lines
12731350 // the Application or other context will connect to in order to know to actually load the script
12741351 void ScriptEngine::load(const QString& loadFile) {
12751352 if (DependencyManager::get<ScriptEngines>()->isStopped()) {
1276− qCDebug(scriptengine) << "Script.load() while shutting down is ignored... "
1277− << "loadFile:" << loadFile << "parent script:" << getFilename();
1353+ scriptWarningMessage("Script.load() while shutting down is ignored... loadFile:"
1354+ + loadFile + "parent script:" + getFilename());
12781355 return; // bail early
12791356 }
12801357 if (!currentEntityIdentifier.isInvalidID()) {
1281− qCWarning(scriptengine) << "Script.load() from entity script is ignored... "
1282− << "loadFile:" << loadFile << "parent script:" << getFilename();
1358+ scriptWarningMessage("Script.load() from entity script is ignored... loadFile:"
1359+ + loadFile + "parent script:" + getFilename());
12831360 return; // bail early
12841361 }
12851362
@@ -1296,7 +1373,7 @@ void ScriptEngine::load(const QString& loadFile) { · 10 unmodified lines
12961373 // Look up the handler associated with eventName and entityID. If found, evalute the argGenerator thunk and call the handler with those args
12971374 void ScriptEngine::forwardHandlerCall(const EntityItemID& entityID, const QString& eventName, QScriptValueList eventHandlerArgs) {
12981375 if (QThread::currentThread() != thread()) {
1299− qDebug() << "*** ERROR *** ScriptEngine::forwardHandlerCall() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "]";
1376+ qCDebug(scriptengine) << "*** ERROR *** ScriptEngine::forwardHandlerCall() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "]";
13001377 assert(false);
13011378 return ;
13021379 }
@@ -1330,7 +1407,7 @@ void ScriptEngine::loadEntityScript(QWeakPointer<ScriptEngine> theEngine, const · 27 unmodified lines
13301407 QSharedPointer<ScriptEngine> strongEngine = theEngine.toStrongRef();
13311408 if (strongEngine) {
13321409 #ifdef THREAD_DEBUGGING
1333− qDebug() << "ScriptEngine::entityScriptContentAvailable() IN LAMBDA contentAvailable on thread ["
1410+ qCDebug(scriptengine) << "ScriptEngine::entityScriptContentAvailable() IN LAMBDA contentAvailable on thread ["
13341411 << QThread::currentThread() << "] expected thread [" << strongEngine->thread() << "]";
13351412 #endif
13361413 strongEngine->entityScriptContentAvailable(entityID, scriptOrURL, contents, isURL, success);
@@ -1343,7 +1420,7 @@ void ScriptEngine::loadEntityScript(QWeakPointer<ScriptEngine> theEngine, const · 6 unmodified lines
13431420 void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, const QString& scriptOrURL, const QString& contents, bool isURL, bool success) {
13441421 if (QThread::currentThread() != thread()) {
13451422 #ifdef THREAD_DEBUGGING
1346− qDebug() << "*** WARNING *** ScriptEngine::entityScriptContentAvailable() called on wrong thread ["
1423+ qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::entityScriptContentAvailable() called on wrong thread ["
13471424 << QThread::currentThread() << "], invoking on correct thread [" << thread()
13481425 << "] " "entityID:" << entityID << "scriptOrURL:" << scriptOrURL << "contents:"
13491426 << contents << "isURL:" << isURL << "success:" << success;
@@ -1359,7 +1436,7 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 9 unmodified lines
13591436 }
13601437
13611438 #ifdef THREAD_DEBUGGING
1362− qDebug() << "ScriptEngine::entityScriptContentAvailable() thread [" << QThread::currentThread() << "] expected thread [" << thread() << "]";
1439+ qCDebug(scriptengine) << "ScriptEngine::entityScriptContentAvailable() thread [" << QThread::currentThread() << "] expected thread [" << thread() << "]";
13631440 #endif
13641441
13651442 auto scriptCache = DependencyManager::get<ScriptCache>();
@@ -1367,7 +1444,7 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 1 unmodified line
13671444 auto fileName = isURL ? scriptOrURL : "EmbeddedEntityScript";
13681445
13691446 QScriptProgram program(contents, fileName);
1370− if (!hasCorrectSyntax(program)) {
1447+ if (!hasCorrectSyntax(program, this)) {
13711448 if (!isFileUrl) {
13721449 scriptCache->addScriptToBadScriptList(scriptOrURL);
13731450 }
@@ -1395,7 +1472,7 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 21 unmodified lines
13951472 });
13961473 testConstructor = sandbox.evaluate(program);
13971474 }
1398− if (hadUncaughtExceptions(sandbox, program.fileName())) {
1475+ if (hadUncaughtExceptions(sandbox, program.fileName(), this)) {
13991476 return;
14001477 }
14011478
@@ -1409,10 +1486,10 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 7 unmodified lines
14091486 if (testConstructorValue.size() > maxTestConstructorValueSize) {
14101487 testConstructorValue = testConstructorValue.mid(0, maxTestConstructorValueSize) + "...";
14111488 }
1412− qCDebug(scriptengine) << "Error -- ScriptEngine::loadEntityScript() entity:" << entityID
1413− << "failed to load entity script -- expected a function, got " + testConstructorType
1414− << "," << testConstructorValue
1415− << "," << scriptOrURL;
1489+ scriptErrorMessage("Error -- ScriptEngine::loadEntityScript() entity:" + entityID.toString()
1490+ + "failed to load entity script -- expected a function, got " + testConstructorType
1491+ + "," + testConstructorValue
1492+ + "," + scriptOrURL);
14161493
14171494 if (!isFileUrl) {
14181495 scriptCache->addScriptToBadScriptList(scriptOrURL);
@@ -1447,7 +1524,7 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 28 unmodified lines
14471524 void ScriptEngine::unloadEntityScript(const EntityItemID& entityID) {
14481525 if (QThread::currentThread() != thread()) {
14491526 #ifdef THREAD_DEBUGGING
1450− qDebug() << "*** WARNING *** ScriptEngine::unloadEntityScript() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
1527+ qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::unloadEntityScript() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
14511528 "entityID:" << entityID;
14521529 #endif
14531530
@@ -1456,7 +1533,7 @@ void ScriptEngine::unloadEntityScript(const EntityItemID& entityID) { · 2 unmodified lines
14561533 return;
14571534 }
14581535 #ifdef THREAD_DEBUGGING
1459− qDebug() << "ScriptEngine::unloadEntityScript() called on correct thread [" << thread() << "] "
1536+ qCDebug(scriptengine) << "ScriptEngine::unloadEntityScript() called on correct thread [" << thread() << "] "
14601537 "entityID:" << entityID;
14611538 #endif
14621539
@@ -1470,14 +1547,14 @@ void ScriptEngine::unloadEntityScript(const EntityItemID& entityID) { · 7 unmodified lines
14701547 void ScriptEngine::unloadAllEntityScripts() {
14711548 if (QThread::currentThread() != thread()) {
14721549 #ifdef THREAD_DEBUGGING
1473− qDebug() << "*** WARNING *** ScriptEngine::unloadAllEntityScripts() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "]";
1550+ qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::unloadAllEntityScripts() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "]";
14741551 #endif
14751552
14761553 QMetaObject::invokeMethod(this, "unloadAllEntityScripts");
14771554 return;
14781555 }
14791556 #ifdef THREAD_DEBUGGING
1480− qDebug() << "ScriptEngine::unloadAllEntityScripts() called on correct thread [" << thread() << "]";
1557+ qCDebug(scriptengine) << "ScriptEngine::unloadAllEntityScripts() called on correct thread [" << thread() << "]";
14811558 #endif
14821559 foreach(const EntityItemID& entityID, _entityScripts.keys()) {
14831560 callEntityScriptMethod(entityID, "unload");
@@ -1485,13 +1562,13 @@ void ScriptEngine::unloadAllEntityScripts() { · 1 unmodified line
14851562 _entityScripts.clear();
14861563
14871564 #ifdef DEBUG_ENGINE_STATE
1488− qDebug() << "---- CURRENT STATE OF ENGINE: --------------------------";
1565+ qCDebug(scriptengine) << "---- CURRENT STATE OF ENGINE: --------------------------";
14891566 QScriptValueIterator it(globalObject());
14901567 while (it.hasNext()) {
14911568 it.next();
1492− qDebug() << it.name() << ":" << it.value().toString();
1569+ qCDebug(scriptengine) << it.name() << ":" << it.value().toString();
14931570 }
1494− qDebug() << "--------------------------------------------------------";
1571+ qCDebug(scriptengine) << "--------------------------------------------------------";
14951572 #endif // DEBUG_ENGINE_STATE
14961573 }
14971574
@@ -1512,7 +1589,7 @@ void ScriptEngine::refreshFileScript(const EntityItemID& entityID) { · 14 unmodified lines
15121589 QString filePath = QUrl(details.scriptText).toLocalFile();
15131590 auto lastModified = QFileInfo(filePath).lastModified().toMSecsSinceEpoch();
15141591 if (lastModified > details.lastModified) {
1515− qCDebug(scriptengine) << "Reloading modified script " << details.scriptText;
1592+ scriptInfoMessage("Reloading modified script " + details.scriptText);
15161593
15171594 QFile file(filePath);
15181595 file.open(QIODevice::ReadOnly);
@@ -1520,7 +1597,7 @@ void ScriptEngine::refreshFileScript(const EntityItemID& entityID) { · 1 unmodified line
15201597 this->unloadEntityScript(entityID);
15211598 this->entityScriptContentAvailable(entityID, details.scriptText, scriptContents, true, true);
15221599 if (!_entityScripts.contains(entityID)) {
1523− qWarning() << "Reload script " << details.scriptText << " failed";
1600+ scriptWarningMessage("Reload script " + details.scriptText + " failed");
15241601 } else {
15251602 details = _entityScripts[entityID];
15261603 }
@@ -1547,7 +1624,7 @@ void ScriptEngine::doWithEnvironment(const EntityItemID& entityID, const QUrl& s · 20 unmodified lines
15471624 #else
15481625 operation();
15491626 #endif
1550− hadUncaughtExceptions(*this, _fileNameString);
1627+ hadUncaughtExceptions(*this, _fileNameString, this);
15511628
15521629 currentEntityIdentifier = oldIdentifier;
15531630 currentSandboxURL = oldSandboxURL;
@@ -1562,7 +1639,7 @@ void ScriptEngine::callWithEnvironment(const EntityItemID& entityID, const QUrl& · 8 unmodified lines
15621639 void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName, const QStringList& params) {
15631640 if (QThread::currentThread() != thread()) {
15641641 #ifdef THREAD_DEBUGGING
1565− qDebug() << "*** WARNING *** ScriptEngine::callEntityScriptMethod() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
1642+ qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::callEntityScriptMethod() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
15661643 "entityID:" << entityID << "methodName:" << methodName;
15671644 #endif
15681645
@@ -1573,7 +1650,7 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 4 unmodified lines
15731650 return;
15741651 }
15751652 #ifdef THREAD_DEBUGGING
1576− qDebug() << "ScriptEngine::callEntityScriptMethod() called on correct thread [" << thread() << "] "
1653+ qCDebug(scriptengine) << "ScriptEngine::callEntityScriptMethod() called on correct thread [" << thread() << "] "
15771654 "entityID:" << entityID << "methodName:" << methodName;
15781655 #endif
15791656
@@ -1594,7 +1671,7 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 14 unmodified lines
15941671 void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName, const PointerEvent& event) {
15951672 if (QThread::currentThread() != thread()) {
15961673 #ifdef THREAD_DEBUGGING
1597− qDebug() << "*** WARNING *** ScriptEngine::callEntityScriptMethod() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
1674+ qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::callEntityScriptMethod() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
15981675 "entityID:" << entityID << "methodName:" << methodName << "event: mouseEvent";
15991676 #endif
16001677
@@ -1605,7 +1682,7 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 4 unmodified lines
16051682 return;
16061683 }
16071684 #ifdef THREAD_DEBUGGING
1608− qDebug() << "ScriptEngine::callEntityScriptMethod() called on correct thread [" << thread() << "] "
1685+ qCDebug(scriptengine) << "ScriptEngine::callEntityScriptMethod() called on correct thread [" << thread() << "] "
16091686 "entityID:" << entityID << "methodName:" << methodName << "event: pointerEvent";
16101687 #endif
16111688
@@ -1626,7 +1703,7 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 14 unmodified lines
16261703 void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName, const EntityItemID& otherID, const Collision& collision) {
16271704 if (QThread::currentThread() != thread()) {
16281705 #ifdef THREAD_DEBUGGING
1629− qDebug() << "*** WARNING *** ScriptEngine::callEntityScriptMethod() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
1706+ qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::callEntityScriptMethod() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
16301707 "entityID:" << entityID << "methodName:" << methodName << "otherID:" << otherID << "collision: collision";
16311708 #endif
16321709
@@ -1638,7 +1715,7 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 5 unmodified lines
16381715 return;
16391716 }
16401717 #ifdef THREAD_DEBUGGING
1641− qDebug() << "ScriptEngine::callEntityScriptMethod() called on correct thread [" << thread() << "] "
1718+ qCDebug(scriptengine) << "ScriptEngine::callEntityScriptMethod() called on correct thread [" << thread() << "] "
16421719 "entityID:" << entityID << "methodName:" << methodName << "otherID:" << otherID << "collision: collision";
16431720 #endif
16441721