From 51922ecd1184c13d37baab49f170e9d9e0a92516 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Thu, 12 May 2011 06:44:54 +0200 Subject: do not leak memory --- comphelper/source/misc/componentmodule.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'comphelper') diff --git a/comphelper/source/misc/componentmodule.cxx b/comphelper/source/misc/componentmodule.cxx index c42308c71508..4318acc149be 100644 --- a/comphelper/source/misc/componentmodule.cxx +++ b/comphelper/source/misc/componentmodule.cxx @@ -85,7 +85,7 @@ namespace comphelper //------------------------------------------------------------------------- OModule::OModule() :m_nClients( 0 ) - ,m_pImpl( new OModuleImpl ) + ,m_pImpl( 0 ) { } @@ -110,17 +110,24 @@ namespace comphelper //-------------------------------------------------------------------------- void OModule::onFirstClient() { + OSL_PRECOND( !m_pImpl, "called out of sequence" ); + if ( !m_pImpl ) + m_pImpl = new OModuleImpl; } //-------------------------------------------------------------------------- void OModule::onLastClient() { + OSL_PRECOND( m_pImpl, "called out of sequence" ); + delete m_pImpl; + m_pImpl = 0; } //-------------------------------------------------------------------------- void OModule::registerImplementation( const ComponentDescription& _rComp ) { ::osl::MutexGuard aGuard( m_aMutex ); + OSL_PRECOND( m_pImpl, "not initialized properly" ); if ( !m_pImpl ) throw RuntimeException(); -- cgit v1.2.3