Kaydet (Commit) 13ca560d authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Fix memory leak

Change-Id: I82ce013a42ac1cd9bb4f3842e9fba8fbc6056b3c
üst 55a754cc
...@@ -30,8 +30,6 @@ ...@@ -30,8 +30,6 @@
#include <com/sun/star/embed/NoVisualAreaSizeException.hpp> #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
#include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/DisposedException.hpp>
#include <cppuhelper/interfacecontainer.h>
#include <dummyobject.hxx> #include <dummyobject.hxx>
...@@ -594,7 +592,7 @@ void SAL_CALL ODummyEmbeddedObject::addStateChangeListener( const uno::Reference ...@@ -594,7 +592,7 @@ void SAL_CALL ODummyEmbeddedObject::addStateChangeListener( const uno::Reference
return; return;
if ( !m_pInterfaceContainer ) if ( !m_pInterfaceContainer )
m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex ); m_pInterfaceContainer.reset(new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex ));
m_pInterfaceContainer->addInterface( cppu::UnoType<embed::XStateChangeListener>::get(), m_pInterfaceContainer->addInterface( cppu::UnoType<embed::XStateChangeListener>::get(),
xListener ); xListener );
...@@ -676,7 +674,7 @@ void SAL_CALL ODummyEmbeddedObject::addCloseListener( const uno::Reference< util ...@@ -676,7 +674,7 @@ void SAL_CALL ODummyEmbeddedObject::addCloseListener( const uno::Reference< util
return; return;
if ( !m_pInterfaceContainer ) if ( !m_pInterfaceContainer )
m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex ); m_pInterfaceContainer.reset(new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex ));
m_pInterfaceContainer->addInterface( cppu::UnoType<util::XCloseListener>::get(), xListener ); m_pInterfaceContainer->addInterface( cppu::UnoType<util::XCloseListener>::get(), xListener );
} }
...@@ -700,7 +698,7 @@ void SAL_CALL ODummyEmbeddedObject::addEventListener( const uno::Reference< docu ...@@ -700,7 +698,7 @@ void SAL_CALL ODummyEmbeddedObject::addEventListener( const uno::Reference< docu
return; return;
if ( !m_pInterfaceContainer ) if ( !m_pInterfaceContainer )
m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex ); m_pInterfaceContainer.reset(new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex ));
m_pInterfaceContainer->addInterface( cppu::UnoType<document::XEventListener>::get(), xListener ); m_pInterfaceContainer->addInterface( cppu::UnoType<document::XEventListener>::get(), xListener );
} }
......
...@@ -20,12 +20,17 @@ ...@@ -20,12 +20,17 @@
#ifndef INCLUDED_EMBEDDEDOBJ_SOURCE_INC_DUMMYOBJECT_HXX #ifndef INCLUDED_EMBEDDEDOBJ_SOURCE_INC_DUMMYOBJECT_HXX
#define INCLUDED_EMBEDDEDOBJ_SOURCE_INC_DUMMYOBJECT_HXX #define INCLUDED_EMBEDDEDOBJ_SOURCE_INC_DUMMYOBJECT_HXX
#include <sal/config.h>
#include <memory>
#include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/embed/XEmbeddedObject.hpp> #include <com/sun/star/embed/XEmbeddedObject.hpp>
#include <com/sun/star/embed/XEmbedPersist.hpp> #include <com/sun/star/embed/XEmbedPersist.hpp>
#include <cppuhelper/implbase.hxx> #include <cppuhelper/implbase.hxx>
#include <cppuhelper/interfacecontainer.hxx>
namespace com { namespace sun { namespace star { namespace com { namespace sun { namespace star {
namespace embed { namespace embed {
...@@ -49,7 +54,8 @@ class ODummyEmbeddedObject : public ::cppu::WeakImplHelper ...@@ -49,7 +54,8 @@ class ODummyEmbeddedObject : public ::cppu::WeakImplHelper
, css::embed::XEmbedPersist > , css::embed::XEmbedPersist >
{ {
::osl::Mutex m_aMutex; ::osl::Mutex m_aMutex;
::cppu::OMultiTypeInterfaceContainerHelper* m_pInterfaceContainer; std::unique_ptr<cppu::OMultiTypeInterfaceContainerHelper>
m_pInterfaceContainer;
bool m_bDisposed; bool m_bDisposed;
OUString m_aEntryName; OUString m_aEntryName;
...@@ -75,8 +81,7 @@ protected: ...@@ -75,8 +81,7 @@ protected:
public: public:
ODummyEmbeddedObject() ODummyEmbeddedObject()
: m_pInterfaceContainer( nullptr ) : m_bDisposed( false )
, m_bDisposed( false )
, m_nObjectState( -1 ) , m_nObjectState( -1 )
, m_nCachedAspect( 0 ) , m_nCachedAspect( 0 )
, m_bHasCachedSize( false ) , m_bHasCachedSize( false )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment