mirror of
https://github.com/reactos/reactos.git
synced 2025-05-31 06:58:10 +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
|
||||
|
||||
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)
|
||||
{
|
||||
T *raw = cptr.Detach();
|
||||
int nrc = raw->Release();
|
||||
int nrc = r = raw->Release();
|
||||
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);
|
||||
if (forceRelease)
|
||||
{
|
||||
while (nrc > 0)
|
||||
{
|
||||
nrc = raw->Release();
|
||||
}
|
||||
}
|
||||
nrc = raw->Release();
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
#define ReleaseCComPtrExpectZero(...) ReleaseCComPtrExpectZeroHelper(__FILE__, __LINE__, __VA_ARGS__)
|
||||
|
||||
template<class T, class R>
|
||||
HRESULT inline ShellDebugObjectCreator(REFIID riid, R ** ppv)
|
||||
|
|
Loading…
Reference in a new issue