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: 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 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 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: Simplify register pair access on big endian
|
||||||
- SM83: Disassemble STOP as one byte
|
- SM83: Disassemble STOP as one byte
|
||||||
Misc:
|
Misc:
|
||||||
|
|
|
@ -406,23 +406,25 @@ void CoreController::reset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoreController::setPaused(bool paused) {
|
void CoreController::setPaused(bool paused) {
|
||||||
if (paused == isPaused()) {
|
QMutexLocker locker(&m_actionMutex);
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (paused) {
|
if (paused) {
|
||||||
addFrameAction([this]() {
|
if (m_moreFrames < 0) {
|
||||||
mCoreThreadPauseFromThread(&m_threadContext);
|
m_moreFrames = 1;
|
||||||
});
|
}
|
||||||
} else {
|
} else {
|
||||||
mCoreThreadUnpause(&m_threadContext);
|
m_moreFrames = -1;
|
||||||
|
if (isPaused()) {
|
||||||
|
mCoreThreadUnpause(&m_threadContext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoreController::frameAdvance() {
|
void CoreController::frameAdvance() {
|
||||||
addFrameAction([this]() {
|
QMutexLocker locker(&m_actionMutex);
|
||||||
mCoreThreadPauseFromThread(&m_threadContext);
|
m_moreFrames = 1;
|
||||||
});
|
if (isPaused()) {
|
||||||
setPaused(false);
|
mCoreThreadUnpause(&m_threadContext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoreController::addFrameAction(std::function<void ()> action) {
|
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);
|
memcpy(m_completeBuffer.data(), m_activeBuffer.constData(), width * height * BYTES_PER_PIXEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
QMutexLocker locker(&m_actionMutex);
|
{
|
||||||
QList<std::function<void ()>> frameActions(m_frameActions);
|
QMutexLocker locker(&m_actionMutex);
|
||||||
m_frameActions.clear();
|
QList<std::function<void ()>> frameActions(m_frameActions);
|
||||||
for (auto& action : frameActions) {
|
m_frameActions.clear();
|
||||||
action();
|
for (auto& action : frameActions) {
|
||||||
|
action();
|
||||||
|
}
|
||||||
|
if (m_moreFrames > 0) {
|
||||||
|
--m_moreFrames;
|
||||||
|
if (!m_moreFrames) {
|
||||||
|
mCoreThreadPauseFromThread(&m_threadContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
updateKeys();
|
updateKeys();
|
||||||
|
|
||||||
|
|
|
@ -213,6 +213,7 @@ private:
|
||||||
QList<std::function<void()>> m_resetActions;
|
QList<std::function<void()>> m_resetActions;
|
||||||
QList<std::function<void()>> m_frameActions;
|
QList<std::function<void()>> m_frameActions;
|
||||||
QMutex m_actionMutex{QMutex::Recursive};
|
QMutex m_actionMutex{QMutex::Recursive};
|
||||||
|
int m_moreFrames = -1;
|
||||||
QMutex m_bufferMutex;
|
QMutex m_bufferMutex;
|
||||||
|
|
||||||
int m_activeKeys = 0;
|
int m_activeKeys = 0;
|
||||||
|
|
Loading…
Reference in New Issue