Skip to content

Commit

Permalink
lock framebuffer stuff to prevent conflicts when reiniting the core o…
Browse files Browse the repository at this point in the history
…r changing the renderer
  • Loading branch information
Arisotura committed Oct 31, 2024
1 parent 9c8f229 commit e3e561d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/frontend/qt_sdl/EmuInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,7 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB
args = &(*dsiargs);
}

renderLock.lock();
if ((!nds) || (consoleType != nds->ConsoleType))
{
NDS::Current = nullptr;
Expand Down Expand Up @@ -1387,6 +1388,7 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB
dsi->EjectGBACart();
}
}
renderLock.unlock();

return true;
}
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/qt_sdl/EmuInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ class EmuInstance
void touchScreen(int x, int y);
void releaseScreen();

QMutex renderLock;

private:
static int lastSep(const std::string& path);
std::string getAssetPath(bool gba, const std::string& configpath, const std::string& ext, const std::string& file);
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/qt_sdl/EmuThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ void EmuThread::run()
// update render settings if needed
if (videoSettingsDirty)
{
emuInstance->renderLock.lock();
if (useOpenGL)
{
emuInstance->setVSyncGL(true);
Expand All @@ -246,6 +247,7 @@ void EmuThread::run()
updateRenderer();

videoSettingsDirty = false;
emuInstance->renderLock.unlock();
}

// process input and hotkeys
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/qt_sdl/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ void ScreenPanelNative::paintEvent(QPaintEvent* event)

if (emuThread->emuIsActive())
{
emuInstance->renderLock.lock();
auto nds = emuInstance->getNDS();

assert(nds != nullptr);
Expand All @@ -801,6 +802,7 @@ void ScreenPanelNative::paintEvent(QPaintEvent* event)
painter.setTransform(screenTrans[i]);
painter.drawImage(screenrc, screen[screenKind[i]]);
}
emuInstance->renderLock.unlock();
}

osdUpdate();
Expand Down

0 comments on commit e3e561d

Please sign in to comment.