all repos — mgba @ bda0f67103dfb316b6da67c4172e52a9e42d9ec1

mGBA Game Boy Advance Emulator

Qt: Fix shutdown crashes
Vicki Pfau vi@endrift.com
Mon, 20 May 2019 15:31:47 -0700
commit

bda0f67103dfb316b6da67c4172e52a9e42d9ec1

parent

eeee6fe44eb11e77774c7bb3f08c2016682d33cd

M src/gba/extra/proxy.csrc/gba/extra/proxy.c

@@ -133,6 +133,7 @@ if (!proxyRenderer->logger->block) {

proxyRenderer->backend->deinit(proxyRenderer->backend); } else { proxyRenderer->logger->postEvent(proxyRenderer->logger, LOGGER_EVENT_DEINIT); + mVideoLoggerRendererFlush(proxyRenderer->logger); } mVideoLoggerRendererDeinit(proxyRenderer->logger);
M src/platform/qt/CoreController.cppsrc/platform/qt/CoreController.cpp

@@ -196,9 +196,6 @@ if (m_cacheSet) {

mCacheSetDeinit(m_cacheSet.get()); m_cacheSet.reset(); } - - mCoreConfigDeinit(&m_threadContext.core->config); - m_threadContext.core->deinit(m_threadContext.core); } const color_t* CoreController::drawContext() {
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -631,8 +631,10 @@ m_config->setOption("height", GBA_VIDEO_VERTICAL_PIXELS * m_savedScale);

m_config->setOption("width", GBA_VIDEO_HORIZONTAL_PIXELS * m_savedScale); } saveConfig(); - m_display.reset(); - QMainWindow::closeEvent(event); + if (m_controller) { + event->ignore(); + m_pendingClose = true; + } } void Window::focusInEvent(QFocusEvent*) {

@@ -776,6 +778,11 @@ }

void Window::gameStopped() { m_controller.reset(); + m_display->stopDrawing(); + if (m_pendingClose) { + m_display.reset(); + close(); + } #ifdef M_CORE_GBA for (Action* action : m_platformActions) { action->setEnabled(true);

@@ -863,7 +870,6 @@ m_shaderView.reset();

m_shaderView = std::make_unique<ShaderSelector>(m_display.get(), m_config); #endif - connect(this, &Window::shutdown, m_display.get(), &Display::stopDrawing); connect(m_display.get(), &Display::hideCursor, [this]() { if (static_cast<QStackedLayout*>(m_screenWidget->layout())->currentWidget() == m_display.get()) { m_screenWidget->setCursor(Qt::BlankCursor);

@@ -888,7 +894,6 @@ }

#endif if (m_controller) { - connect(m_controller.get(), &CoreController::stopping, m_display.get(), &Display::stopDrawing); connect(m_controller.get(), &CoreController::stateLoaded, m_display.get(), &Display::resizeContext); connect(m_controller.get(), &CoreController::stateLoaded, m_display.get(), &Display::forceDraw); connect(m_controller.get(), &CoreController::rewound, m_display.get(), &Display::forceDraw);

@@ -1700,6 +1705,9 @@ void Window::setController(CoreController* controller, const QString& fname) {

if (!controller) { return; } + if (m_pendingClose) { + return; + } if (m_controller) { m_controller->stop();

@@ -1739,6 +1747,7 @@ if (!m_controller) {

return; } m_controller->stop(); + disconnect(m_controller.get(), &CoreController::started, this, &Window::gameStarted); }); connect(m_controller.get(), &CoreController::started, this, &Window::gameStarted);

@@ -1766,7 +1775,6 @@ connect(m_controller.get(), &CoreController::unpaused, [this]() {

emit paused(false); }); - connect(m_controller.get(), &CoreController::stopping, m_display.get(), &Display::stopDrawing); connect(m_controller.get(), &CoreController::stateLoaded, m_display.get(), &Display::resizeContext); connect(m_controller.get(), &CoreController::stateLoaded, m_display.get(), &Display::forceDraw); connect(m_controller.get(), &CoreController::rewound, m_display.get(), &Display::forceDraw);
M src/platform/qt/Window.hsrc/platform/qt/Window.h

@@ -209,6 +209,7 @@ bool m_wasOpened = false;

QString m_pendingPatch; QString m_pendingState; bool m_pendingPause = false; + bool m_pendingClose = false; bool m_hitUnimplementedBiosCall;