History

drop remaining references to QScriptEngineDebugger

Heather Anderson committed 5 years ago

Commit 04f8ccd1 parent 9b41ae43 files · +1 −118Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 3 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+0−98
@@ -36,8 +36,6 @@ · 35 unmodified lines
3636 #include <QtScript/QScriptValue>
3737 #include <QtScript/QScriptValueIterator>
3838
39−#include <QtScriptTools/QScriptEngineDebugger>
40−
4139 #include <shared/LocalFileAccessGate.h>
4240 #include <shared/QtHelpers.h>
4341 #include <shared/AbstractLoggerInterface.h>
@@ -327,96 +325,6 @@ void ScriptEngine::disconnectNonEssentialSignals() { · 283 unmodified lines
327325 }
328326 }
329327
330−void ScriptEngine::runDebuggable() {
331− static QMenuBar* menuBar { nullptr };
332− static QMenu* scriptDebugMenu { nullptr };
333− static size_t scriptMenuCount { 0 };
334− if (!scriptDebugMenu) {
335− for (auto window : qApp->topLevelWidgets()) {
336− auto mainWindow = qobject_cast<QMainWindow*>(window);
337− if (mainWindow) {
338− menuBar = mainWindow->menuBar();
339− break;
340− }
341− }
342− if (menuBar) {
343− scriptDebugMenu = menuBar->addMenu("Script Debug");
344− }
345− }
346−
347− init();
348− _isRunning = true;
349− _debuggable = true;
350− _debugger = new QScriptEngineDebugger(this);
351− _debugger->attachTo(this);
352−
353− QMenu* parentMenu = scriptDebugMenu;
354− QMenu* scriptMenu { nullptr };
355− if (parentMenu) {
356− ++scriptMenuCount;
357− scriptMenu = parentMenu->addMenu(_fileNameString);
358− scriptMenu->addMenu(_debugger->createStandardMenu(qApp->activeWindow()));
359− } else {
360− qWarning() << "Unable to add script debug menu";
361− }
362−
363− QScriptValue result = evaluate(_scriptContents, _fileNameString);
364−
365− _lastUpdate = usecTimestampNow();
366− QTimer* timer = new QTimer(this);
367− connect(this, &ScriptEngine::finished, [this, timer, parentMenu, scriptMenu] {
368− if (scriptMenu) {
369− parentMenu->removeAction(scriptMenu->menuAction());
370− --scriptMenuCount;
371− if (0 == scriptMenuCount) {
372− menuBar->removeAction(scriptDebugMenu->menuAction());
373− scriptDebugMenu = nullptr;
374− }
375− }
376− disconnect(timer);
377− });
378−
379− connect(timer, &QTimer::timeout, [this, timer] {
380− if (_isFinished) {
381− if (!_isRunning) {
382− return;
383− }
384− stopAllTimers(); // make sure all our timers are stopped if the script is ending
385−
386− emit scriptEnding();
387− emit finished(_fileNameString, qSharedPointerCast<ScriptEngine>(sharedFromThis()));
388− _isRunning = false;
389−
390− emit runningStateChanged();
391− emit doneRunning();
392−
393− timer->deleteLater();
394− return;
395− }
396−
397− qint64 now = usecTimestampNow();
398− // we check for 'now' in the past in case people set their clock back
399− if (_lastUpdate < now) {
400− float deltaTime = (float)(now - _lastUpdate) / (float)USECS_PER_SECOND;
401− if (!(_isFinished || _isStopping)) {
402− emit update(deltaTime);
403− }
404− }
405− _lastUpdate = now;
406−
407− // only clear exceptions if we are not in the middle of evaluating
408− if (!isEvaluating() && hasUncaughtException()) {
409− qCWarning(scriptengine) << __FUNCTION__ << "---------- UNCAUGHT EXCEPTION --------";
410− qCWarning(scriptengine) << "runDebuggable" << uncaughtException().toString();
411− logException(__FUNCTION__);
412− clearExceptions();
413− }
414− });
415−
416− timer->start(10);
417−}
418−
419−
420328 void ScriptEngine::runInThread() {
421329 Q_ASSERT_X(!_isThreaded, "ScriptEngine::runInThread()", "runInThread should not be called more than once");
422330
@@ -588,12 +496,6 @@ void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) { · 165 unmodified lines
588496
589497 _scriptContents = scriptContents;
590498
591− {
592− static const QString DEBUG_FLAG("#debug");
593− if (QRegularExpression(DEBUG_FLAG).match(scriptContents).hasMatch()) {
594− _debuggable = true;
595− }
596− }
597499 emit scriptLoaded(url);
598500 }, reload, maxRetries);
599501 }