Changeset 0a4df15f49de…
Parent ffcbae25f9a1…
by
Changes to 3 files · Browse files at 0a4df15f49de Showing diff from parent ffcbae25f9a1 Diff from another changeset...
@@ -42,6 +42,8 @@
STDMETHODIMP CShellExt::IsMemberOf(LPCWSTR pwszPath, DWORD /* dwAttrib */)
{
+ ThgCriticalSection cs(GetCriticalSection());
+
std::string cval;
if (GetRegistryConfig("EnableOverlays", cval) != 0 && cval == "0")
return S_FALSE;
|
|
@@ -21,6 +21,9 @@
HMENU hSubMenu = 0;
+CRITICAL_SECTION g_critical_section;
+
+
typedef struct
{
HKEY hRootKey;
@@ -36,14 +39,20 @@int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
TDEBUG_TRACE("DllMain");
-
+
if (dwReason == DLL_PROCESS_ATTACH)
{
+ TDEBUG_TRACE("DllMain: DLL_PROCESS_ATTACH");
g_hmodThisDll = hInstance;
+ ::InitializeCriticalSection(&g_critical_section);
_LoadResources();
}
else if (dwReason == DLL_PROCESS_DETACH)
+ {
+ TDEBUG_TRACE("DllMain: DLL_PROCESS_ATTACH");
+ ::DeleteCriticalSection(&g_critical_section);
_UnloadResources();
+ }
return 1;
}
@@ -99,8 +108,15 @@ DestroyMenu(hSubMenu);
}
+
+LPCRITICAL_SECTION CDllRegSxClassFactory::GetCriticalSection()
+{
+ return &g_critical_section;
+}
+
CDllRegSxClassFactory::CDllRegSxClassFactory(TortoiseOLEClass classToMake)
{
+ ThgCriticalSection cs(GetCriticalSection());
m_cRef = 0L;
g_cRefThisDll++;
myclassToMake = classToMake;
@@ -108,6 +124,7 @@
CDllRegSxClassFactory::~CDllRegSxClassFactory()
{
+ ThgCriticalSection cs(GetCriticalSection());
g_cRefThisDll--;
}
@@ -130,12 +147,14 @@STDMETHODIMP_(ULONG)
CDllRegSxClassFactory::AddRef()
{
+ ThgCriticalSection cs(GetCriticalSection());
return ++m_cRef;
}
STDMETHODIMP_(ULONG)
CDllRegSxClassFactory::Release()
{
+ ThgCriticalSection cs(GetCriticalSection());
if (--m_cRef)
return m_cRef;
@@ -167,6 +186,8 @@CShellExt::CShellExt(TortoiseOLEClass tortoiseClass)
: m_ppszFileUserClickedOn(0)
{
+ ThgCriticalSection cs(GetCriticalSection());
+
myTortoiseClass = tortoiseClass;
m_cRef = 0L;
m_pDataObj = NULL;
@@ -176,12 +197,19 @@
CShellExt::~CShellExt()
{
+ ThgCriticalSection cs(GetCriticalSection());
+
if (m_pDataObj)
m_pDataObj->Release();
g_cRefThisDll--;
}
+LPCRITICAL_SECTION CShellExt::GetCriticalSection()
+{
+ return &g_critical_section;
+}
+
STDMETHODIMP
CShellExt::QueryInterface(REFIID riid, LPVOID FAR *ppv)
{
@@ -228,12 +256,15 @@STDMETHODIMP_(ULONG)
CShellExt::AddRef()
{
+ ThgCriticalSection cs(GetCriticalSection());
return ++m_cRef;
}
STDMETHODIMP_(ULONG)
CShellExt::Release()
{
+ ThgCriticalSection cs(GetCriticalSection());
+
if(--m_cRef)
return m_cRef;
|
@@ -29,6 +29,8 @@ ~CDllRegSxClassFactory();
public:
+ static LPCRITICAL_SECTION GetCriticalSection();
+
STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
@@ -60,6 +62,8 @@ void CShellExt::DoHgtk(const std::string &);
public:
+ static LPCRITICAL_SECTION GetCriticalSection();
+
CShellExt(TortoiseOLEClass);
~CShellExt();
@@ -86,4 +90,22 @@
typedef CShellExt *LPCSHELLEXT;
+
+class ThgCriticalSection
+{
+ LPCRITICAL_SECTION cs_;
+
+public:
+ ThgCriticalSection(LPCRITICAL_SECTION cs): cs_(cs)
+ {
+ ::EnterCriticalSection(cs_);
+ }
+
+ ~ThgCriticalSection()
+ {
+ ::LeaveCriticalSection(cs_);
+ }
+};
+
+
#endif // _SHELL_EXT_H_
|
Loading...