fix freeze when starting new emu instance while using OpenGL

This commit is contained in:
Arisotura 2024-10-27 10:17:59 +01:00
parent 24ca1a5fdb
commit e6f0d77aa0
4 changed files with 21 additions and 11 deletions

View File

@ -201,7 +201,7 @@ void EmuInstance::createWindow()
emuThread->attachWindow(win);
// if creating a secondary window, we may need to initialize its OpenGL context here
if (win->hasOpenGL() && (win != topWindow))
if (win->hasOpenGL() && (id != 0))
emuThread->initContext(id);
}

View File

@ -749,8 +749,10 @@ bool ScreenPanelGL::createContext()
// if our parent window is parented to another window, we will
// share our OpenGL context with that window
MainWindow* ourwin = (MainWindow*)parentWidget();
MainWindow* parentwin = (MainWindow*)parentWidget()->parentWidget();
if (parentwin)
//if (parentwin)
if (ourwin->getWindowID() != 0)
{
if (windowinfo.has_value())
if (glContext = parentwin->getOGLContext()->CreateSharedContext(*windowinfo))

View File

@ -2147,9 +2147,14 @@ void MainWindow::onEmuReset()
void MainWindow::onUpdateVideoSettings(bool glchange)
{
if (windowID != 0)
{
MainWindow* parentwin = (MainWindow*)parentWidget();
if (parentwin)
return parentwin->onUpdateVideoSettings(glchange);
parentwin->onUpdateVideoSettings(glchange);
return;
}
bool hadOGL = hasOGL;
if (glchange)
@ -2166,13 +2171,16 @@ void MainWindow::onUpdateVideoSettings(bool glchange)
{
if (hasOGL) emuThread->initContext(windowID);
auto childwins = findChildren<MainWindow*>(nullptr, Qt::FindDirectChildrenOnly);
for (auto child : childwins)
if (windowID == 0)
{
auto childwins = findChildren<MainWindow *>(nullptr, Qt::FindDirectChildrenOnly);
for (auto child: childwins)
{
if (hadOGL) emuThread->deinitContext(child->windowID);
child->createScreenPanel();
if (hasOGL) emuThread->initContext(child->windowID);
}
}
emuThread->emuUnpause();
}

View File

@ -110,7 +110,7 @@ public:
EmuInstance* getEmuInstance() { return emuInstance; }
Config::Table& getWindowConfig() { return windowCfg; }
int getID() { return windowID; }
int getWindowID() { return windowID; }
bool winHasMenu() { return hasMenu; }