mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix cancelling pausing before the frame ends
This commit is contained in:
parent
61f8f14694
commit
67dae057ed
1
CHANGES
1
CHANGES
|
@ -59,6 +59,7 @@ Other fixes:
|
|||
- Qt: Load/save bytes from memory viewer in the order visible (fixes mgba.io/i/1900)
|
||||
- Qt: Fix running proxied video if it gets pushed to the main thread
|
||||
- Qt: Fix game display sometimes disappearing after closing load/save state screen
|
||||
- Qt: Fix cancelling pausing before the frame ends
|
||||
- SM83: Simplify register pair access on big endian
|
||||
- SM83: Disassemble STOP as one byte
|
||||
Misc:
|
||||
|
|
|
@ -406,23 +406,25 @@ void CoreController::reset() {
|
|||
}
|
||||
|
||||
void CoreController::setPaused(bool paused) {
|
||||
if (paused == isPaused()) {
|
||||
return;
|
||||
}
|
||||
QMutexLocker locker(&m_actionMutex);
|
||||
if (paused) {
|
||||
addFrameAction([this]() {
|
||||
mCoreThreadPauseFromThread(&m_threadContext);
|
||||
});
|
||||
if (m_moreFrames < 0) {
|
||||
m_moreFrames = 1;
|
||||
}
|
||||
} else {
|
||||
mCoreThreadUnpause(&m_threadContext);
|
||||
m_moreFrames = -1;
|
||||
if (isPaused()) {
|
||||
mCoreThreadUnpause(&m_threadContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CoreController::frameAdvance() {
|
||||
addFrameAction([this]() {
|
||||
mCoreThreadPauseFromThread(&m_threadContext);
|
||||
});
|
||||
setPaused(false);
|
||||
QMutexLocker locker(&m_actionMutex);
|
||||
m_moreFrames = 1;
|
||||
if (isPaused()) {
|
||||
mCoreThreadUnpause(&m_threadContext);
|
||||
}
|
||||
}
|
||||
|
||||
void CoreController::addFrameAction(std::function<void ()> action) {
|
||||
|
@ -947,11 +949,19 @@ void CoreController::finishFrame() {
|
|||
memcpy(m_completeBuffer.data(), m_activeBuffer.constData(), width * height * BYTES_PER_PIXEL);
|
||||
}
|
||||
|
||||
QMutexLocker locker(&m_actionMutex);
|
||||
QList<std::function<void ()>> frameActions(m_frameActions);
|
||||
m_frameActions.clear();
|
||||
for (auto& action : frameActions) {
|
||||
action();
|
||||
{
|
||||
QMutexLocker locker(&m_actionMutex);
|
||||
QList<std::function<void ()>> frameActions(m_frameActions);
|
||||
m_frameActions.clear();
|
||||
for (auto& action : frameActions) {
|
||||
action();
|
||||
}
|
||||
if (m_moreFrames > 0) {
|
||||
--m_moreFrames;
|
||||
if (!m_moreFrames) {
|
||||
mCoreThreadPauseFromThread(&m_threadContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
updateKeys();
|
||||
|
||||
|
|
|
@ -213,6 +213,7 @@ private:
|
|||
QList<std::function<void()>> m_resetActions;
|
||||
QList<std::function<void()>> m_frameActions;
|
||||
QMutex m_actionMutex{QMutex::Recursive};
|
||||
int m_moreFrames = -1;
|
||||
QMutex m_bufferMutex;
|
||||
|
||||
int m_activeKeys = 0;
|
||||
|
|
Loading…
Reference in New Issue