lock framebuffer stuff to prevent conflicts when reiniting the core or changing the renderer

This commit is contained in:
Arisotura 2024-10-31 22:51:18 +01:00
parent 9c8f229fed
commit e3e561da3f
4 changed files with 8 additions and 0 deletions

View File

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

View File

@ -150,6 +150,8 @@ public:
void touchScreen(int x, int y); void touchScreen(int x, int y);
void releaseScreen(); void releaseScreen();
QMutex renderLock;
private: private:
static int lastSep(const std::string& path); static int lastSep(const std::string& path);
std::string getAssetPath(bool gba, const std::string& configpath, const std::string& ext, const std::string& file); std::string getAssetPath(bool gba, const std::string& configpath, const std::string& ext, const std::string& file);

View File

@ -231,6 +231,7 @@ void EmuThread::run()
// update render settings if needed // update render settings if needed
if (videoSettingsDirty) if (videoSettingsDirty)
{ {
emuInstance->renderLock.lock();
if (useOpenGL) if (useOpenGL)
{ {
emuInstance->setVSyncGL(true); emuInstance->setVSyncGL(true);
@ -246,6 +247,7 @@ void EmuThread::run()
updateRenderer(); updateRenderer();
videoSettingsDirty = false; videoSettingsDirty = false;
emuInstance->renderLock.unlock();
} }
// process input and hotkeys // process input and hotkeys

View File

@ -779,6 +779,7 @@ void ScreenPanelNative::paintEvent(QPaintEvent* event)
if (emuThread->emuIsActive()) if (emuThread->emuIsActive())
{ {
emuInstance->renderLock.lock();
auto nds = emuInstance->getNDS(); auto nds = emuInstance->getNDS();
assert(nds != nullptr); assert(nds != nullptr);
@ -801,6 +802,7 @@ void ScreenPanelNative::paintEvent(QPaintEvent* event)
painter.setTransform(screenTrans[i]); painter.setTransform(screenTrans[i]);
painter.drawImage(screenrc, screen[screenKind[i]]); painter.drawImage(screenrc, screen[screenKind[i]]);
} }
emuInstance->renderLock.unlock();
} }
osdUpdate(); osdUpdate();