History

more CR feedback removed redundant abort code

ZappoMan committed 10 years ago

Commit 00838d11 parent ee4748f1 file · +0 −25Browse files

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

Unified · Split

libraries/script-engine/src/ScriptEngines.cpp+0−25
@@ -131,31 +131,6 @@ void ScriptEngines::shutdownScripting() { · 130 unmodified lines
131 if (scriptEngine->isRunning()) {131 if (scriptEngine->isRunning()) {
132 qCDebug(scriptengine) << "about to shutdown script:" << scriptName;132 qCDebug(scriptengine) << "about to shutdown script:" << scriptName;
133 133
134 // If the script is running, but still evaluating then we need to wait for its evaluation step to
135 // complete. After that we can handle the stop process appropriately
136 if (scriptEngine->evaluatePending()) {
137 qCDebug(scriptengine) << "script still evaluating:" << scriptName;
138 auto startedWaiting = usecTimestampNow();
139 while (scriptEngine->evaluatePending()) {
140
141 // This event loop allows any started, but not yet finished evaluate() calls to complete
142 // we need to let these complete so that we can be guaranteed that the script engine isn't
143 // in a partially setup state, which can confuse our shutdown unwinding.
144 QEventLoop loop;
145 static const int MAX_PROCESSING_TIME = 500; // in MS
146 loop.processEvents(QEventLoop::AllEvents, MAX_PROCESSING_TIME);
147 auto stillWaiting = usecTimestampNow();
148 auto elapsed = stillWaiting - startedWaiting;
149 // if we've been waiting for more than 5 seconds, then tell the script engine to stop evaluating
150 static const auto WAITING_TOO_LONG = USECS_PER_SECOND * 5;
151 if (elapsed > WAITING_TOO_LONG) {
152 qCDebug(scriptengine) << "giving up on script evaluation elapsed:" << elapsed << "calling abortEvaluation() script:" << scriptName;
153 scriptEngine->abortEvaluation();
154 }
155 }
156 qCDebug(scriptengine) << "script DONE evaluating:" << scriptName;
157 }
158
159 // We disconnect any script engine signals from the application because we don't want to do any134 // We disconnect any script engine signals from the application because we don't want to do any
160 // extra stopScript/loadScript processing that the Application normally does when scripts start135 // extra stopScript/loadScript processing that the Application normally does when scripts start
161 // and stop. We can safely short circuit this because we know we're in the "quitting" process136 // and stop. We can safely short circuit this because we know we're in the "quitting" process