Changeset 96540 in vbox
- Timestamp:
- Aug 28, 2022 4:40:20 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/microatl.h
r96407 r96540 185 185 }; 186 186 187 template <class TLock> class CComCritSectLock 188 { 189 public: 190 CComCritSectLock(CComCriticalSection &cs, bool fInitialLock = true) : 191 m_cs(cs), 192 m_fLocked(false) 193 { 194 if (fInitialLock) 195 { 196 HRESULT hrc = Lock(); 197 if (FAILED(hrc)) 198 throw hrc; 199 } 200 } 201 202 ~CComCritSectLock() throw() 187 template<class TLock> 188 class CComCritSectLockManual 189 { 190 public: 191 CComCritSectLockManual(CComCriticalSection &cs) 192 : m_cs(cs) 193 , m_fLocked(false) 194 { 195 } 196 197 ~CComCritSectLockManual() throw() 203 198 { 204 199 if (m_fLocked) … … 228 223 bool m_fLocked; 229 224 225 CComCritSectLockManual(const CComCritSectLockManual&) throw(); // Do not call. 226 CComCritSectLockManual &operator=(const CComCritSectLockManual &) throw(); // Do not call. 227 }; 228 229 230 #ifdef RT_EXCEPTIONS_ENABLED 231 /** This is called CComCritSecLock in real ATL... */ 232 template<class TLock> 233 class CComCritSectLock : public CComCritSectLockManual<TLock> 234 { 235 public: 236 CComCritSectLock(CComCriticalSection &cs, bool fInitialLock = true) 237 : CComCritSectLockManual(cs) 238 { 239 if (fInitialLock) 240 { 241 HRESULT hrc = Lock(); 242 if (FAILED(hrc)) 243 throw hrc; 244 } 245 } 246 247 private: 230 248 CComCritSectLock(const CComCritSectLock&) throw(); // Do not call. 231 249 CComCritSectLock &operator=(const CComCritSectLock &) throw(); // Do not call. 232 250 }; 251 #endif 233 252 234 253 class CComFakeCriticalSection … … 420 439 pNew->pfn = pfn; 421 440 pNew->pv = pv; 422 CComCritSectLock <CComCriticalSection> lock(m_csStaticDataInitAndTypeInfo, false);441 CComCritSectLockManual<CComCriticalSection> lock(m_csStaticDataInitAndTypeInfo); 423 442 HRESULT hrc = lock.Lock(); 424 443 if (SUCCEEDED(hrc)) … … 576 595 if (!pEntry->pCF) 577 596 { 578 CComCritSectLock <CComCriticalSection> lock(_AtlComModule.m_csObjMap, false);597 CComCritSectLockManual<CComCriticalSection> lock(_AtlComModule.m_csObjMap); 579 598 hrc = lock.Lock(); 580 599 if (FAILED(hrc)) … … 848 867 if (m_pTInfo) 849 868 return S_OK; 850 CComCritSectLock<CComCriticalSection> lock(_pAtlModule->m_csStaticDataInitAndTypeInfo, false); 869 870 CComCritSectLockManual<CComCriticalSection> lock(_pAtlModule->m_csStaticDataInitAndTypeInfo); 851 871 HRESULT hrc = lock.Lock(); 852 ITypeLib *pTypeLib = NULL;853 Assert(*m_pLibID != GUID_NULL);854 hrc = LoadRegTypeLib(*m_pLibID, m_iMajor, m_iMinor, lcid, &pTypeLib);855 872 if (SUCCEEDED(hrc)) 856 873 { 857 ITypeInfo *pTypeInfo; 858 hrc = pTypeLib->GetTypeInfoOfGuid(*m_pGUID, &pTypeInfo); 874 ITypeLib *pTypeLib = NULL; 875 Assert(*m_pLibID != GUID_NULL); 876 hrc = LoadRegTypeLib(*m_pLibID, m_iMajor, m_iMinor, lcid, &pTypeLib); 859 877 if (SUCCEEDED(hrc)) 860 878 { 861 ITypeInfo2 *pTypeInfo2; 862 if (SUCCEEDED(pTypeInfo->QueryInterface(__uuidof(ITypeInfo2), (void **)&pTypeInfo2))) 879 ITypeInfo *pTypeInfo; 880 hrc = pTypeLib->GetTypeInfoOfGuid(*m_pGUID, &pTypeInfo); 881 if (SUCCEEDED(hrc)) 863 882 { 864 pTypeInfo->Release(); 865 pTypeInfo = pTypeInfo2; 883 ITypeInfo2 *pTypeInfo2; 884 if (SUCCEEDED(pTypeInfo->QueryInterface(__uuidof(ITypeInfo2), (void **)&pTypeInfo2))) 885 { 886 pTypeInfo->Release(); 887 pTypeInfo = pTypeInfo2; 888 } 889 m_pTInfo = pTypeInfo; 890 _pAtlModule->AddTermFunc(Cleanup, (void *)this); 866 891 } 867 m_pTInfo = pTypeInfo; 868 _pAtlModule->AddTermFunc(Cleanup, (void *)this); 892 pTypeLib->Release(); 869 893 } 870 pTypeLib->Release();871 894 } 872 895 return hrc;
Note:
See TracChangeset
for help on using the changeset viewer.