Matteo Bruni : d3dx9: Skip AddRef + Release if SetValue is called with the old texture.

Alexandre Julliard julliard at winehq.org
Wed Mar 14 17:37:18 CDT 2018


Module: wine
Branch: master
Commit: 972dc565edaf7cff3173b146f340ffd817d0a018
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=972dc565edaf7cff3173b146f340ffd817d0a018

Author: Matteo Bruni <mbruni at codeweavers.com>
Date:   Wed Mar 14 19:53:18 2018 +0100

d3dx9: Skip AddRef + Release if SetValue is called with the old texture.

Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/d3dx9_36/effect.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c
index a98495e..7f54e25 100644
--- a/dlls/d3dx9_36/effect.c
+++ b/dlls/d3dx9_36/effect.c
@@ -1555,13 +1555,16 @@ static HRESULT d3dx9_base_effect_set_value(struct d3dx9_base_effect *base,
             case D3DXPT_TEXTURECUBE:
                 for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
                 {
-                    IUnknown *unk = ((IUnknown **)data)[i];
-                    if (unk)
-                        IUnknown_AddRef(unk);
+                    IUnknown *old_texture = ((IUnknown **)param->data)[i];
+                    IUnknown *new_texture = ((IUnknown **)data)[i];
 
-                    unk = ((IUnknown **)param->data)[i];
-                    if (unk)
-                        IUnknown_Release(unk);
+                    if (new_texture == old_texture)
+                        continue;
+
+                    if (new_texture)
+                        IUnknown_AddRef(new_texture);
+                    if (old_texture)
+                        IUnknown_Release(old_texture);
                 }
             /* fallthrough */
             case D3DXPT_VOID:




More information about the wine-cvs mailing list