Ref counting fixes.
This commit is contained in:
parent
dbfe39fe68
commit
bf9f8da333
|
@ -2,5 +2,6 @@ Makefile
|
|||
olefont.ok
|
||||
safearray.ok
|
||||
testlist.c
|
||||
typelib.ok
|
||||
vartest.ok
|
||||
vartype.ok
|
||||
|
|
|
@ -9,6 +9,7 @@ EXTRALIBS = -luuid
|
|||
CTESTS = \
|
||||
olefont.c \
|
||||
safearray.c \
|
||||
typelib.c \
|
||||
vartest.c \
|
||||
vartype.c
|
||||
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* ITypeLib and ITypeInfo test
|
||||
*
|
||||
* Copyright 2004 Jacek Caban
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
#include <wine/test.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "oleauto.h"
|
||||
|
||||
void ref_count_test(LPCWSTR type_lib)
|
||||
{
|
||||
ITypeLib *iface;
|
||||
ITypeInfo *iti1, *iti2;
|
||||
HRESULT hRes;
|
||||
int ref_count;
|
||||
|
||||
trace("Loading type library\n");
|
||||
hRes = LoadTypeLib(type_lib, &iface);
|
||||
ok(hRes == S_OK, "Could not load type library\n");
|
||||
if(hRes != S_OK)
|
||||
return;
|
||||
|
||||
hRes = ITypeLib_GetTypeInfo(iface, 1, &iti1);
|
||||
ok(hRes == S_OK, "ITypeLib_GetTypeInfo failed on index = 1\n");
|
||||
ok(ref_count=ITypeLib_Release(iface) > 0, "ITypeLib destroyed while ITypeInfo has back pointer\n");
|
||||
if(!ref_count)
|
||||
return;
|
||||
|
||||
hRes = ITypeLib_GetTypeInfo(iface, 1, &iti2);
|
||||
ok(hRes == S_OK, "ITypeLib_GetTypeInfo failed on index = 1\n");
|
||||
ok(iti1 == iti2, "ITypeLib_GetTypeInfo returned different pointers for same indexes\n");
|
||||
|
||||
ITypeLib_AddRef(iface);
|
||||
ITypeInfo_Release(iti2);
|
||||
ITypeInfo_Release(iti1);
|
||||
ok(ITypeLib_Release(iface) == 0, "ITypeLib should be destroyed here.\n");
|
||||
}
|
||||
|
||||
START_TEST(typelib)
|
||||
{
|
||||
static const WCHAR type_lib_olepro32[] = {'o','l','e','p','r','o','3','2','.','d','l','l',0};
|
||||
static const WCHAR type_lib_stdole32[] = {'s','t','d','o','l','e','3','2','.','t','l','b',0};
|
||||
|
||||
ref_count_test(type_lib_olepro32);
|
||||
ref_count_test(type_lib_stdole32);
|
||||
}
|
|
@ -2460,7 +2460,6 @@ static ITypeLib2* ITypeLib2_Constructor_MSFT(LPVOID pLib, DWORD dwTLBLength)
|
|||
{
|
||||
*ppTI = MSFT_DoTypeInfo(&cx, i, pTypeLibImpl);
|
||||
|
||||
ITypeInfo_AddRef((ITypeInfo*) *ppTI);
|
||||
ppTI = &((*ppTI)->next);
|
||||
(pTypeLibImpl->TypeInfoCount)++;
|
||||
}
|
||||
|
@ -4079,6 +4078,7 @@ static ULONG WINAPI ITypeInfo_fnAddRef( ITypeInfo2 *iface)
|
|||
ICOM_THIS( ITypeInfoImpl, iface);
|
||||
|
||||
++(This->ref);
|
||||
ITypeLib2_AddRef((ITypeLib2*)This->pTypeLib);
|
||||
|
||||
TRACE("(%p)->ref is %u\n",This, This->ref);
|
||||
return This->ref;
|
||||
|
@ -4086,7 +4086,7 @@ static ULONG WINAPI ITypeInfo_fnAddRef( ITypeInfo2 *iface)
|
|||
|
||||
/* ITypeInfo::Release
|
||||
*/
|
||||
static ULONG WINAPI ITypeInfo_fnRelease( ITypeInfo2 *iface)
|
||||
static ULONG WINAPI ITypeInfo_fnRelease(ITypeInfo2 *iface)
|
||||
{
|
||||
ICOM_THIS( ITypeInfoImpl, iface);
|
||||
|
||||
|
@ -4094,8 +4094,11 @@ static ULONG WINAPI ITypeInfo_fnRelease( ITypeInfo2 *iface)
|
|||
|
||||
TRACE("(%p)->(%u)\n",This, This->ref);
|
||||
|
||||
if (!This->ref)
|
||||
{
|
||||
if (This->ref) {
|
||||
/* We don't release ITypeLib when ref=0 becouse
|
||||
it means that funtion is called by ITypeLi2_Release */
|
||||
ITypeLib2_Release((ITypeLib2*)This->pTypeLib);
|
||||
} else {
|
||||
FIXME("destroy child objects\n");
|
||||
|
||||
TRACE("destroying ITypeInfo(%p)\n",This);
|
||||
|
|
Loading…
Reference in New Issue