Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop remaining references to "QScriptEngineDebugger". #1206

Merged
merged 1 commit into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 0 additions & 98 deletions libraries/script-engine/src/ScriptEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
#include <QtScript/QScriptValue>
#include <QtScript/QScriptValueIterator>

#include <QtScriptTools/QScriptEngineDebugger>

#include <shared/LocalFileAccessGate.h>
#include <shared/QtHelpers.h>
#include <shared/AbstractLoggerInterface.h>
Expand Down Expand Up @@ -327,96 +325,6 @@ void ScriptEngine::disconnectNonEssentialSignals() {
}
}

void ScriptEngine::runDebuggable() {
static QMenuBar* menuBar { nullptr };
static QMenu* scriptDebugMenu { nullptr };
static size_t scriptMenuCount { 0 };
if (!scriptDebugMenu) {
for (auto window : qApp->topLevelWidgets()) {
auto mainWindow = qobject_cast<QMainWindow*>(window);
if (mainWindow) {
menuBar = mainWindow->menuBar();
break;
}
}
if (menuBar) {
scriptDebugMenu = menuBar->addMenu("Script Debug");
}
}

init();
_isRunning = true;
_debuggable = true;
_debugger = new QScriptEngineDebugger(this);
_debugger->attachTo(this);

QMenu* parentMenu = scriptDebugMenu;
QMenu* scriptMenu { nullptr };
if (parentMenu) {
++scriptMenuCount;
scriptMenu = parentMenu->addMenu(_fileNameString);
scriptMenu->addMenu(_debugger->createStandardMenu(qApp->activeWindow()));
} else {
qWarning() << "Unable to add script debug menu";
}

QScriptValue result = evaluate(_scriptContents, _fileNameString);

_lastUpdate = usecTimestampNow();
QTimer* timer = new QTimer(this);
connect(this, &ScriptEngine::finished, [this, timer, parentMenu, scriptMenu] {
if (scriptMenu) {
parentMenu->removeAction(scriptMenu->menuAction());
--scriptMenuCount;
if (0 == scriptMenuCount) {
menuBar->removeAction(scriptDebugMenu->menuAction());
scriptDebugMenu = nullptr;
}
}
disconnect(timer);
});

connect(timer, &QTimer::timeout, [this, timer] {
if (_isFinished) {
if (!_isRunning) {
return;
}
stopAllTimers(); // make sure all our timers are stopped if the script is ending

emit scriptEnding();
emit finished(_fileNameString, qSharedPointerCast<ScriptEngine>(sharedFromThis()));
_isRunning = false;

emit runningStateChanged();
emit doneRunning();

timer->deleteLater();
return;
}

qint64 now = usecTimestampNow();
// we check for 'now' in the past in case people set their clock back
if (_lastUpdate < now) {
float deltaTime = (float)(now - _lastUpdate) / (float)USECS_PER_SECOND;
if (!(_isFinished || _isStopping)) {
emit update(deltaTime);
}
}
_lastUpdate = now;

// only clear exceptions if we are not in the middle of evaluating
if (!isEvaluating() && hasUncaughtException()) {
qCWarning(scriptengine) << __FUNCTION__ << "---------- UNCAUGHT EXCEPTION --------";
qCWarning(scriptengine) << "runDebuggable" << uncaughtException().toString();
logException(__FUNCTION__);
clearExceptions();
}
});

timer->start(10);
}


void ScriptEngine::runInThread() {
Q_ASSERT_X(!_isThreaded, "ScriptEngine::runInThread()", "runInThread should not be called more than once");

Expand Down Expand Up @@ -588,12 +496,6 @@ void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) {

_scriptContents = scriptContents;

{
static const QString DEBUG_FLAG("#debug");
if (QRegularExpression(DEBUG_FLAG).match(scriptContents).hasMatch()) {
_debuggable = true;
}
}
emit scriptLoaded(url);
}, reload, maxRetries);
}
Expand Down
8 changes: 0 additions & 8 deletions libraries/script-engine/src/ScriptEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
#include "SettingHandle.h"
#include "Profile.h"

class QScriptEngineDebugger;

static const QString NO_SCRIPT("");

static const int SCRIPT_FPS = 60;
Expand Down Expand Up @@ -167,8 +165,6 @@ class ScriptEngine : public BaseScriptEngine, public EntitiesScriptEngineProvide
/// services before calling this.
void runInThread();

void runDebuggable();

/// run the script in the callers thread, exit when stop() is called.
void run();

Expand Down Expand Up @@ -667,8 +663,6 @@ class ScriptEngine : public BaseScriptEngine, public EntitiesScriptEngineProvide
// this is used by code in ScriptEngines.cpp during the "reload all" operation
bool isStopping() const { return _isStopping; }

bool isDebuggable() const { return _debuggable; }

void disconnectNonEssentialSignals();

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -982,8 +976,6 @@ public slots:
EntityScriptContentAvailableMap _contentAvailableQueue;

bool _isThreaded { false };
QScriptEngineDebugger* _debugger { nullptr };
bool _debuggable { false };
qint64 _lastUpdate;

QString _fileNameString;
Expand Down
13 changes: 1 addition & 12 deletions libraries/script-engine/src/ScriptEngines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#define __LOC__ __FILE__ "(" __STR1__(__LINE__) ") : Warning Msg: "

static const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
static const bool HIFI_SCRIPT_DEBUGGABLES { true };
static const QString SETTINGS_KEY { "RunningScripts" };
static const QUrl DEFAULT_SCRIPTS_LOCATION { "file:///~//defaultScripts.js" };

Expand Down Expand Up @@ -589,17 +588,7 @@ void ScriptEngines::launchScriptEngine(ScriptEnginePointer scriptEngine) {

// register our application services and set it off on its own thread
runScriptInitializers(scriptEngine);

// FIXME disabling 'shift key' debugging for now. If you start up the application with
// the shift key held down, it triggers a deadlock because of script interfaces running
// on the main thread
auto const wantDebug = scriptEngine->isDebuggable(); // || (qApp->queryKeyboardModifiers() & Qt::ShiftModifier);

if (HIFI_SCRIPT_DEBUGGABLES && wantDebug) {
scriptEngine->runDebuggable();
} else {
scriptEngine->runInThread();
}
scriptEngine->runInThread();
}

void ScriptEngines::onScriptFinished(const QString& rawScriptURL, ScriptEnginePointer engine) {
Expand Down