-- v2: oleaut32: Implement ICreateTypeLib2 DeleteTypeInfo
From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
--- dlls/oleaut32/tests/typelib.c | 46 +++++++++++++++++++++++++++++++++++ dlls/oleaut32/typelib.c | 26 ++++++++++++++++++-- 2 files changed, 70 insertions(+), 2 deletions(-)
diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index 59b2ea7c93e..9017ac29696 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -8366,6 +8366,51 @@ static void test_dep(void) { DeleteFileW(filenameW); }
+static void test_DeleteTypeInfo(void) +{ + static OLECHAR interface1W[] = L"interface1"; + static OLECHAR interface2W[] = L"interface2"; + ICreateTypeInfo *createti; + ICreateTypeLib2 *createtl; + ICreateTypeInfo2 *createti2; + WCHAR filenameW[MAX_PATH]; + ITypeLib *stdole; + HRESULT hr; + + hr = LoadTypeLib(L"stdole2.tlb", &stdole); + ok(hr == S_OK, "Failed to load stdole2, hr %#lx.\n", hr); + + GetTempFileNameW(L".", L"tlb", 0, filenameW); + + hr = CreateTypeLib2(SYS_WIN32, filenameW, &createtl); + ok(hr == S_OK, "Failed to create instance, hr %#lx.\n", hr); + + hr = ICreateTypeLib2_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti); + ok(hr == S_OK, "Failed to create instance, hr %#lx.\n", hr); + hr = ICreateTypeInfo_QueryInterface(createti, &IID_ICreateTypeInfo2, (void **)&createti2); + ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr); + ICreateTypeInfo_Release(createti); + + /* Reference to ICreateTypeInfo still exists */ + hr = ICreateTypeLib2_DeleteTypeInfo(createtl, interface1W); + ok(hr == E_FAIL, "got %08lx\n", hr); + + ICreateTypeInfo2_Release(createti2); + + hr = ICreateTypeLib2_DeleteTypeInfo(createtl, NULL); + ok(hr == E_INVALIDARG, "got %08lx\n", hr); + + hr = ICreateTypeLib2_DeleteTypeInfo(createtl, interface2W); + ok(hr == TYPE_E_ELEMENTNOTFOUND, "got %08lx\n", hr); + + hr = ICreateTypeLib2_DeleteTypeInfo(createtl, interface1W); + ok(hr == S_OK, "got %08lx\n", hr); + + ITypeLib_Release(stdole); + + DeleteFileW(filenameW); +} + static void test_DeleteImplType(void) { static OLECHAR interface1W[] = L"interface1"; @@ -8581,6 +8626,7 @@ START_TEST(typelib) test_GetLibAttr(); test_stub(); test_dep(); + test_DeleteTypeInfo(); test_DeleteImplType(); test_DeleteFuncDesc(); } diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c index dc354184d36..1695bba4f06 100644 --- a/dlls/oleaut32/typelib.c +++ b/dlls/oleaut32/typelib.c @@ -10389,8 +10389,30 @@ static HRESULT WINAPI ICreateTypeLib2_fnDeleteTypeInfo(ICreateTypeLib2 *iface, LPOLESTR name) { ITypeLibImpl *This = impl_from_ICreateTypeLib2(iface); - FIXME("%p %s - stub\n", This, wine_dbgstr_w(name)); - return E_NOTIMPL; + int i; + TRACE("%p %s\n", This, wine_dbgstr_w(name)); + + if (!name) + return E_INVALIDARG; + + for (i = 0; i < This->TypeInfoCount; ++i) + { + if (!lstrcmpiW(TLB_get_bstr(This->typeinfos[i]->Name), name)) + { + if (This->typeinfos[i]->ref != 1) + return E_FAIL; + + ITypeInfoImpl_Destroy(This->typeinfos[i]); + + This->TypeInfoCount--; + if (i < This->TypeInfoCount) + memmove(This->typeinfos + i, This->typeinfos + i + 1, (This->TypeInfoCount - i) * + sizeof(*This->typeinfos)); + return S_OK; + } + } + + return TYPE_E_ELEMENTNOTFOUND; }
static HRESULT WINAPI ICreateTypeLib2_fnSetCustData(ICreateTypeLib2 *iface,
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=136743
Your paranoid android.
=== debian11 (32 bit report) ===
oleaut32: typelib.c:8396: Test failed: got 00000000 typelib.c:8407: Test failed: got 8002802b
=== debian11 (32 bit ar:MA report) ===
oleaut32: typelib.c:8396: Test failed: got 00000000 typelib.c:8407: Test failed: got 8002802b
=== debian11 (32 bit de report) ===
oleaut32: typelib.c:8396: Test failed: got 00000000 typelib.c:8407: Test failed: got 8002802b
=== debian11 (32 bit fr report) ===
oleaut32: typelib.c:8396: Test failed: got 00000000 typelib.c:8407: Test failed: got 8002802b
=== debian11 (32 bit he:IL report) ===
oleaut32: typelib.c:8396: Test failed: got 00000000 typelib.c:8407: Test failed: got 8002802b
=== debian11 (32 bit hi:IN report) ===
oleaut32: typelib.c:8396: Test failed: got 00000000 typelib.c:8407: Test failed: got 8002802b
=== debian11 (32 bit ja:JP report) ===
oleaut32: typelib.c:8396: Test failed: got 00000000 typelib.c:8407: Test failed: got 8002802b
=== debian11 (32 bit zh:CN report) ===
oleaut32: typelib.c:8396: Test failed: got 00000000 typelib.c:8407: Test failed: got 8002802b
=== debian11b (32 bit WoW report) ===
oleaut32: typelib.c:8396: Test failed: got 00000000 typelib.c:8407: Test failed: got 8002802b
=== debian11b (64 bit WoW report) ===
oleaut32: typelib.c:8396: Test failed: got 00000000 typelib.c:8407: Test failed: got 8002802b