oleaut32: Return TYPE_E_NAMECONFLICT in ICreateTypeLib2::CreateTypeInfo.

This commit is contained in:
Piotr Caban 2010-02-17 13:02:06 +01:00 committed by Alexandre Julliard
parent 2c911147b9
commit 1f2590be9b
2 changed files with 15 additions and 0 deletions

View File

@ -969,9 +969,12 @@ if(use_midl_tlb) {
}
static void test_CreateTypeLib(void) {
static OLECHAR interface1W[] = {'i','n','t','e','r','f','a','c','e','1',0};
char filename[MAX_PATH];
WCHAR filenameW[MAX_PATH];
ICreateTypeLib2 *createtl;
ICreateTypeInfo *createti;
ITypeLib *tl;
HRESULT hres;
@ -983,6 +986,13 @@ static void test_CreateTypeLib(void) {
hres = CreateTypeLib2(SYS_WIN32, filenameW, &createtl);
ok(hres == S_OK, "got %08x\n", hres);
hres = ICreateTypeLib_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti);
ok(hres == S_OK, "got %08x\n", hres);
ICreateTypeInfo_Release(createti);
hres = ICreateTypeLib_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti);
ok(hres == TYPE_E_NAMECONFLICT, "got %08x\n", hres);
hres = ICreateTypeLib2_SaveAllChanges(createtl);
ok(hres == S_OK, "got %08x\n", hres);
ICreateTypeLib2_Release(createtl);

View File

@ -3073,9 +3073,14 @@ static HRESULT WINAPI ICreateTypeLib2_fnCreateTypeInfo(
ICreateTypeInfo **ppCTInfo)
{
ICreateTypeLib2Impl *This = (ICreateTypeLib2Impl *)iface;
char *name;
TRACE("(%p,%s,%d,%p)\n", iface, debugstr_w(szName), tkind, ppCTInfo);
ctl2_encode_name(This, szName, &name);
if(ctl2_find_name(This, name) != -1)
return TYPE_E_NAMECONFLICT;
*ppCTInfo = (ICreateTypeInfo *)ICreateTypeInfo2_Constructor(This, szName, tkind);
if (!*ppCTInfo) return E_OUTOFMEMORY;