From 89937d62b0055fbb22ce60e15e5e79fad7c05b90 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sat, 14 Nov 2020 15:49:39 -0800 Subject: [PATCH] Qt: Remove thread parameter for Interrupter that can be autodetected --- src/platform/qt/CoreController.cpp | 8 ++++---- src/platform/qt/CoreController.h | 4 ++-- src/platform/qt/DebuggerConsoleController.cpp | 6 +++--- src/platform/qt/FrameView.cpp | 2 +- src/platform/qt/Window.cpp | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/platform/qt/CoreController.cpp b/src/platform/qt/CoreController.cpp index 613f486a5..137f3db53 100644 --- a/src/platform/qt/CoreController.cpp +++ b/src/platform/qt/CoreController.cpp @@ -1008,26 +1008,26 @@ void CoreController::updateFastForward() { m_threadContext.core->reloadConfigOption(m_threadContext.core, NULL, NULL); } -CoreController::Interrupter::Interrupter(CoreController* parent, bool fromThread) +CoreController::Interrupter::Interrupter(CoreController* parent) : m_parent(parent) { if (!m_parent->thread()->impl) { return; } - if (!fromThread) { + if (mCoreThreadGet() != m_parent->thread()) { mCoreThreadInterrupt(m_parent->thread()); } else { mCoreThreadInterruptFromThread(m_parent->thread()); } } -CoreController::Interrupter::Interrupter(std::shared_ptr parent, bool fromThread) +CoreController::Interrupter::Interrupter(std::shared_ptr parent) : m_parent(parent.get()) { if (!m_parent->thread()->impl) { return; } - if (!fromThread) { + if (mCoreThreadGet() != m_parent->thread()) { mCoreThreadInterrupt(m_parent->thread()); } else { mCoreThreadInterruptFromThread(m_parent->thread()); diff --git a/src/platform/qt/CoreController.h b/src/platform/qt/CoreController.h index 166c60e7b..50af58871 100644 --- a/src/platform/qt/CoreController.h +++ b/src/platform/qt/CoreController.h @@ -53,8 +53,8 @@ public: class Interrupter { public: - Interrupter(CoreController*, bool fromThread = false); - Interrupter(std::shared_ptr, bool fromThread = false); + Interrupter(CoreController*); + Interrupter(std::shared_ptr); Interrupter(const Interrupter&); ~Interrupter(); diff --git a/src/platform/qt/DebuggerConsoleController.cpp b/src/platform/qt/DebuggerConsoleController.cpp index 08b113f72..95c8638a6 100644 --- a/src/platform/qt/DebuggerConsoleController.cpp +++ b/src/platform/qt/DebuggerConsoleController.cpp @@ -79,7 +79,7 @@ void DebuggerConsoleController::deinit(struct CLIDebuggerBackend* be) { const char* DebuggerConsoleController::readLine(struct CLIDebuggerBackend* be, size_t* len) { Backend* consoleBe = reinterpret_cast(be); DebuggerConsoleController* self = consoleBe->self; - CoreController::Interrupter interrupter(self->m_gameController, true); + CoreController::Interrupter interrupter(self->m_gameController); QMutexLocker lock(&self->m_mutex); while (self->m_lines.isEmpty()) { self->m_cond.wait(&self->m_mutex); @@ -103,7 +103,7 @@ void DebuggerConsoleController::lineAppend(struct CLIDebuggerBackend* be, const const char* DebuggerConsoleController::historyLast(struct CLIDebuggerBackend* be, size_t* len) { Backend* consoleBe = reinterpret_cast(be); DebuggerConsoleController* self = consoleBe->self; - CoreController::Interrupter interrupter(self->m_gameController, true); + CoreController::Interrupter interrupter(self->m_gameController); QMutexLocker lock(&self->m_mutex); if (self->m_history.isEmpty()) { return "i"; @@ -115,7 +115,7 @@ const char* DebuggerConsoleController::historyLast(struct CLIDebuggerBackend* be void DebuggerConsoleController::historyAppend(struct CLIDebuggerBackend* be, const char* line) { Backend* consoleBe = reinterpret_cast(be); DebuggerConsoleController* self = consoleBe->self; - CoreController::Interrupter interrupter(self->m_gameController, true); + CoreController::Interrupter interrupter(self->m_gameController); QMutexLocker lock(&self->m_mutex); self->m_history.append(QString::fromUtf8(line)); } diff --git a/src/platform/qt/FrameView.cpp b/src/platform/qt/FrameView.cpp index 649c16e92..ae805483b 100644 --- a/src/platform/qt/FrameView.cpp +++ b/src/platform/qt/FrameView.cpp @@ -521,7 +521,7 @@ void FrameView::frameCallback(FrameView* viewer, std::shared_ptr lock) { if (!*lock) { return; } - CoreController::Interrupter interrupter(viewer->m_controller, true); + CoreController::Interrupter interrupter(viewer->m_controller); viewer->refreshVl(); viewer->m_controller->addFrameAction(std::bind(&FrameView::frameCallback, viewer, lock)); } diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index ca19b8eca..b52c8ac79 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -766,7 +766,7 @@ void Window::gameStarted() { m_screenWidget->setCursor(Qt::BlankCursor); } - CoreController::Interrupter interrupter(m_controller, true); + CoreController::Interrupter interrupter(m_controller); mCore* core = m_controller->thread()->core; m_actions.clearMenu("videoLayers"); m_actions.clearMenu("audioChannels");