[PATCH v3 5/8] mfplat: Implement IMFAttributes::DeleteItem().

Jactry Zeng jzeng at codeweavers.com
Sun Jan 6 09:38:38 CST 2019


Signed-off-by: Jactry Zeng <jzeng at codeweavers.com>
---
 dlls/mfplat/main.c         | 21 +++++++++++++++++++--
 dlls/mfplat/tests/mfplat.c |  5 ++++-
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c
index 2877e9a929..f897325502 100644
--- a/dlls/mfplat/main.c
+++ b/dlls/mfplat/main.c
@@ -774,10 +774,27 @@ static HRESULT WINAPI mfattributes_SetItem(IMFAttributes *iface, REFGUID key, RE
 static HRESULT WINAPI mfattributes_DeleteItem(IMFAttributes *iface, REFGUID key)
 {
     mfattributes *This = impl_from_IMFAttributes(iface);
+    struct mfattribute *attribute = NULL;
+    int index = 0;
 
-    FIXME("%p, %s\n", This, debugstr_guid(key));
+    TRACE("(%p, %s)\n", This, debugstr_guid(key));
 
-    return E_NOTIMPL;
+    EnterCriticalSection(&This->lock);
+
+    index = mfattributes_finditem(This, key, &attribute);
+    if(attribute)
+    {
+        PropVariantClear(&attribute->value);
+        heap_free(attribute);
+
+        This->count--;
+        for(; index < This->count; index++)
+            This->attributes[index] = This->attributes[index + 1];
+    }
+
+    LeaveCriticalSection(&This->lock);
+
+    return S_OK;
 }
 
 static HRESULT WINAPI mfattributes_DeleteAllItems(IMFAttributes *iface)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c
index a9e2cc90d7..088a1d83a7 100644
--- a/dlls/mfplat/tests/mfplat.c
+++ b/dlls/mfplat/tests/mfplat.c
@@ -777,7 +777,7 @@ static void test_IMFAttributes_item(void)
     ok(hr == S_OK, "IMFAttributes_SetItem failed: 0x%08x.\n", hr);
 
     hr = IMFAttributes_DeleteItem(attributes, &DUMMY_GUID2);
-    todo_wine ok(hr == S_OK, "IMFAttributes_DeleteItem failed: 0x%08x.\n", hr);
+    ok(hr == S_OK, "IMFAttributes_DeleteItem failed: 0x%08x.\n", hr);
     if(is_prewin8())
         hr = IMFAttributes_GetItemByIndex(attributes, 1, &key, &ret_propvar);
     else
@@ -797,6 +797,9 @@ static void test_IMFAttributes_item(void)
     todo_wine ok(!PropVariantCompareEx(&propvar, &ret_propvar, 0, 0), "got wrong property.\n");
     todo_wine ok(IsEqualIID(&key, &DUMMY_GUID1), "got wrong key: %s.\n", wine_dbgstr_guid(&key));
 
+    hr = IMFAttributes_DeleteItem(attributes, &DUMMY_GUID2);
+    ok(hr == S_OK, "IMFAttributes_DeleteItem failed: 0x%08x.\n", hr);
+
     IMFAttributes_Release(attributes);
 }
 
-- 
2.20.1





More information about the wine-devel mailing list