From 47728c7a8d7f349cae8a22022b803b36515cc23e Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Thu, 11 Mar 2021 23:19:22 -0800 Subject: [PATCH] Qt: Fix up debugger console slightly --- src/platform/qt/DebuggerConsoleController.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/platform/qt/DebuggerConsoleController.cpp b/src/platform/qt/DebuggerConsoleController.cpp index 95c8638a6..b77609a5a 100644 --- a/src/platform/qt/DebuggerConsoleController.cpp +++ b/src/platform/qt/DebuggerConsoleController.cpp @@ -8,6 +8,7 @@ #include "CoreController.h" #include +#include #include @@ -30,6 +31,7 @@ DebuggerConsoleController::DebuggerConsoleController(QObject* parent) } void DebuggerConsoleController::enterLine(const QString& line) { + CoreController::Interrupter interrupter(m_gameController); QMutexLocker lock(&m_mutex); m_lines.append(line); if (m_cliDebugger.d.state == DEBUGGER_RUNNING) { @@ -39,14 +41,20 @@ void DebuggerConsoleController::enterLine(const QString& line) { } void DebuggerConsoleController::detach() { - if (m_cliDebugger.d.state != DEBUGGER_SHUTDOWN) { - m_lines.append(QString()); - m_cond.wakeOne(); + { + CoreController::Interrupter interrupter(m_gameController); + QMutexLocker lock(&m_mutex); + if (m_cliDebugger.d.state != DEBUGGER_SHUTDOWN) { + m_lines.append(QString()); + m_cond.wakeOne(); + } } DebuggerController::detach(); } void DebuggerConsoleController::attachInternal() { + CoreController::Interrupter interrupter(m_gameController); + QMutexLocker lock(&m_mutex); m_history.clear(); mCore* core = m_gameController->thread()->core; CLIDebuggerAttachBackend(&m_cliDebugger, &m_backend.d); @@ -65,12 +73,13 @@ void DebuggerConsoleController::printf(struct CLIDebuggerBackend* be, const char void DebuggerConsoleController::init(struct CLIDebuggerBackend* be) { Backend* consoleBe = reinterpret_cast(be); DebuggerConsoleController* self = consoleBe->self; + UNUSED(self); } void DebuggerConsoleController::deinit(struct CLIDebuggerBackend* be) { Backend* consoleBe = reinterpret_cast(be); DebuggerConsoleController* self = consoleBe->self; - if (be->p->d.state != DEBUGGER_SHUTDOWN) { + if (QThread::currentThread() == self->thread() && be->p->d.state != DEBUGGER_SHUTDOWN) { self->m_lines.append(QString()); self->m_cond.wakeOne(); } @@ -109,6 +118,7 @@ const char* DebuggerConsoleController::historyLast(struct CLIDebuggerBackend* be return "i"; } self->m_last = self->m_history.last().toUtf8(); + *len = self->m_last.size(); return self->m_last.constData(); }