Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Other fixes:
- Qt: Fix selecting high tiles in tile and map views (fixes mgba.io/i/3461)
- Qt: Fix some actions disabled in multiplayer staying disabled after closing game
- Qt: Fix unexpected mute when window becomes focused while fast-forwarding
- Qt: Fix crashes when exiting with OpenGL renderer
Misc:
- 3DS: Change title ID to avoid conflict with commercial title (fixes mgba.io/i/3023)
- Core: Handle relative paths for saves, screenshots, etc consistently (fixes mgba.io/i/2826)
Expand Down
1 change: 1 addition & 0 deletions src/debugger/debugger.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ void mDebuggerDetachModule(struct mDebugger* debugger, struct mDebuggerModule* m
module->deinit(module);
}
}
module->p = NULL;
mDebuggerModuleListShift(&debugger->modules, i, 1);
break;
}
Expand Down
3 changes: 0 additions & 3 deletions src/platform/qt/DisplayGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,9 +917,6 @@ void PainterGL::doStop() {
m_started = false;
dequeueAll(false);
if (m_context) {
if (m_videoProxy) {
m_videoProxy->detach(m_context.get());
}
m_context->setFramebufferHandle(-1);
m_context.reset();
if (m_videoProxy) {
Expand Down
17 changes: 10 additions & 7 deletions src/platform/qt/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,12 +992,7 @@ void Window::gameStopped() {
#endif
}

std::shared_ptr<CoreController> controller;
m_controller.swap(controller);
QTimer::singleShot(0, this, [controller]() {
// Destroy the controller after everything else has cleaned up
Q_UNUSED(controller);
});
m_cleanupController = std::move(m_controller);
detachWidget();
updateTitle();

Expand All @@ -1008,9 +1003,10 @@ void Window::gameStopped() {
m_scripting->setVideoBackend(nullptr);
}
#endif
m_display.reset();
m_cleanupDisplay = std::move(m_display);
close();
}
QTimer::singleShot(0, this, &Window::delayedCleanup);
#ifndef Q_OS_MAC
showMenu(true);
#endif
Expand Down Expand Up @@ -2360,6 +2356,13 @@ void Window::setLogo() {
centralWidget()->unsetCursor();
}

void Window::delayedCleanup() {
// Destroy the controller after everything else has cleaned up, except for the display
m_cleanupController.reset();
// The display needs to be cleaned up last so the core can clean up the OpenGL resources
m_cleanupDisplay.reset();
}

WindowBackground::WindowBackground(QWidget* parent)
: QWidget(parent)
{
Expand Down
5 changes: 5 additions & 0 deletions src/platform/qt/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ private slots:

void setLogo();

void delayedCleanup();

private:
static const int FPS_TIMER_INTERVAL = 2000;
static const int MUST_RESTART_TIMEOUT = 10000;
Expand Down Expand Up @@ -266,6 +268,9 @@ private slots:
#ifdef ENABLE_SCRIPTING
std::unique_ptr<ScriptingController> m_scripting;
#endif

std::unique_ptr<QGBA::Display> m_cleanupDisplay;
std::shared_ptr<CoreController> m_cleanupController;
};

class WindowBackground : public QWidget {
Expand Down