Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all
Unified · Split
| @@ -135,7 +135,7 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNam · 134 unmodified lines | |||
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | ScriptEngine::~ScriptEngine() { | 137 | ScriptEngine::~ScriptEngine() { |
| 138 | qDebug() << "Script Engine shutting down (destructor) for script:" << getFilename(); | 138 | qCDebug(scriptengine) << "Script Engine shutting down (destructor) for script:" << getFilename(); |
| 139 | 139 | ||
| 140 | // If we're not already in the middle of stopping all scripts, then we should remove ourselves | 140 | // If we're not already in the middle of stopping all scripts, then we should remove ourselves |
| 141 | // from the list of running scripts. We don't do this if we're in the process of stopping all scripts | 141 | // from the list of running scripts. We don't do this if we're in the process of stopping all scripts |
| @@ -158,6 +158,10 @@ void ScriptEngine::runInThread() { · 16 unmodified lines | |||
| 158 | QString scriptEngineName = QString("Script Thread:") + getFilename(); | 158 | QString scriptEngineName = QString("Script Thread:") + getFilename(); |
| 159 | workerThread->setObjectName(scriptEngineName); | 159 | workerThread->setObjectName(scriptEngineName); |
| 160 | 160 | ||
| 161 | // NOTE: If you connect any essential signals for proper shutdown or cleanup of | ||
| 162 | // the script engine, make sure to add code to "reconnect" them to the | ||
| 163 | // disconnectNonEssentialSignals() method | ||
| 164 | |||
| 161 | // when the worker thread is started, call our engine's run.. | 165 | // when the worker thread is started, call our engine's run.. |
| 162 | connect(workerThread, &QThread::started, this, &ScriptEngine::run); | 166 | connect(workerThread, &QThread::started, this, &ScriptEngine::run); |
| 163 | 167 | ||
| @@ -184,7 +188,7 @@ void ScriptEngine::stopAllScripts(QObject* application) { · 20 unmodified lines | |||
| 184 | _allScriptsMutex.lock(); | 188 | _allScriptsMutex.lock(); |
| 185 | _stoppingAllScripts = true; | 189 | _stoppingAllScripts = true; |
| 186 | 190 | ||
| 187 | qDebug() << "Stopping all scripts.... currently known scripts:" << _allKnownScriptEngines.size(); | 191 | qCDebug(scriptengine) << "Stopping all scripts.... currently known scripts:" << _allKnownScriptEngines.size(); |
| 188 | 192 | ||
| 189 | QMutableSetIterator<ScriptEngine*> i(_allKnownScriptEngines); | 193 | QMutableSetIterator<ScriptEngine*> i(_allKnownScriptEngines); |
| 190 | while (i.hasNext()) { | 194 | while (i.hasNext()) { |
| @@ -223,9 +227,9 @@ void ScriptEngine::stopAllScripts(QObject* application) { · 32 unmodified lines | |||
| 223 | // We need to wait for the engine to be done running before we proceed, because we don't | 227 | // We need to wait for the engine to be done running before we proceed, because we don't |
| 224 | // want any of the scripts final "scriptEnding()" or pending "update()" methods from accessing | 228 | // want any of the scripts final "scriptEnding()" or pending "update()" methods from accessing |
| 225 | // any application state after we leave this stopAllScripts() method | 229 | // any application state after we leave this stopAllScripts() method |
| 226 | qDebug() << "waiting on script:" << scriptName; | 230 | qCDebug(scriptengine) << "waiting on script:" << scriptName; |
| 227 | scriptEngine->waitTillDoneRunning(); | 231 | scriptEngine->waitTillDoneRunning(); |
| 228 | qDebug() << "done waiting on script:" << scriptName; | 232 | qCDebug(scriptengine) << "done waiting on script:" << scriptName; |
| 229 | 233 | ||
| 230 | // If the script is stopped, we can remove it from our set | 234 | // If the script is stopped, we can remove it from our set |
| 231 | i.remove(); | 235 | i.remove(); |
| @@ -233,7 +237,7 @@ void ScriptEngine::stopAllScripts(QObject* application) { · 1 unmodified line | |||
| 233 | } | 237 | } |
| 234 | _stoppingAllScripts = false; | 238 | _stoppingAllScripts = false; |
| 235 | _allScriptsMutex.unlock(); | 239 | _allScriptsMutex.unlock(); |
| 236 | qDebug() << "DONE Stopping all scripts...."; | 240 | qCDebug(scriptengine) << "DONE Stopping all scripts...."; |
| 237 | } | 241 | } |
| 238 | 242 | ||
| 239 | 243 | ||
| @@ -1170,7 +1174,7 @@ void ScriptEngine::refreshFileScript(const EntityItemID& entityID) { · 930 unmodified lines | |||
| 1170 | QString filePath = QUrl(details.scriptText).toLocalFile(); | 1174 | QString filePath = QUrl(details.scriptText).toLocalFile(); |
| 1171 | auto lastModified = QFileInfo(filePath).lastModified().toMSecsSinceEpoch(); | 1175 | auto lastModified = QFileInfo(filePath).lastModified().toMSecsSinceEpoch(); |
| 1172 | if (lastModified > details.lastModified) { | 1176 | if (lastModified > details.lastModified) { |
| 1173 | qDebug() << "Reloading modified script " << details.scriptText; | 1177 | qCDebug(scriptengine) << "Reloading modified script " << details.scriptText; |
| 1174 | 1178 | ||
| 1175 | QFile file(filePath); | 1179 | QFile file(filePath); |
| 1176 | file.open(QIODevice::ReadOnly); | 1180 | file.open(QIODevice::ReadOnly); |