all repos — mgba @ 89937d62b0055fbb22ce60e15e5e79fad7c05b90

mGBA Game Boy Advance Emulator

Qt: Remove thread parameter for Interrupter that can be autodetected
Vicki Pfau vi@endrift.com
Sat, 14 Nov 2020 15:49:39 -0800
commit

89937d62b0055fbb22ce60e15e5e79fad7c05b90

parent

9a0561e9c2fe3ccade7a97477f49cfcff70ac34a

M src/platform/qt/CoreController.cppsrc/platform/qt/CoreController.cpp

@@ -1008,26 +1008,26 @@

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<CoreController> parent, bool fromThread) +CoreController::Interrupter::Interrupter(std::shared_ptr<CoreController> 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());
M src/platform/qt/CoreController.hsrc/platform/qt/CoreController.h

@@ -53,8 +53,8 @@ };

class Interrupter { public: - Interrupter(CoreController*, bool fromThread = false); - Interrupter(std::shared_ptr<CoreController>, bool fromThread = false); + Interrupter(CoreController*); + Interrupter(std::shared_ptr<CoreController>); Interrupter(const Interrupter&); ~Interrupter();
M src/platform/qt/DebuggerConsoleController.cppsrc/platform/qt/DebuggerConsoleController.cpp

@@ -79,7 +79,7 @@

const char* DebuggerConsoleController::readLine(struct CLIDebuggerBackend* be, size_t* len) { Backend* consoleBe = reinterpret_cast<Backend*>(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 @@

const char* DebuggerConsoleController::historyLast(struct CLIDebuggerBackend* be, size_t* len) { Backend* consoleBe = reinterpret_cast<Backend*>(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 @@

void DebuggerConsoleController::historyAppend(struct CLIDebuggerBackend* be, const char* line) { Backend* consoleBe = reinterpret_cast<Backend*>(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)); }
M src/platform/qt/FrameView.cppsrc/platform/qt/FrameView.cpp

@@ -521,7 +521,7 @@ void FrameView::frameCallback(FrameView* viewer, std::shared_ptr<bool> 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)); }
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -766,7 +766,7 @@ if (m_display->underMouse()) {

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");