File tree Expand file tree Collapse file tree 4 files changed +16
-10
lines changed
Expand file tree Collapse file tree 4 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ Other fixes:
5454 - Qt: Fix selecting high tiles in tile and map views (fixes mgba.io/i/3461)
5555 - Qt: Fix some actions disabled in multiplayer staying disabled after closing game
5656 - Qt: Fix unexpected mute when window becomes focused while fast-forwarding
57+ - Qt: Fix crashes when exiting with OpenGL renderer
5758Misc:
5859 - 3DS: Change title ID to avoid conflict with commercial title (fixes mgba.io/i/3023)
5960 - Core: Handle relative paths for saves, screenshots, etc consistently (fixes mgba.io/i/2826)
Original file line number Diff line number Diff line change @@ -917,9 +917,6 @@ void PainterGL::doStop() {
917917 m_started = false ;
918918 dequeueAll (false );
919919 if (m_context) {
920- if (m_videoProxy) {
921- m_videoProxy->detach (m_context.get ());
922- }
923920 m_context->setFramebufferHandle (-1 );
924921 m_context.reset ();
925922 if (m_videoProxy) {
Original file line number Diff line number Diff line change @@ -992,12 +992,7 @@ void Window::gameStopped() {
992992#endif
993993 }
994994
995- std::shared_ptr<CoreController> controller;
996- m_controller.swap (controller);
997- QTimer::singleShot (0 , this , [controller]() {
998- // Destroy the controller after everything else has cleaned up
999- Q_UNUSED (controller);
1000- });
995+ m_cleanupController = std::move (m_controller);
1001996 detachWidget ();
1002997 updateTitle ();
1003998
@@ -1008,9 +1003,10 @@ void Window::gameStopped() {
10081003 m_scripting->setVideoBackend (nullptr );
10091004 }
10101005#endif
1011- m_display. reset ( );
1006+ m_cleanupDisplay = std::move (m_display );
10121007 close ();
10131008 }
1009+ QTimer::singleShot (0 , this , &Window::delayedCleanup);
10141010#ifndef Q_OS_MAC
10151011 showMenu (true );
10161012#endif
@@ -2360,6 +2356,13 @@ void Window::setLogo() {
23602356 centralWidget ()->unsetCursor ();
23612357}
23622358
2359+ void Window::delayedCleanup () {
2360+ // Destroy the controller after everything else has cleaned up, except for the display
2361+ m_cleanupController.reset ();
2362+ // The display needs to be cleaned up last so the core can clean up the OpenGL resources
2363+ m_cleanupDisplay.reset ();
2364+ }
2365+
23632366WindowBackground::WindowBackground (QWidget* parent)
23642367 : QWidget (parent)
23652368{
Original file line number Diff line number Diff line change @@ -161,6 +161,8 @@ private slots:
161161
162162 void setLogo ();
163163
164+ void delayedCleanup ();
165+
164166private:
165167 static const int FPS_TIMER_INTERVAL = 2000 ;
166168 static const int MUST_RESTART_TIMEOUT = 10000 ;
@@ -266,6 +268,9 @@ private slots:
266268#ifdef ENABLE_SCRIPTING
267269 std::unique_ptr<ScriptingController> m_scripting;
268270#endif
271+
272+ std::unique_ptr<QGBA::Display> m_cleanupDisplay;
273+ std::shared_ptr<CoreController> m_cleanupController;
269274};
270275
271276class WindowBackground : public QWidget {
You can’t perform that action at this time.
0 commit comments