瀏覽代碼

hmm, previous check in caused a crash on toontown, this fixes it

Asad M. Zaman 21 年之前
父節點
當前提交
1c5385b973
共有 2 個文件被更改,包括 14 次插入7 次删除
  1. 9 7
      panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx
  2. 5 0
      panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx

+ 9 - 7
panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx

@@ -4509,12 +4509,16 @@ dx_cleanup(bool bRestoreDisplayMode,bool bAtExitFnCalled) {
     //    if(bAtExitFnEverCalled)
     //    if(bAtExitFnEverCalled)
     //      return;
     //      return;
 
 
+    if (!_pD3DDevice)
+      return;
+
     // unsafe to do the D3D releases after exit() called, since DLL_PROCESS_DETACH
     // unsafe to do the D3D releases after exit() called, since DLL_PROCESS_DETACH
     // msg already delivered to d3d.dll and it's unloaded itself
     // msg already delivered to d3d.dll and it's unloaded itself
 
 
     wdxdisplay8_cat.debug() << "called dx_cleanup\n";
     wdxdisplay8_cat.debug() << "called dx_cleanup\n";
     free_nondx_resources();
     free_nondx_resources();
 
 
+    wdxdisplay8_cat.debug() << "device : " << _pD3DDevice << endl;
     PRINT_REFCNT(dxgsg8,_pD3DDevice);
     PRINT_REFCNT(dxgsg8,_pD3DDevice);
 
 
     // delete non-panda-texture/geom DX objects (VBs/textures/shaders)
     // delete non-panda-texture/geom DX objects (VBs/textures/shaders)
@@ -4526,13 +4530,11 @@ dx_cleanup(bool bRestoreDisplayMode,bool bAtExitFnCalled) {
 
 
     // Do a safe check for releasing the D3DDEVICE. RefCount should be zero.
     // Do a safe check for releasing the D3DDEVICE. RefCount should be zero.
     // if we're called from exit(), _pD3DDevice may already have been released
     // if we're called from exit(), _pD3DDevice may already have been released
-    if (_pD3DDevice!=NULL) {
-        for(int i=0;i<D3D_MAXTEXTURESTAGES;i++)
-           _pD3DDevice->SetTexture(i,NULL);  // d3d should release this stuff internally anyway, but whatever
-        RELEASE(_pD3DDevice,dxgsg8,"d3dDevice",RELEASE_DOWN_TO_ZERO);
-        _pScrn->pD3DDevice = NULL;
-    }
-
+    for(int i=0;i<D3D_MAXTEXTURESTAGES;i++)
+      _pD3DDevice->SetTexture(i,NULL);  // d3d should release this stuff internally anyway, but whatever
+    RELEASE(_pD3DDevice,dxgsg8,"d3dDevice",RELEASE_DOWN_TO_ZERO);
+    _pScrn->pD3DDevice = NULL;
+    
     // Releasing pD3D is now the responsibility of the GraphicsPipe destructor
     // Releasing pD3D is now the responsibility of the GraphicsPipe destructor
 }
 }
 
 

+ 5 - 0
panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx

@@ -4513,11 +4513,16 @@ dx_cleanup(bool bRestoreDisplayMode,bool bAtExitFnCalled) {
     //    if(bAtExitFnEverCalled)
     //    if(bAtExitFnEverCalled)
     //      return;
     //      return;
 
 
+    if (!_pD3DDevice)
+      return;
+
     // unsafe to do the D3D releases after exit() called, since DLL_PROCESS_DETACH
     // unsafe to do the D3D releases after exit() called, since DLL_PROCESS_DETACH
     // msg already delivered to d3d.dll and it's unloaded itself
     // msg already delivered to d3d.dll and it's unloaded itself
 
 
+    wdxdisplay9_cat.debug() << "called dx_cleanup\n";
     free_nondx_resources();
     free_nondx_resources();
 
 
+    wdxdisplay9_cat.debug() << "device : " << _pD3DDevice << endl;
     PRINT_REFCNT(dxgsg9,_pD3DDevice);
     PRINT_REFCNT(dxgsg9,_pD3DDevice);
 
 
     // delete non-panda-texture/geom DX objects (VBs/textures/shaders)
     // delete non-panda-texture/geom DX objects (VBs/textures/shaders)