mirror of
https://github.com/reactos/reactos.git
synced 2025-05-21 10:05:35 +00:00
[ATL] Prohibit the use of AddRef/Release on objects inside CComPtr
This mimics what MS's CComPtr is doing: https://learn.microsoft.com/en-us/cpp/atl/reference/ccomptrbase-class?view=msvc-170#operator_ptr The reasoning behind this is that AddRef/Release is handled by the CComPtr, so anyone calling that is most likely not using the CComPtr correct.
This commit is contained in:
parent
544b734498
commit
a414c88dae
1 changed files with 9 additions and 2 deletions
|
@ -59,6 +59,13 @@ inline HRESULT AtlHresultFromLastError() throw()
|
||||||
return HRESULT_FROM_WIN32(dwError);
|
return HRESULT_FROM_WIN32(dwError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class _NoAddRefReleaseOnCComPtr : public T
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
virtual ULONG STDMETHODCALLTYPE AddRef() = 0;
|
||||||
|
virtual ULONG STDMETHODCALLTYPE Release() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class CComPtr
|
class CComPtr
|
||||||
|
@ -173,10 +180,10 @@ public:
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
T *operator -> ()
|
_NoAddRefReleaseOnCComPtr<T> *operator -> () const
|
||||||
{
|
{
|
||||||
ATLASSERT(p != NULL);
|
ATLASSERT(p != NULL);
|
||||||
return p;
|
return (_NoAddRefReleaseOnCComPtr<T> *)p;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue