Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 20 files). Show all
Unified · Split
| @@ -35,6 +35,7 @@ · 34 unmodified lines | |||
| 35 | #include "MenuItemProperties.h" | 35 | #include "MenuItemProperties.h" |
| 36 | #include "ScriptAudioInjector.h" | 36 | #include "ScriptAudioInjector.h" |
| 37 | #include "ScriptCache.h" | 37 | #include "ScriptCache.h" |
| 38 | #include "ScriptEngineLogging.h" | ||
| 38 | #include "ScriptEngine.h" | 39 | #include "ScriptEngine.h" |
| 39 | #include "TypedArrays.h" | 40 | #include "TypedArrays.h" |
| 40 | #include "XMLHttpRequestClass.h" | 41 | #include "XMLHttpRequestClass.h" |
| @@ -45,7 +46,7 @@ · 4 unmodified lines | |||
| 45 | 46 | ||
| 46 | 47 | ||
| 47 | static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){ | 48 | static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){ |
| 48 | qDebug() << "script:print()<<" << context->argument(0).toString(); | 49 | qCDebug(scriptengine) << "script:print()<<" << context->argument(0).toString(); |
| 49 | QString message = context->argument(0).toString() | 50 | QString message = context->argument(0).toString() |
| 50 | .replace("\\", "\\\\") | 51 | .replace("\\", "\\\\") |
| 51 | .replace("\n", "\\n") | 52 | .replace("\n", "\\n") |
| @@ -271,12 +272,12 @@ void ScriptEngine::loadURL(const QUrl& scriptURL) { · 219 unmodified lines | |||
| 271 | _fileNameString = url.toLocalFile(); | 272 | _fileNameString = url.toLocalFile(); |
| 272 | QFile scriptFile(_fileNameString); | 273 | QFile scriptFile(_fileNameString); |
| 273 | if (scriptFile.open(QFile::ReadOnly | QFile::Text)) { | 274 | if (scriptFile.open(QFile::ReadOnly | QFile::Text)) { |
| 274 | qDebug() << "ScriptEngine loading file:" << _fileNameString; | 275 | qCDebug(scriptengine) << "ScriptEngine loading file:" << _fileNameString; |
| 275 | QTextStream in(&scriptFile); | 276 | QTextStream in(&scriptFile); |
| 276 | _scriptContents = in.readAll(); | 277 | _scriptContents = in.readAll(); |
| 277 | emit scriptLoaded(_fileNameString); | 278 | emit scriptLoaded(_fileNameString); |
| 278 | } else { | 279 | } else { |
| 279 | qDebug() << "ERROR Loading file:" << _fileNameString << "line:" << __LINE__; | 280 | qCDebug(scriptengine) << "ERROR Loading file:" << _fileNameString << "line:" << __LINE__; |
| 280 | emit errorLoadingScript(_fileNameString); | 281 | emit errorLoadingScript(_fileNameString); |
| 281 | } | 282 | } |
| 282 | } else { | 283 | } else { |
| @@ -294,7 +295,7 @@ void ScriptEngine::scriptContentsAvailable(const QUrl& url, const QString& scrip · 11 unmodified lines | |||
| 294 | } | 295 | } |
| 295 | 296 | ||
| 296 | void ScriptEngine::errorInLoadingScript(const QUrl& url) { | 297 | void ScriptEngine::errorInLoadingScript(const QUrl& url) { |
| 297 | qDebug() << "ERROR Loading file:" << url.toString() << "line:" << __LINE__; | 298 | qCDebug(scriptengine) << "ERROR Loading file:" << url.toString() << "line:" << __LINE__; |
| 298 | emit errorLoadingScript(_fileNameString); // ?? | 299 | emit errorLoadingScript(_fileNameString); // ?? |
| 299 | } | 300 | } |
| 300 | 301 | ||
| @@ -402,7 +403,7 @@ void ScriptEngine::evaluate() { · 101 unmodified lines | |||
| 402 | // will cause this code to never actually run... | 403 | // will cause this code to never actually run... |
| 403 | if (hasUncaughtException()) { | 404 | if (hasUncaughtException()) { |
| 404 | int line = uncaughtExceptionLineNumber(); | 405 | int line = uncaughtExceptionLineNumber(); |
| 405 | qDebug() << "Uncaught exception at (" << _fileNameString << ") line" << line << ":" << result.toString(); | 406 | qCDebug(scriptengine) << "Uncaught exception at (" << _fileNameString << ") line" << line << ":" << result.toString(); |
| 406 | emit errorMessage("Uncaught exception at (" + _fileNameString + ") line" + QString::number(line) + ":" + result.toString()); | 407 | emit errorMessage("Uncaught exception at (" + _fileNameString + ") line" + QString::number(line) + ":" + result.toString()); |
| 407 | clearExceptions(); | 408 | clearExceptions(); |
| 408 | } | 409 | } |
| @@ -417,7 +418,7 @@ QScriptValue ScriptEngine::evaluate(const QString& program, const QString& fileN · 8 unmodified lines | |||
| 417 | QScriptValue result = QScriptEngine::evaluate(program, fileName, lineNumber); | 418 | QScriptValue result = QScriptEngine::evaluate(program, fileName, lineNumber); |
| 418 | if (hasUncaughtException()) { | 419 | if (hasUncaughtException()) { |
| 419 | int line = uncaughtExceptionLineNumber(); | 420 | int line = uncaughtExceptionLineNumber(); |
| 420 | qDebug() << "Uncaught exception at (" << _fileNameString << " : " << fileName << ") line" << line << ": " << result.toString(); | 421 | qCDebug(scriptengine) << "Uncaught exception at (" << _fileNameString << " : " << fileName << ") line" << line << ": " << result.toString(); |
| 421 | } | 422 | } |
| 422 | _evaluatesPending--; | 423 | _evaluatesPending--; |
| 423 | emit evaluationFinished(result, hasUncaughtException()); | 424 | emit evaluationFinished(result, hasUncaughtException()); |
| @@ -591,7 +592,7 @@ void ScriptEngine::run() { · 167 unmodified lines | |||
| 591 | 592 | ||
| 592 | if (hasUncaughtException()) { | 593 | if (hasUncaughtException()) { |
| 593 | int line = uncaughtExceptionLineNumber(); | 594 | int line = uncaughtExceptionLineNumber(); |
| 594 | qDebug() << "Uncaught exception at (" << _fileNameString << ") line" << line << ":" << uncaughtException().toString(); | 595 | qCDebug(scriptengine) << "Uncaught exception at (" << _fileNameString << ") line" << line << ":" << uncaughtException().toString(); |
| 595 | emit errorMessage("Uncaught exception at (" + _fileNameString + ") line" + QString::number(line) + ":" + uncaughtException().toString()); | 596 | emit errorMessage("Uncaught exception at (" + _fileNameString + ") line" + QString::number(line) + ":" + uncaughtException().toString()); |
| 596 | clearExceptions(); | 597 | clearExceptions(); |
| 597 | } | 598 | } |
| @@ -684,7 +685,7 @@ QObject* ScriptEngine::setupTimerWithInterval(const QScriptValue& function, int · 86 unmodified lines | |||
| 684 | 685 | ||
| 685 | QObject* ScriptEngine::setInterval(const QScriptValue& function, int intervalMS) { | 686 | QObject* ScriptEngine::setInterval(const QScriptValue& function, int intervalMS) { |
| 686 | if (_stoppingAllScripts) { | 687 | if (_stoppingAllScripts) { |
| 687 | qDebug() << "Script.setInterval() while shutting down is ignored... parent script:" << getFilename(); | 688 | qCDebug(scriptengine) << "Script.setInterval() while shutting down is ignored... parent script:" << getFilename(); |
| 688 | return NULL; // bail early | 689 | return NULL; // bail early |
| 689 | } | 690 | } |
| 690 | 691 | ||
| @@ -693,7 +694,7 @@ QObject* ScriptEngine::setInterval(const QScriptValue& function, int intervalMS) · 2 unmodified lines | |||
| 693 | 694 | ||
| 694 | QObject* ScriptEngine::setTimeout(const QScriptValue& function, int timeoutMS) { | 695 | QObject* ScriptEngine::setTimeout(const QScriptValue& function, int timeoutMS) { |
| 695 | if (_stoppingAllScripts) { | 696 | if (_stoppingAllScripts) { |
| 696 | qDebug() << "Script.setTimeout() while shutting down is ignored... parent script:" << getFilename(); | 697 | qCDebug(scriptengine) << "Script.setTimeout() while shutting down is ignored... parent script:" << getFilename(); |
| 697 | return NULL; // bail early | 698 | return NULL; // bail early |
| 698 | } | 699 | } |
| 699 | 700 | ||
| @@ -743,7 +744,7 @@ void ScriptEngine::print(const QString& message) { · 43 unmodified lines | |||
| 743 | // all of the files have finished loading. | 744 | // all of the files have finished loading. |
| 744 | void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callback) { | 745 | void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callback) { |
| 745 | if (_stoppingAllScripts) { | 746 | if (_stoppingAllScripts) { |
| 746 | qDebug() << "Script.include() while shutting down is ignored..." | 747 | qCDebug(scriptengine) << "Script.include() while shutting down is ignored..." |
| 747 | << "includeFiles:" << includeFiles << "parent script:" << getFilename(); | 748 | << "includeFiles:" << includeFiles << "parent script:" << getFilename(); |
| 748 | return; // bail early | 749 | return; // bail early |
| 749 | } | 750 | } |
| @@ -758,7 +759,7 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac · 8 unmodified lines | |||
| 758 | for (QUrl url : urls) { | 759 | for (QUrl url : urls) { |
| 759 | QString contents = data[url]; | 760 | QString contents = data[url]; |
| 760 | if (contents.isNull()) { | 761 | if (contents.isNull()) { |
| 761 | qDebug() << "Error loading file: " << url << "line:" << __LINE__; | 762 | qCDebug(scriptengine) << "Error loading file: " << url << "line:" << __LINE__; |
| 762 | } else { | 763 | } else { |
| 763 | QScriptValue result = evaluate(contents, url.toString()); | 764 | QScriptValue result = evaluate(contents, url.toString()); |
| 764 | } | 765 | } |
| @@ -787,7 +788,7 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac · 22 unmodified lines | |||
| 787 | 788 | ||
| 788 | void ScriptEngine::include(const QString& includeFile, QScriptValue callback) { | 789 | void ScriptEngine::include(const QString& includeFile, QScriptValue callback) { |
| 789 | if (_stoppingAllScripts) { | 790 | if (_stoppingAllScripts) { |
| 790 | qDebug() << "Script.include() while shutting down is ignored... " | 791 | qCDebug(scriptengine) << "Script.include() while shutting down is ignored... " |
| 791 | << "includeFile:" << includeFile << "parent script:" << getFilename(); | 792 | << "includeFile:" << includeFile << "parent script:" << getFilename(); |
| 792 | return; // bail early | 793 | return; // bail early |
| 793 | } | 794 | } |
| @@ -802,7 +803,7 @@ void ScriptEngine::include(const QString& includeFile, QScriptValue callback) { · 8 unmodified lines | |||
| 802 | // the Application or other context will connect to in order to know to actually load the script | 803 | // the Application or other context will connect to in order to know to actually load the script |
| 803 | void ScriptEngine::load(const QString& loadFile) { | 804 | void ScriptEngine::load(const QString& loadFile) { |
| 804 | if (_stoppingAllScripts) { | 805 | if (_stoppingAllScripts) { |
| 805 | qDebug() << "Script.load() while shutting down is ignored... " | 806 | qCDebug(scriptengine) << "Script.load() while shutting down is ignored... " |
| 806 | << "loadFile:" << loadFile << "parent script:" << getFilename(); | 807 | << "loadFile:" << loadFile << "parent script:" << getFilename(); |
| 807 | return; // bail early | 808 | return; // bail early |
| 808 | } | 809 | } |