mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix shutdown crashes
This commit is contained in:
parent
eeee6fe44e
commit
bda0f67103
|
@ -133,6 +133,7 @@ void GBAVideoProxyRendererDeinit(struct GBAVideoRenderer* renderer) {
|
|||
proxyRenderer->backend->deinit(proxyRenderer->backend);
|
||||
} else {
|
||||
proxyRenderer->logger->postEvent(proxyRenderer->logger, LOGGER_EVENT_DEINIT);
|
||||
mVideoLoggerRendererFlush(proxyRenderer->logger);
|
||||
}
|
||||
|
||||
mVideoLoggerRendererDeinit(proxyRenderer->logger);
|
||||
|
|
|
@ -196,9 +196,6 @@ CoreController::~CoreController() {
|
|||
mCacheSetDeinit(m_cacheSet.get());
|
||||
m_cacheSet.reset();
|
||||
}
|
||||
|
||||
mCoreConfigDeinit(&m_threadContext.core->config);
|
||||
m_threadContext.core->deinit(m_threadContext.core);
|
||||
}
|
||||
|
||||
const color_t* CoreController::drawContext() {
|
||||
|
|
|
@ -631,8 +631,10 @@ void Window::closeEvent(QCloseEvent* event) {
|
|||
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::gameStarted() {
|
|||
|
||||
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 @@ void Window::reloadDisplayDriver() {
|
|||
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 @@ void Window::reloadDisplayDriver() {
|
|||
#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 @@ void Window::setController(CoreController* controller, const QString& fname) {
|
|||
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 @@ void Window::setController(CoreController* controller, const QString& fname) {
|
|||
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);
|
||||
|
|
|
@ -209,6 +209,7 @@ private:
|
|||
QString m_pendingPatch;
|
||||
QString m_pendingState;
|
||||
bool m_pendingPause = false;
|
||||
bool m_pendingClose = false;
|
||||
|
||||
bool m_hitUnimplementedBiosCall;
|
||||
|
||||
|
|
Loading…
Reference in New Issue