Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 19 files). Show all
Unified · Split
| @@ -87,7 +87,7 @@ · 86 unmodified lines | |||
| 87 | #include "SettingHandle.h" | 87 | #include "SettingHandle.h" |
| 88 | #include <AddressManager.h> | 88 | #include <AddressManager.h> |
| 89 | #include <NetworkingConstants.h> | 89 | #include <NetworkingConstants.h> |
| 90 | 90 | #include <ThreadHelpers.h> | |
| 91 | 91 | ||
| 92 | const QString ScriptEngine::_SETTINGS_ENABLE_EXTENDED_EXCEPTIONS { | 92 | const QString ScriptEngine::_SETTINGS_ENABLE_EXTENDED_EXCEPTIONS { |
| 93 | "com.highfidelity.experimental.enableExtendedJSExceptions" | 93 | "com.highfidelity.experimental.enableExtendedJSExceptions" |
| @@ -429,13 +429,17 @@ void ScriptEngine::runInThread() { · 335 unmodified lines | |||
| 429 | // The thread interface cannot live on itself, and we want to move this into the thread, so | 429 | // The thread interface cannot live on itself, and we want to move this into the thread, so |
| 430 | // the thread cannot have this as a parent. | 430 | // the thread cannot have this as a parent. |
| 431 | QThread* workerThread = new QThread(); | 431 | QThread* workerThread = new QThread(); |
| 432 | workerThread->setObjectName(QString("js:") + getFilename().replace("about:","")); | 432 | QString name = QString("js:") + getFilename().replace("about:",""); |
| 433 | workerThread->setObjectName(name); | ||
| 433 | moveToThread(workerThread); | 434 | moveToThread(workerThread); |
| 434 | 435 | ||
| 435 | // NOTE: If you connect any essential signals for proper shutdown or cleanup of | 436 | // NOTE: If you connect any essential signals for proper shutdown or cleanup of |
| 436 | // the script engine, make sure to add code to "reconnect" them to the | 437 | // the script engine, make sure to add code to "reconnect" them to the |
| 437 | // disconnectNonEssentialSignals() method | 438 | // disconnectNonEssentialSignals() method |
| 438 | connect(workerThread, &QThread::started, this, &ScriptEngine::run); | 439 | connect(workerThread, &QThread::started, this, [this, name] { |
| 440 | setThreadName(name.toStdString()); | ||
| 441 | run(); | ||
| 442 | }); | ||
| 439 | connect(this, &QObject::destroyed, workerThread, &QThread::quit); | 443 | connect(this, &QObject::destroyed, workerThread, &QThread::quit); |
| 440 | connect(workerThread, &QThread::finished, workerThread, &QObject::deleteLater); | 444 | connect(workerThread, &QThread::finished, workerThread, &QObject::deleteLater); |
| 441 | 445 | ||