Henri Verbeet : wined3d: Release the stateblock only after mode setting in wined3d_device_reset().

Alexandre Julliard julliard at winehq.org
Tue Jun 26 13:34:15 CDT 2012


Module: wine
Branch: master
Commit: d93e61f2499f747e7d70960f3a6547ed2b3a0b02
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d93e61f2499f747e7d70960f3a6547ed2b3a0b02

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Tue Jun 26 15:32:10 2012 +0200

wined3d: Release the stateblock only after mode setting in wined3d_device_reset().

While we're allowed to leave the device in a somewhat inconsistent state after
a failed reset, such a state should be recoverable by calling reset again. If
e.g. mode setting were to fail between the point where we destroy and recreate
the stateblock a subsequent reset would crash because the device doesn't have
a stateblock anymore.

---

 dlls/wined3d/device.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index cae76ff..dbd2359 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -5293,10 +5293,6 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
     if (swapchain_desc->enable_auto_depth_stencil)
         wined3d_device_set_depth_stencil(device, device->auto_depth_stencil);
 
-    TRACE("Resetting stateblock\n");
-    wined3d_stateblock_decref(device->updateStateBlock);
-    wined3d_stateblock_decref(device->stateBlock);
-
     if (swapchain_desc->windowed)
     {
         mode.width = swapchain->orig_width;
@@ -5377,9 +5373,6 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
         }
     }
 
-    if (device->d3d_initialized)
-        delete_opengl_contexts(device, swapchain);
-
     if (!swapchain_desc->windowed != !swapchain->desc.windowed
             || DisplayModeChanged)
     {
@@ -5443,6 +5436,13 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
         device->exStyle = exStyle;
     }
 
+    TRACE("Resetting stateblock.\n");
+    wined3d_stateblock_decref(device->updateStateBlock);
+    wined3d_stateblock_decref(device->stateBlock);
+
+    if (device->d3d_initialized)
+        delete_opengl_contexts(device, swapchain);
+
     /* Note: No parent needed for initial internal stateblock */
     hr = wined3d_stateblock_create(device, WINED3D_SBT_INIT, &device->stateBlock);
     if (FAILED(hr))




More information about the wine-cvs mailing list