[PATCH 4/4] d3d9: Forbid creating a stateblock while recording.

Zebediah Figura z.figura12 at gmail.com
Tue Apr 2 12:42:48 CDT 2019


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/d3d9/device.c       | 9 +++++++++
 dlls/d3d9/tests/device.c | 4 ++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 4a41443e84..bad9211f45 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -2313,6 +2313,15 @@ static HRESULT WINAPI d3d9_device_CreateStateBlock(IDirect3DDevice9Ex *iface,
         return D3DERR_INVALIDCALL;
     }
 
+    wined3d_mutex_lock();
+    if (device->recording)
+    {
+        wined3d_mutex_unlock();
+        WARN("Trying to create a stateblock while recording, returning D3DERR_INVALIDCALL.\n");
+        return D3DERR_INVALIDCALL;
+    }
+    wined3d_mutex_unlock();
+
     if (!(object = heap_alloc_zero(sizeof(*object))))
         return E_OUTOFMEMORY;
 
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index 40ccdc4625..e7366b1977 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -10602,7 +10602,7 @@ static void test_begin_end_state_block(void)
     ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
 
     hr = IDirect3DDevice9_CreateStateBlock(device, D3DSBT_ALL, &stateblock2);
-    todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
 
     hr = IDirect3DDevice9_GetRenderState(device, D3DRS_LIGHTING, &value);
     ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
@@ -10621,7 +10621,7 @@ static void test_begin_end_state_block(void)
     IDirect3DStateBlock9_Release(stateblock);
     IDirect3DStateBlock9_Release(stateblock2);
     refcount = IDirect3DDevice9_Release(device);
-    todo_wine ok(!refcount, "Device has %u references left.\n", refcount);
+    ok(!refcount, "Device has %u references left.\n", refcount);
     IDirect3D9_Release(d3d);
     DestroyWindow(window);
 }
-- 
2.20.1




More information about the wine-devel mailing list