History

ifdef around massive debug output

ZappoMan committed 11 years ago

Commit 87576001 parent ca432a41 file · +76 −73Browse files

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

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+76−73
@@ -41,6 +41,13 @@ · 40 unmodified lines
41 41
42#include "MIDIEvent.h"42#include "MIDIEvent.h"
43 43
44
45#ifdef WANT_DEBUG_SCRIPT_ENDING
46#define DEBUG_SCRIPT_ENDING(X) X
47#else
48#define DEBUG_SCRIPT_ENDING(x)
49#endif
50
44EntityScriptingInterface ScriptEngine::_entityScriptingInterface;51EntityScriptingInterface ScriptEngine::_entityScriptingInterface;
45 52
46static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){53static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){
@@ -100,7 +107,7 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNam · 53 unmodified lines
100}107}
101 108
102ScriptEngine::~ScriptEngine() {109ScriptEngine::~ScriptEngine() {
103 qDebug() << "ScriptEngine::~ScriptEngine() ------- BEGIN ------- script:" << getFilename();110 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::~ScriptEngine() ------- BEGIN ------- script:" << getFilename();)
104 // If we're not already in the middle of stopping all scripts, then we should remove ourselves111 // If we're not already in the middle of stopping all scripts, then we should remove ourselves
105 // from the list of running scripts. We don't do this if we're in the process of stopping all scripts112 // from the list of running scripts. We don't do this if we're in the process of stopping all scripts
106 // because that method removes scripts from its list as it iterates them113 // because that method removes scripts from its list as it iterates them
@@ -109,7 +116,7 @@ ScriptEngine::~ScriptEngine() { · 2 unmodified lines
109 _allKnownScriptEngines.remove(this);116 _allKnownScriptEngines.remove(this);
110 _allScriptsMutex.unlock();117 _allScriptsMutex.unlock();
111 }118 }
112 qDebug() << "ScriptEngine::~ScriptEngine() ------- END ------- script:" << getFilename();119 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::~ScriptEngine() ------- END ------- script:" << getFilename();)
113}120}
114 121
115QSet<ScriptEngine*> ScriptEngine::_allKnownScriptEngines;122QSet<ScriptEngine*> ScriptEngine::_allKnownScriptEngines;
@@ -118,7 +125,7 @@ bool ScriptEngine::_stoppingAllScripts = false; · 2 unmodified lines
118bool ScriptEngine::_doneRunningThisScript = false;125bool ScriptEngine::_doneRunningThisScript = false;
119 126
120void ScriptEngine::stopAllScripts(QObject* application) {127void ScriptEngine::stopAllScripts(QObject* application) {
121 qDebug() << "ScriptEngine::stopAllScripts() ------- BEGIN -------";128 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::stopAllScripts() ------- BEGIN -------";)
122 129
123 _allScriptsMutex.lock();130 _allScriptsMutex.lock();
124 _stoppingAllScripts = true;131 _stoppingAllScripts = true;
@@ -129,9 +136,9 @@ void ScriptEngine::stopAllScripts(QObject* application) { · 4 unmodified lines
129 136
130 QString scriptName = scriptEngine->getFilename();137 QString scriptName = scriptEngine->getFilename();
131 138
132 qDebug() << "ScriptEngine::stopAllScripts() considering:" << scriptName 139 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::stopAllScripts() considering:" << scriptName
133 << "isRunning():" << scriptEngine->isRunning()140 << "isRunning():" << scriptEngine->isRunning()
134 << "evaluatePending():" << scriptEngine->evaluatePending();141 << "evaluatePending():" << scriptEngine->evaluatePending();)
135 142
136 // NOTE: typically all script engines are running. But there's at least one known exception to this, the143 // NOTE: typically all script engines are running. But there's at least one known exception to this, the
137 // "entities sandbox" which is only used to evaluate entities scripts to test their validity before using144 // "entities sandbox" which is only used to evaluate entities scripts to test their validity before using
@@ -144,38 +151,34 @@ void ScriptEngine::stopAllScripts(QObject* application) { · 6 unmodified lines
144 while (scriptEngine->evaluatePending()) {151 while (scriptEngine->evaluatePending()) {
145 QEventLoop loop;152 QEventLoop loop;
146 QObject::connect(scriptEngine, &ScriptEngine::evaluationFinished, &loop, &QEventLoop::quit);153 QObject::connect(scriptEngine, &ScriptEngine::evaluationFinished, &loop, &QEventLoop::quit);
147 qDebug() << "ScriptEngine::stopAllScripts() while(evaluatePending()) STARTING loop.exec() script:" << scriptName;154 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::stopAllScripts() while(evaluatePending()) STARTING loop.exec() script:" << scriptName;)
148 loop.exec();155 loop.exec();
149 qDebug() << "ScriptEngine::stopAllScripts() while(evaluatePending()) AFTER loop.exec() script:" << scriptName;156 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::stopAllScripts() while(evaluatePending()) AFTER loop.exec() script:" << scriptName;)
150 }157 }
151 }158 }
152 159
153 scriptEngine->disconnect(application);160 scriptEngine->disconnect(application);
154 scriptEngine->stop();161 scriptEngine->stop();
155 162
156 qDebug() << "ScriptEngine::stopAllScripts() -- WAITING for waitTillDoneRunning() script:" << scriptName;163 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::stopAllScripts() -- WAITING for waitTillDoneRunning() script:" << scriptName;)
157 scriptEngine->waitTillDoneRunning();164 scriptEngine->waitTillDoneRunning();
158 qDebug() << "ScriptEngine::stopAllScripts() -- AFTER waitTillDoneRunning() script:" << scriptName;165 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::stopAllScripts() -- AFTER waitTillDoneRunning() script:" << scriptName;)
159 i.remove();166 i.remove();
160 } else {167 } else {
161 }168 }
162 }169 }
163 _stoppingAllScripts = false;170 _stoppingAllScripts = false;
164 _allScriptsMutex.unlock();171 _allScriptsMutex.unlock();
165 qDebug() << "ScriptEngine::stopAllScripts() ------- DONE -------";172 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::stopAllScripts() ------- DONE -------";)
166}173}
167 174
168 175
169void ScriptEngine::waitTillDoneRunning() {176void ScriptEngine::waitTillDoneRunning() {
170 QString scriptName = getFilename();177 QString scriptName = getFilename();
171 qDebug() << "ScriptEngine::waitTillDoneRunning() ------- BEGIN ------- script:" << scriptName;178 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::waitTillDoneRunning() ------- BEGIN ------- script:" << scriptName;)
172 qDebug() << " _isFinished:" << _isFinished;
173 qDebug() << " _isRunning:" << _isRunning;
174 qDebug() << " _isInitialized:" << _isInitialized;
175 qDebug() << " _evaluatesPending:" << _evaluatesPending;
176 179
177 if (_isRunning) {180 if (_isRunning) {
178 qDebug() << "ScriptEngine::waitTillDoneRunning() SETTING _doneRunningThisScript = false ################################### line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";181 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::waitTillDoneRunning() SETTING _doneRunningThisScript = false ################################### line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
179 _doneRunningThisScript = false;182 _doneRunningThisScript = false;
180 _isWaitingForDoneRunning = true;183 _isWaitingForDoneRunning = true;
181 184
@@ -188,23 +191,23 @@ void ScriptEngine::waitTillDoneRunning() { · 6 unmodified lines
188 // and run a QEventLoop???191 // and run a QEventLoop???
189 QEventLoop loop;192 QEventLoop loop;
190 QObject::connect(this, &ScriptEngine::doneRunning, &loop, &QEventLoop::quit);193 QObject::connect(this, &ScriptEngine::doneRunning, &loop, &QEventLoop::quit);
191 qDebug() << "ScriptEngine::waitTillDoneRunning() STARTING loop.exec() script:" << scriptName;194 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::waitTillDoneRunning() STARTING loop.exec() script:" << scriptName;)
192 qDebug() << " _doneRunningThisScript:" << _doneRunningThisScript;195 DEBUG_SCRIPT_ENDING(qDebug() << " _doneRunningThisScript:" << _doneRunningThisScript;)
193 qDebug() << " _isRunning:" << _isRunning;196 DEBUG_SCRIPT_ENDING(qDebug() << " _isRunning:" << _isRunning;)
194 qDebug() << " _isWaitingForDoneRunning:" << _isWaitingForDoneRunning;197 DEBUG_SCRIPT_ENDING(qDebug() << " _isWaitingForDoneRunning:" << _isWaitingForDoneRunning;)
195 qDebug() << " _isFinished:" << _isFinished;198 DEBUG_SCRIPT_ENDING(qDebug() << " _isFinished:" << _isFinished;)
196 qDebug() << " _isInitialized:" << _isInitialized;199 DEBUG_SCRIPT_ENDING(qDebug() << " _isInitialized:" << _isInitialized;)
197 qDebug() << " _evaluatesPending:" << _evaluatesPending;200 DEBUG_SCRIPT_ENDING(qDebug() << " _evaluatesPending:" << _evaluatesPending;)
198 loop.exec();201 loop.exec();
199 qDebug() << "ScriptEngine::waitTillDoneRunning() AFTER loop.exec() script:" << scriptName;202 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::waitTillDoneRunning() AFTER loop.exec() script:" << scriptName;)
200 203
201 // process events204 // process events
202 qDebug() << "ScriptEngine::waitTillDoneRunning() STARTING QCoreApplication::processEvents() script:" << scriptName;205 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::waitTillDoneRunning() STARTING QCoreApplication::processEvents() script:" << scriptName;)
203 QCoreApplication::processEvents();206 QCoreApplication::processEvents();
204 qDebug() << "ScriptEngine::waitTillDoneRunning() AFTER QCoreApplication::processEvents() script:" << scriptName;207 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::waitTillDoneRunning() AFTER QCoreApplication::processEvents() script:" << scriptName;)
205 208
206 if (_doneRunningThisScript) {209 if (_doneRunningThisScript) {
207 qDebug() << "ScriptEngine::waitTillDoneRunning() _doneRunningThisScript after processEvents... breaking!!! script:" << scriptName;210 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::waitTillDoneRunning() _doneRunningThisScript after processEvents... breaking!!! script:" << scriptName;)
208 break;211 break;
209 }212 }
210 }213 }
@@ -212,7 +215,7 @@ void ScriptEngine::waitTillDoneRunning() { · 1 unmodified line
212 _isWaitingForDoneRunning = false;215 _isWaitingForDoneRunning = false;
213 }216 }
214 217
215 qDebug() << "ScriptEngine::waitTillDoneRunning() ------- DONE ------- script:" << scriptName;218 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::waitTillDoneRunning() ------- DONE ------- script:" << scriptName;)
216}219}
217 220
218QString ScriptEngine::getFilename() const { 221QString ScriptEngine::getFilename() const {
@@ -430,20 +433,20 @@ void ScriptEngine::evaluate() { · 211 unmodified lines
430 return; // bail early433 return; // bail early
431 }434 }
432 435
433 qDebug() << "ScriptEngine::evaluate() -- BEGIN script:" << getFilename() << "[" << this << "]";436 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::evaluate() -- BEGIN script:" << getFilename() << "[" << this << "]";)
434 if (!_isInitialized) {437 if (!_isInitialized) {
435 init();438 init();
436 }439 }
437 440
438 qDebug() << "ScriptEngine::evaluate() -- about to call own evaluate(program) script:" << getFilename() << "[" << this << "]";441 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::evaluate() -- about to call own evaluate(program) script:" << getFilename() << "[" << this << "]";)
439 QScriptValue result = evaluate(_scriptContents);442 QScriptValue result = evaluate(_scriptContents);
440 qDebug() << "ScriptEngine::evaluate() -- AFTER own evaluate(program) script:" << getFilename() << "[" << this << "]";443 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::evaluate() -- AFTER own evaluate(program) script:" << getFilename() << "[" << this << "]";)
441 444
442 // TODO: why do we check this twice? It seems like the call to clearExcpetions() in the lower level evaluate call445 // TODO: why do we check this twice? It seems like the call to clearExcpetions() in the lower level evaluate call
443 // will cause this code to never actually run...446 // will cause this code to never actually run...
444 if (hasUncaughtException()) {447 if (hasUncaughtException()) {
445 int line = uncaughtExceptionLineNumber();448 int line = uncaughtExceptionLineNumber();
446 qDebug() << "Uncaught exception at (" << _fileNameString << ") line" << line << ":" << result.toString();449 DEBUG_SCRIPT_ENDING(qDebug() << "Uncaught exception at (" << _fileNameString << ") line" << line << ":" << result.toString();)
447 emit errorMessage("Uncaught exception at (" + _fileNameString + ") line" + QString::number(line) + ":" + result.toString());450 emit errorMessage("Uncaught exception at (" + _fileNameString + ") line" + QString::number(line) + ":" + result.toString());
448 clearExceptions();451 clearExceptions();
449 }452 }
@@ -456,24 +459,24 @@ QScriptValue ScriptEngine::evaluate(const QString& program, const QString& fileN · 6 unmodified lines
456 return QScriptValue(); // bail early459 return QScriptValue(); // bail early
457 }460 }
458 461
459 qDebug() << "ScriptEngine::evaluate(program) -- BEGIN script:" << getFilename() << "_evaluatesPending:" << _evaluatesPending << "[" << this << "]";462 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::evaluate(program) -- BEGIN script:" << getFilename() << "_evaluatesPending:" << _evaluatesPending << "[" << this << "]";)
460 _evaluatesPending++;463 _evaluatesPending++;
461 qDebug() << "ScriptEngine::evaluate(program) -- after _evaluatesPending++ script:" << getFilename() << "_evaluatesPending:" << _evaluatesPending << "[" << this << "]";464 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::evaluate(program) -- after _evaluatesPending++ script:" << getFilename() << "_evaluatesPending:" << _evaluatesPending << "[" << this << "]";)
462 qDebug() << "ScriptEngine::evaluate(program) -- BEFORE QScriptEngine::evaluate() script:" << getFilename() << "_evaluatesPending:" << _evaluatesPending << "[" << this << "]";465 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::evaluate(program) -- BEFORE QScriptEngine::evaluate() script:" << getFilename() << "_evaluatesPending:" << _evaluatesPending << "[" << this << "]";)
463 QScriptValue result = QScriptEngine::evaluate(program, fileName, lineNumber);466 QScriptValue result = QScriptEngine::evaluate(program, fileName, lineNumber);
464 qDebug() << "ScriptEngine::evaluate(program) -- AFTER QScriptEngine::evaluate() script:" << getFilename() << "_evaluatesPending:" << _evaluatesPending << "[" << this << "]";467 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::evaluate(program) -- AFTER QScriptEngine::evaluate() script:" << getFilename() << "_evaluatesPending:" << _evaluatesPending << "[" << this << "]";)
465 if (hasUncaughtException()) {468 if (hasUncaughtException()) {
466 int line = uncaughtExceptionLineNumber();469 int line = uncaughtExceptionLineNumber();
467 qDebug() << "Uncaught exception at (" << _fileNameString << " : " << fileName << ") line" << line << ": " << result.toString();470 qDebug() << "Uncaught exception at (" << _fileNameString << " : " << fileName << ") line" << line << ": " << result.toString();
468 }471 }
469 _evaluatesPending--;472 _evaluatesPending--;
470 qDebug() << "ScriptEngine::evaluate(program) -- after _evaluatesPending-- script:" << getFilename() << "_evaluatesPending:" << _evaluatesPending << "[" << this << "]";473 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::evaluate(program) -- after _evaluatesPending-- script:" << getFilename() << "_evaluatesPending:" << _evaluatesPending << "[" << this << "]";)
471 474
472 qDebug() << "ScriptEngine::evaluate(program) -- ABOUT TO emit evaluationFinished() script:" << getFilename() << "_evaluatesPending:" << _evaluatesPending << "[" << this << "]";475 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::evaluate(program) -- ABOUT TO emit evaluationFinished() script:" << getFilename() << "_evaluatesPending:" << _evaluatesPending << "[" << this << "]";)
473 emit evaluationFinished(result, hasUncaughtException());476 emit evaluationFinished(result, hasUncaughtException());
474 qDebug() << "ScriptEngine::evaluate(program) -- AFTER emit evaluationFinished() script:" << getFilename() << "_evaluatesPending:" << _evaluatesPending << "[" << this << "]";477 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::evaluate(program) -- AFTER emit evaluationFinished() script:" << getFilename() << "_evaluatesPending:" << _evaluatesPending << "[" << this << "]";)
475 clearExceptions();478 clearExceptions();
476 qDebug() << "ScriptEngine::evaluate(program) -- DONE script:" << getFilename() << "_evaluatesPending:" << _evaluatesPending << "[" << this << "]";479 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::evaluate(program) -- DONE script:" << getFilename() << "_evaluatesPending:" << _evaluatesPending << "[" << this << "]";)
477 return result;480 return result;
478}481}
479 482
@@ -493,18 +496,18 @@ void ScriptEngine::run() { · 13 unmodified lines
493 // TODO: can we add a short circuit for _stoppingAllScripts here? What does it mean to not start running if496 // TODO: can we add a short circuit for _stoppingAllScripts here? What does it mean to not start running if
494 // we're in the process of stopping?497 // we're in the process of stopping?
495 498
496 qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";499 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
497 if (!_isInitialized) {500 if (!_isInitialized) {
498 init();501 init();
499 }502 }
500 qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";503 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
501 _isRunning = true;504 _isRunning = true;
502 _isFinished = false;505 _isFinished = false;
503 emit runningStateChanged();506 emit runningStateChanged();
504 507
505 qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";508 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
506 QScriptValue result = evaluate(_scriptContents);509 QScriptValue result = evaluate(_scriptContents);
507 qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";510 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
508 511
509 QElapsedTimer startTime;512 QElapsedTimer startTime;
510 startTime.start();513 startTime.start();
@@ -515,11 +518,11 @@ void ScriptEngine::run() { · 4 unmodified lines
515 518
516 qint64 lastUpdate = usecTimestampNow();519 qint64 lastUpdate = usecTimestampNow();
517 520
518 qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";521 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
519 522
520 while (!_isFinished) {523 while (!_isFinished) {
521 if (_isWaitingForDoneRunning) {524 if (_isWaitingForDoneRunning) {
522 qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";525 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
523 }526 }
524 527
525 int usecToSleep = (thisFrame++ * SCRIPT_DATA_CALLBACK_USECS) - startTime.nsecsElapsed() / 1000; // nsec to usec528 int usecToSleep = (thisFrame++ * SCRIPT_DATA_CALLBACK_USECS) - startTime.nsecsElapsed() / 1000; // nsec to usec
@@ -528,22 +531,22 @@ void ScriptEngine::run() { · 2 unmodified lines
528 }531 }
529 532
530 if (_isFinished) {533 if (_isFinished) {
531 qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";534 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
532 break;535 break;
533 }536 }
534 537
535 if (_isWaitingForDoneRunning) {538 if (_isWaitingForDoneRunning) {
536 qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";539 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
537 }540 }
538 541
539 QCoreApplication::processEvents();542 QCoreApplication::processEvents();
540 543
541 if (_isWaitingForDoneRunning) {544 if (_isWaitingForDoneRunning) {
542 qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";545 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
543 }546 }
544 547
545 if (_isFinished) {548 if (_isFinished) {
546 qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";549 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
547 break;550 break;
548 }551 }
549 552
@@ -673,34 +676,34 @@ void ScriptEngine::run() { · 123 unmodified lines
673 lastUpdate = now;676 lastUpdate = now;
674 677
675 if (_isWaitingForDoneRunning) {678 if (_isWaitingForDoneRunning) {
676 qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";679 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
677 }680 }
678 681
679 }682 }
680 683
681 if (_isWaitingForDoneRunning) {684 if (_isWaitingForDoneRunning) {
682 qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";685 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
683 }686 }
684 687
685 qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";688 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
686 689
687 stopAllTimers(); // make sure all our timers are stopped if the script is ending690 stopAllTimers(); // make sure all our timers are stopped if the script is ending
688 qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename();691 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename();)
689 692
690 if (_isWaitingForDoneRunning) {693 if (_isWaitingForDoneRunning) {
691 qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";694 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
692 }695 }
693 696
694 emit scriptEnding();697 emit scriptEnding();
695 qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";698 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
696 699
697 // kill the avatar identity timer700 // kill the avatar identity timer
698 delete _avatarIdentityTimer;701 delete _avatarIdentityTimer;
699 702
700 qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";703 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
701 704
702 if (_isWaitingForDoneRunning) {705 if (_isWaitingForDoneRunning) {
703 qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";706 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
704 }707 }
705 708
706 if (_entityScriptingInterface.getEntityPacketSender()->serversExist()) {709 if (_entityScriptingInterface.getEntityPacketSender()->serversExist()) {
@@ -713,43 +716,43 @@ void ScriptEngine::run() { · 6 unmodified lines
713 }716 }
714 }717 }
715 718
716 qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";719 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
717 720
718 // If we were on a thread, then wait till it's done721 // If we were on a thread, then wait till it's done
719 if (thread()) {722 if (thread()) {
720 qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";723 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
721 thread()->quit();724 thread()->quit();
722 qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";725 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
723 }726 }
724 727
725 qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";728 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
726 729
727 if (_isWaitingForDoneRunning) {730 if (_isWaitingForDoneRunning) {
728 qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";731 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
729 }732 }
730 733
731 emit finished(_fileNameString);734 emit finished(_fileNameString);
732 735
733 if (_isWaitingForDoneRunning) {736 if (_isWaitingForDoneRunning) {
734 qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";737 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
735 }738 }
736 739
737 _isRunning = false;740 _isRunning = false;
738 emit runningStateChanged();741 emit runningStateChanged();
739 742
740 qDebug() << "ABOUT TO emit doneRunning() script:" << getFilename() << "[" << this << "]";743 DEBUG_SCRIPT_ENDING(qDebug() << "ABOUT TO emit doneRunning() script:" << getFilename() << "[" << this << "]";)
741 emit doneRunning();744 emit doneRunning();
742 qDebug() << "AFTER emit doneRunning() script:" << getFilename() << "[" << this << "]";745 DEBUG_SCRIPT_ENDING(qDebug() << "AFTER emit doneRunning() script:" << getFilename() << "[" << this << "]";)
743 746
744 if (_isWaitingForDoneRunning) {747 if (_isWaitingForDoneRunning) {
745 qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";748 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
746 }749 }
747 750
748 qDebug() << "ScriptEngine::run() SETTING _doneRunningThisScript = true ################################### line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";751 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() SETTING _doneRunningThisScript = true ################################### line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
749 _doneRunningThisScript = true;752 _doneRunningThisScript = true;
750 753
751 if (_isWaitingForDoneRunning) {754 if (_isWaitingForDoneRunning) {
752 qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";755 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::run() ** _isWaitingForDoneRunning == true ** line:" << __LINE__ << " script:" << getFilename() << "[" << this << "]";)
753 }756 }
754}757}
755 758
@@ -765,10 +768,10 @@ void ScriptEngine::stopAllTimers() { · 9 unmodified lines
765}768}
766 769
767void ScriptEngine::stop() {770void ScriptEngine::stop() {
768 qDebug() << "ScriptEngine::stop() -- START -- line:" << __LINE__ << " script:" << getFilename();771 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::stop() -- START -- line:" << __LINE__ << " script:" << getFilename();)
769 _isFinished = true;772 _isFinished = true;
770 emit runningStateChanged();773 emit runningStateChanged();
771 qDebug() << "ScriptEngine::stop() -- DONE -- line:" << __LINE__ << " script:" << getFilename();774 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::stop() -- DONE -- line:" << __LINE__ << " script:" << getFilename();)
772}775}
773 776
774void ScriptEngine::timerFired() {777void ScriptEngine::timerFired() {
@@ -884,9 +887,9 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac · 109 unmodified lines
884 if (contents.isNull()) {887 if (contents.isNull()) {
885 qDebug() << "Error loading file: " << url;888 qDebug() << "Error loading file: " << url;
886 } else {889 } else {
887 qDebug() << "ScriptEngine::include() BEFORE evaluate() line:" << __LINE__ << " parent script:" << getFilename() << "[" << this << "]" << " url:" << url << "_evaluatesPending:" << _evaluatesPending;890 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::include() BEFORE evaluate() line:" << __LINE__ << " parent script:" << getFilename() << "[" << this << "]" << " url:" << url << "_evaluatesPending:" << _evaluatesPending;)
888 QScriptValue result = evaluate(contents, url.toString());891 QScriptValue result = evaluate(contents, url.toString());
889 qDebug() << "ScriptEngine::include() AFTER evaluate() line:" << __LINE__ << " parent script:" << getFilename() << "[" << this << "]" << " url:" << url << "_evaluatesPending:" << _evaluatesPending;892 DEBUG_SCRIPT_ENDING(qDebug() << "ScriptEngine::include() AFTER evaluate() line:" << __LINE__ << " parent script:" << getFilename() << "[" << this << "]" << " url:" << url << "_evaluatesPending:" << _evaluatesPending;)
890 }893 }
891 }894 }
892 895