[PATCH v3 1/5] ddraw: Keep a ddraw object reference in d3d7 vertex buffers.

Matteo Bruni mbruni at codeweavers.com
Wed Mar 8 13:45:44 CST 2017


Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
For bug 38307. With this it doesn't crash anymore for me but it still
fails with a "Runtime Error : ERROR 10. " messagebox a bit later.

v2: Modified for the changes in the previous patch. Split tests out.
v3: AddRef() in d3d_vertex_buffer_create() instead.

 dlls/ddraw/vertexbuffer.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/dlls/ddraw/vertexbuffer.c b/dlls/ddraw/vertexbuffer.c
index 515c86e..07f1257 100644
--- a/dlls/ddraw/vertexbuffer.c
+++ b/dlls/ddraw/vertexbuffer.c
@@ -81,25 +81,27 @@ static ULONG WINAPI d3d_vertex_buffer7_Release(IDirect3DVertexBuffer7 *iface)
 
     TRACE("%p decreasing refcount to %u.\n", buffer, ref);
 
-    if (ref == 0)
+    if (!ref)
     {
-        struct wined3d_buffer *curVB = NULL;
+        struct wined3d_buffer *vb = NULL;
         UINT offset, stride;
 
-        /* D3D7 Vertex buffers don't stay bound in the device, they are passed
-         * as a parameter to drawPrimitiveVB. DrawPrimitiveVB sets them as the
-         * stream source in wined3d, and they should get unset there before
+        /* D3D7 vertex buffers don't stay bound in the device, they are passed
+         * as a parameter to DrawPrimitiveVB. DrawPrimitiveVB sets them as the
+         * stream source in wined3d and they should get unset there before
          * they are destroyed. */
         wined3d_mutex_lock();
-        wined3d_device_get_stream_source(buffer->ddraw->wined3d_device,
-                0, &curVB, &offset, &stride);
-        if (curVB == buffer->wined3d_buffer)
+        wined3d_device_get_stream_source(buffer->ddraw->wined3d_device, 0, &vb, &offset, &stride);
+        if (vb == buffer->wined3d_buffer)
             wined3d_device_set_stream_source(buffer->ddraw->wined3d_device, 0, NULL, 0, 0);
 
         wined3d_vertex_declaration_decref(buffer->wined3d_declaration);
         wined3d_buffer_decref(buffer->wined3d_buffer);
         wined3d_mutex_unlock();
 
+        if (buffer->version == 7)
+            IDirectDraw7_Release(&buffer->ddraw->IDirectDraw7_iface);
+
         HeapFree(GetProcessHeap(), 0, buffer);
     }
 
@@ -451,7 +453,8 @@ HRESULT d3d_vertex_buffer_create(struct d3d_vertex_buffer **vertex_buf,
     buffer->IDirect3DVertexBuffer7_iface.lpVtbl = &d3d_vertex_buffer7_vtbl;
     buffer->ref = 1;
     buffer->version = ddraw->d3dversion;
-
+    if (buffer->version == 7)
+        IDirectDraw7_AddRef(&ddraw->IDirectDraw7_iface);
     buffer->ddraw = ddraw;
     buffer->Caps = desc->dwCaps;
     buffer->fvf = desc->dwFVF;
-- 
2.10.2




More information about the wine-patches mailing list