From 7a94b959c9e1a3524ef49c18d05078b319685a75 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 10 Apr 2006 15:08:04 +0000 Subject: [PATCH] Destroy D3D after destroying the window. Fixes another DestroyWindow crash: start in fullscreen, change to a window, close the game. This is sort of trial-and-error: there seems to be no documentation about the proper order of shutting down a window. Shutting down D3D first makes sense: restore the window to normal, then destroy it, so we don't kill the window while D3D is still using it. But this seems to work, and it's how we did it in 3.9. (I think releasing D3D first is leaving traces behind in the window, which then cause stale dereferences; the previous FreeLibrary() change was for the same problem, and this seems to just be another incarnation of that.) 7c918fea: ntdll!RtlpWaitForCriticalSection [7c900000+18f8f+5b] 77d48bd9: USER32!GetWindowThreadProcessId [77d40000+8a80+159] 77d4b3cc: USER32!DefWindowProcW [77d40000+b33c+90] 7c90104b: ntdll!RtlEnterCriticalSection [7c900000+1005+46] 6d9ab228: D3D8!CheckFullscreen [6d9a0000+b060+1c8] 77d48734: USER32!GetDC [77d40000+86c7+6d] 77d4b4c0: USER32!DefWindowProcW [77d40000+b33c+184] 7c90eae3: ntdll!KiUserCallbackDispatcher [7c900000+ead0+13] 77d4daf6: USER32!DestroyWindow [77d40000+daea+c] 00539971: void GraphicsWindow::DestroyGraphicsWindow(void) [00400000+1398d1+a0] --- stepmania/src/RageDisplay_D3D.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stepmania/src/RageDisplay_D3D.cpp b/stepmania/src/RageDisplay_D3D.cpp index 29ea05f494..9ca21ea8df 100644 --- a/stepmania/src/RageDisplay_D3D.cpp +++ b/stepmania/src/RageDisplay_D3D.cpp @@ -281,6 +281,8 @@ RageDisplay_D3D::~RageDisplay_D3D() { LOG->Trace( "RageDisplay_D3D::~RageDisplay()" ); + GraphicsWindow::Shutdown(); + if( g_pd3dDevice ) { g_pd3dDevice->Release(); @@ -293,8 +295,6 @@ RageDisplay_D3D::~RageDisplay_D3D() g_pd3d = NULL; } - GraphicsWindow::Shutdown(); - /* Even after we call Release(), D3D may still affect our window. It seems to subclass * the window, and never release it. Free the DLL after destroying the window. */ #if !defined(XBOX)