mirror of
https://github.com/reactos/reactos.git
synced 2025-06-05 09:20:30 +00:00
[SDK] ReleaseCComPtrExpectZero should print the relevant file:line (#6772)
ReleaseCComPtrExpectZero currently always prints the same line from shellutils.h in the warning which is not very useful. A macro is required for __FILE__ to be correct.
This commit is contained in:
parent
515f998f0d
commit
ef80b3dde4
1 changed files with 8 additions and 10 deletions
|
@ -227,25 +227,23 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void ReleaseCComPtrExpectZero(CComPtr<T>& cptr, BOOL forceRelease = FALSE)
|
ULONG ReleaseCComPtrExpectZeroHelper(const char *file, UINT line, CComPtr<T>& cptr, BOOL forceRelease = FALSE)
|
||||||
{
|
{
|
||||||
|
ULONG r = 0;
|
||||||
if (cptr.p != NULL)
|
if (cptr.p != NULL)
|
||||||
{
|
{
|
||||||
T *raw = cptr.Detach();
|
T *raw = cptr.Detach();
|
||||||
int nrc = raw->Release();
|
int nrc = r = raw->Release();
|
||||||
if (nrc > 0)
|
if (nrc > 0)
|
||||||
|
Win32DbgPrint(file, line, "WARNING: Unexpected RefCount > 0 (%d)\n", nrc);
|
||||||
|
while (nrc > 0 && forceRelease)
|
||||||
{
|
{
|
||||||
DbgPrint("WARNING: Unexpected RefCount > 0 (%d)!\n", nrc);
|
nrc = raw->Release();
|
||||||
if (forceRelease)
|
|
||||||
{
|
|
||||||
while (nrc > 0)
|
|
||||||
{
|
|
||||||
nrc = raw->Release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
#define ReleaseCComPtrExpectZero(...) ReleaseCComPtrExpectZeroHelper(__FILE__, __LINE__, __VA_ARGS__)
|
||||||
|
|
||||||
template<class T, class R>
|
template<class T, class R>
|
||||||
HRESULT inline ShellDebugObjectCreator(REFIID riid, R ** ppv)
|
HRESULT inline ShellDebugObjectCreator(REFIID riid, R ** ppv)
|
||||||
|
|
Loading…
Reference in a new issue