use rtl::Reference in FormControlContainer

instead of manual acquire/release

Change-Id: Ie0fed7db217adea68aaa09cf9de699d488bf84dd
This commit is contained in:
Noel Grandin 2017-01-19 13:58:56 +02:00
parent 46a0ce8032
commit 7d7a5666ae
2 changed files with 7 additions and 9 deletions

View file

@ -35,7 +35,6 @@ namespace bib
FormControlContainer::FormControlContainer( )
:OLoadListener( m_aMutex )
,m_pFormAdapter( nullptr )
{
}
@ -52,9 +51,8 @@ namespace bib
SAL_WARN_IF( !isFormConnected(), "extensions.biblio", "FormControlContainer::connectForm: not connected!" );
if ( isFormConnected() )
{
m_pFormAdapter->dispose();
m_pFormAdapter->release();
m_pFormAdapter = nullptr;
m_xFormAdapter->dispose();
m_xFormAdapter.clear();
}
}
@ -65,9 +63,8 @@ namespace bib
SAL_WARN_IF( !_rxForm.is(), "extensions.biblio", "FormControlContainer::connectForm: invalid form!" );
if ( !isFormConnected() && _rxForm.is() )
{
m_pFormAdapter = new OLoadListenerAdapter( _rxForm );
m_pFormAdapter->acquire();
m_pFormAdapter->Init( this );
m_xFormAdapter = new OLoadListenerAdapter( _rxForm );
m_xFormAdapter->Init( this );
implSetDesignMode( !m_xForm.is() || !m_xForm->isLoaded() );
}

View file

@ -23,6 +23,7 @@
#include <cppuhelper/basemutex.hxx>
#include "loadlisteneradapter.hxx"
#include <com/sun/star/awt/XControlContainer.hpp>
#include <rtl/ref.hxx>
namespace bib
@ -33,7 +34,7 @@ namespace bib
,public ::bib::OLoadListener
{
private:
OLoadListenerAdapter* m_pFormAdapter;
rtl::Reference<OLoadListenerAdapter> m_xFormAdapter;
css::uno::Reference< css::form::XLoadable > m_xForm;
private:
void implSetDesignMode( bool _bDesign );
@ -42,7 +43,7 @@ namespace bib
FormControlContainer( );
virtual ~FormControlContainer( ) override;
bool isFormConnected() const { return nullptr != m_pFormAdapter; }
bool isFormConnected() const { return m_xFormAdapter.is(); }
void connectForm( const css::uno::Reference< css::form::XLoadable >& _rxForm );
void disconnectForm();