don't segfault on closing

This commit is contained in:
RSDuck 2022-10-12 23:28:07 +02:00
parent cdaa52256f
commit dbd75f8ae4
2 changed files with 24 additions and 21 deletions

View File

@ -464,15 +464,12 @@ void EmuThread::run()
videoSettings.GL_ScaleFactor = Config::GL_ScaleFactor;
videoSettings.GL_BetterPolygons = Config::GL_BetterPolygons;
bool hasOGL = mainWindow->hasOGL;
#ifdef OGLRENDERER_ENABLED
if (hasOGL)
if (mainWindow->hasOGL)
{
initOpenGL();
videoRenderer = Config::_3DRenderer;
}
else
#endif
{
videoRenderer = 0;
}
@ -547,20 +544,19 @@ void EmuThread::run()
// update render settings if needed
if (videoSettingsDirty)
{
if (hasOGL != mainWindow->hasOGL)
if (oglContext)
{
hasOGL = mainWindow->hasOGL;
oglContext->SetSwapInterval(Config::ScreenVSync ? Config::ScreenVSyncInterval : 0);
videoRenderer = Config::_3DRenderer;
}
#ifdef OGLRENDERER_ENABLED
if (hasOGL)
videoRenderer = Config::_3DRenderer;
else
#endif
videoRenderer = 0;
}
else
#endif
{
videoRenderer = hasOGL ? Config::_3DRenderer : 0;
}
videoRenderer = 0;
}
videoRenderer = oglContext ? Config::_3DRenderer : 0;
videoSettingsDirty = false;
@ -568,11 +564,6 @@ void EmuThread::run()
videoSettings.GL_ScaleFactor = Config::GL_ScaleFactor;
videoSettings.GL_BetterPolygons = Config::GL_BetterPolygons;
if (hasOGL)
{
oglContext->SetSwapInterval(Config::ScreenVSync ? Config::ScreenVSyncInterval : 0);
}
GPU::SetRenderSettings(videoRenderer, videoSettings);
}
@ -629,7 +620,7 @@ void EmuThread::run()
if (ROMManager::GBASave)
ROMManager::GBASave->CheckFlush();
if (!hasOGL)
if (!oglContext)
{
FrontBufferLock.lock();
FrontBuffer = GPU::FrontBuffer;
@ -752,7 +743,7 @@ void EmuThread::run()
NDS::DeInit();
//Platform::LAN_DeInit();
if (hasOGL)
if (oglContext)
deinitOpenGL();
}
@ -1831,6 +1822,15 @@ MainWindow::~MainWindow()
{
}
void MainWindow::closeEvent(QCloseEvent* event)
{
printf("close event\n");
emuThread->emuPause();
emuThread->deinitContext();
QMainWindow::closeEvent(event);
}
void MainWindow::createScreenPanel()
{
hasOGL = (Config::ScreenUseGL != 0) || (Config::_3DRenderer != 0);

View File

@ -31,6 +31,7 @@
#include <QTimer>
#include <QMutex>
#include <QScreen>
#include <QCloseEvent>
#include <atomic>
@ -325,6 +326,8 @@ private slots:
void onFullscreenToggled();
private:
void closeEvent(QCloseEvent* event);
QStringList currentROM;
QStringList currentGBAROM;
QList<QString> recentFileList;