Add small wxOleInitializer RAII helper.
Wrap wxOleInitialize()/wxOleUninitialize() in a helper class ensuring that we never forget to call the latter. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77507 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		| @@ -354,4 +354,30 @@ inline void wxOleUninitialize() { } | |||||||
|  |  | ||||||
| #endif // wxUSE_OLE/!wxUSE_OLE | #endif // wxUSE_OLE/!wxUSE_OLE | ||||||
|  |  | ||||||
|  | // RAII class initializing OLE in its ctor and undoing it in its dtor. | ||||||
|  | class wxOleInitializer | ||||||
|  | { | ||||||
|  | public: | ||||||
|  |     wxOleInitializer() | ||||||
|  |         : m_ok(wxOleInitialize()) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     bool IsOk() const | ||||||
|  |     { | ||||||
|  |         return m_ok; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     ~wxOleInitializer() | ||||||
|  |     { | ||||||
|  |         if ( m_ok ) | ||||||
|  |             wxOleUninitialize(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | private: | ||||||
|  |     const bool m_ok; | ||||||
|  |  | ||||||
|  |     wxDECLARE_NO_COPY_CLASS(wxOleInitializer); | ||||||
|  | }; | ||||||
|  |  | ||||||
| #endif  //_WX_OLEUTILS_H | #endif  //_WX_OLEUTILS_H | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user