Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 3 files). Show all
Unified · Split
| @@ -94,43 +94,33 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNam · 93 unmodified lines | ||
| 94 | 94 | _isUserLoaded(false), |
| 95 | 95 | _arrayBufferClass(new ArrayBufferClass(this)) |
| 96 | 96 | { |
| 97 | − qDebug() << "[" << QThread::currentThread() << "]" << "ScriptEngine::ScriptEngine() " << getFilename() << "[" << this << "]"; | |
| 98 | 97 | _allKnownScriptEngines.insert(this); |
| 99 | 98 | } |
| 100 | 99 | |
| 101 | 100 | ScriptEngine::~ScriptEngine() { |
| 102 | − qDebug() << "[" << QThread::currentThread() << "]" << "ScriptEngine::~ScriptEngine() " << getFilename(); | |
| 103 | 101 | _allKnownScriptEngines.remove(this); |
| 104 | 102 | } |
| 105 | 103 | |
| 106 | 104 | QSet<ScriptEngine*> ScriptEngine::_allKnownScriptEngines; |
| 107 | 105 | |
| 108 | −void ScriptEngine::gracefullyStopAllScripts(QObject* application) { | |
| 109 | − qDebug() << "[" << QThread::currentThread() << "]" << "ScriptEngine::gracefullyStopAllScripts() ----------- START ------------------"; | |
| 110 | − | |
| 111 | − | |
| 106 | +void ScriptEngine::stopAllScripts(QObject* application) { | |
| 112 | 107 | QMutableSetIterator<ScriptEngine*> i(_allKnownScriptEngines); |
| 113 | 108 | while (i.hasNext()) { |
| 114 | 109 | ScriptEngine* scriptEngine = i.next(); |
| 115 | − qDebug() << (void*)scriptEngine; | |
| 116 | − | |
| 117 | − if (scriptEngine->isRunning()) { | |
| 118 | − qDebug() << "scriptEngine still alive:" << scriptEngine->getFilename() << "[" << scriptEngine << "]"; | |
| 119 | 110 | |
| 111 | + // NOTE: typically all script engines are running. But there's at least one known exception to this, the | |
| 112 | + // "entities sandbox" which is only used to evaluate entities scripts to test their validity before using | |
| 113 | + // them. We don't need to stop scripts that aren't running. | |
| 114 | + if (scriptEngine->isRunning()) { | |
| 120 | 115 | QEventLoop loop; |
| 121 | 116 | QObject::connect(scriptEngine, &ScriptEngine::doneRunning, &loop, &QEventLoop::quit); |
| 122 | 117 | |
| 123 | 118 | scriptEngine->disconnect(application); |
| 124 | 119 | scriptEngine->stop(); |
| 125 | 120 | |
| 126 | − qDebug() << "waiting on script to stop... "; | |
| 127 | 121 | loop.exec(); |
| 128 | − qDebug() << "done waiting... "; | |
| 129 | − } else { | |
| 130 | − qDebug() << "WARNING! scriptEngine [" << (void*)scriptEngine << "] still in _allKnownScriptEngines but not running??? <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"; | |
| 131 | 122 | } |
| 132 | 123 | } |
| 133 | − qDebug() << "[" << QThread::currentThread() << "]" << "ScriptEngine::gracefullyStopAllScripts() ----------- DONE ------------------"; | |
| 134 | 124 | } |
| 135 | 125 | |
| 136 | 126 | QString ScriptEngine::getFilename() const { |
| @@ -411,14 +401,12 @@ void ScriptEngine::run() { · 274 unmodified lines | ||
| 411 | 401 | } |
| 412 | 402 | |
| 413 | 403 | if (_isFinished) { |
| 414 | − qDebug() << "ScriptEngine::run()... while() about to break " << getFilename(); | |
| 415 | 404 | break; |
| 416 | 405 | } |
| 417 | 406 | |
| 418 | 407 | QCoreApplication::processEvents(); |
| 419 | 408 | |
| 420 | 409 | if (_isFinished) { |
| 421 | − qDebug() << "ScriptEngine::run()... while() about to break " << getFilename(); | |
| 422 | 410 | break; |
| 423 | 411 | } |
| 424 | 412 | |
| @@ -548,7 +536,6 @@ void ScriptEngine::run() { · 123 unmodified lines | ||
| 548 | 536 | } |
| 549 | 537 | lastUpdate = now; |
| 550 | 538 | } |
| 551 | − qDebug() << "ScriptEngine::run()... about to emit scriptEnding() " << getFilename(); | |
| 552 | 539 | emit scriptEnding(); |
| 553 | 540 | |
| 554 | 541 | // kill the avatar identity timer |
| @@ -566,25 +553,19 @@ void ScriptEngine::run() { · 11 unmodified lines | ||
| 566 | 553 | |
| 567 | 554 | // If we were on a thread, then wait till it's done |
| 568 | 555 | if (thread()) { |
| 569 | − qDebug() << "ScriptEngine::run()... about to call thread()->quit() " << getFilename(); | |
| 570 | 556 | thread()->quit(); |
| 571 | 557 | } |
| 572 | 558 | |
| 573 | − qDebug() << "ScriptEngine::run()... about to emit finished() " << getFilename(); | |
| 574 | 559 | emit finished(_fileNameString); |
| 575 | 560 | |
| 576 | 561 | _isRunning = false; |
| 577 | 562 | |
| 578 | − qDebug() << "ScriptEngine::run()... about to emit runningStateChanged() " << getFilename(); | |
| 579 | 563 | emit runningStateChanged(); |
| 580 | 564 | |
| 581 | − qDebug() << "ScriptEngine::run()... about to emit doneRunning() " << getFilename(); | |
| 582 | 565 | emit doneRunning(); |
| 583 | − qDebug() << "ScriptEngine::run()... DONE WITH run()... " << getFilename(); | |
| 584 | 566 | } |
| 585 | 567 | |
| 586 | 568 | void ScriptEngine::stop() { |
| 587 | − qDebug() << "ScriptEngine::stop()... " << getFilename(); | |
| 588 | 569 | _isFinished = true; |
| 589 | 570 | emit runningStateChanged(); |
| 590 | 571 | } |
| @@ -666,12 +647,10 @@ void ScriptEngine::print(const QString& message) { · 75 unmodified lines | ||
| 666 | 647 | emit printedMessage(message); |
| 667 | 648 | } |
| 668 | 649 | |
| 669 | −/** | |
| 670 | − * If a callback is specified, the included files will be loaded asynchronously and the callback will be called | |
| 671 | − * when all of the files have finished loading. | |
| 672 | − * If no callback is specified, the included files will be loaded synchronously and will block execution until | |
| 673 | − * all of the files have finished loading. | |
| 674 | − */ | |
| 650 | +// If a callback is specified, the included files will be loaded asynchronously and the callback will be called | |
| 651 | +// when all of the files have finished loading. | |
| 652 | +// If no callback is specified, the included files will be loaded synchronously and will block execution until | |
| 653 | +// all of the files have finished loading. | |
| 675 | 654 | void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callback) { |
| 676 | 655 | QList<QUrl> urls; |
| 677 | 656 | for (QString file : includeFiles) { |