mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 17:05:46 +00:00
[SHELL32]
- Fix assertion failure in 2nd stage by setting s_IsTerminated when an instance does not yet exist. - Rename CComCreatorSingleton to CComCreatorCentralInstance since it's not /technically/ a singleton svn path=/trunk/; revision=68215
This commit is contained in:
parent
f7bbd54974
commit
8d850ac341
4 changed files with 16 additions and 9 deletions
|
@ -79,7 +79,7 @@ class CDesktopFolder :
|
|||
virtual HRESULT WINAPI CopyItems(IShellFolder *pSFFrom, UINT cidl, LPCITEMIDLIST *apidl, BOOL bCopy);
|
||||
|
||||
DECLARE_REGISTRY_RESOURCEID(IDR_SHELLDESKTOP)
|
||||
DECLARE_SINGLETON_NOT_AGGREGATABLE(CDesktopFolder)
|
||||
DECLARE_CENTRAL_INSTANCE_NOT_AGGREGATABLE(CDesktopFolder)
|
||||
|
||||
DECLARE_PROTECT_FINAL_CONSTRUCT()
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ class CDrivesFolder :
|
|||
virtual HRESULT WINAPI GetCurFolder(LPITEMIDLIST * pidl);
|
||||
|
||||
DECLARE_REGISTRY_RESOURCEID(IDR_MYCOMPUTER)
|
||||
DECLARE_SINGLETON_NOT_AGGREGATABLE(CDrivesFolder)
|
||||
DECLARE_CENTRAL_INSTANCE_NOT_AGGREGATABLE(CDrivesFolder)
|
||||
|
||||
DECLARE_PROTECT_FINAL_CONSTRUCT()
|
||||
|
||||
|
|
|
@ -151,8 +151,8 @@ class CShell32Module : public CComModule
|
|||
public:
|
||||
void Term()
|
||||
{
|
||||
CComCreatorSingleton< ATL::CComObject< CDrivesFolder > >::Term();
|
||||
CComCreatorSingleton< ATL::CComObject< CDesktopFolder > >::Term();
|
||||
CComCreatorCentralInstance< ATL::CComObject< CDrivesFolder > >::Term();
|
||||
CComCreatorCentralInstance< ATL::CComObject< CDesktopFolder > >::Term();
|
||||
CComModule::Term();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -43,7 +43,7 @@ extern "C" {
|
|||
|
||||
#ifdef __cplusplus
|
||||
template <typename T>
|
||||
class CComCreatorSingleton
|
||||
class CComCreatorCentralInstance
|
||||
{
|
||||
private:
|
||||
static IUnknown *s_pInstance;
|
||||
|
@ -59,11 +59,18 @@ public:
|
|||
{
|
||||
PVOID pObj;
|
||||
HRESULT hr;
|
||||
s_IsTerminated = true;
|
||||
hr = ATL::CComCreator< T >::CreateInstance(NULL, IID_IUnknown, &pObj);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
s_IsTerminated = false;
|
||||
return hr;
|
||||
}
|
||||
if (InterlockedCompareExchangePointer((PVOID *)&s_pInstance, pObj, NULL))
|
||||
{
|
||||
static_cast<IUnknown *>(pObj)->Release();
|
||||
s_IsTerminated = false;
|
||||
}
|
||||
}
|
||||
return s_pInstance->QueryInterface(riid, ppv);
|
||||
}
|
||||
|
@ -87,14 +94,14 @@ public:
|
|||
};
|
||||
|
||||
template <typename T>
|
||||
IUnknown *CComCreatorSingleton<T>::s_pInstance = NULL;
|
||||
IUnknown *CComCreatorCentralInstance<T>::s_pInstance = NULL;
|
||||
|
||||
template <typename T>
|
||||
bool CComCreatorSingleton<T>::s_IsTerminated = false;
|
||||
bool CComCreatorCentralInstance<T>::s_IsTerminated = false;
|
||||
|
||||
#define DECLARE_SINGLETON_NOT_AGGREGATABLE(x) \
|
||||
#define DECLARE_CENTRAL_INSTANCE_NOT_AGGREGATABLE(x) \
|
||||
public: \
|
||||
typedef CComCreatorSingleton< ATL::CComObject<x> > _CreatorClass;
|
||||
typedef CComCreatorCentralInstance< ATL::CComObject<x> > _CreatorClass;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Loading…
Reference in a new issue