Kaydet (Commit) d5b971f9 authored tarafından Noel Grandin's avatar Noel Grandin

use rtl::Reference in forms

instead of manual reference counting

Change-Id: I5bad5b7b83049f5c018a1f2d5bbc37f03727c3ce
Reviewed-on: https://gerrit.libreoffice.org/43497Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst e149c4f3
...@@ -180,15 +180,12 @@ namespace frm ...@@ -180,15 +180,12 @@ namespace frm
// create the peer // create the peer
Reference< XControlModel > xModel( getModel() ); Reference< XControlModel > xModel( getModel() );
ORichTextPeer* pPeer = ORichTextPeer::Create( xModel, pParentWin, getWinBits( xModel ) ); rtl::Reference<ORichTextPeer> pPeer = ORichTextPeer::Create( xModel, pParentWin, getWinBits( xModel ) );
DBG_ASSERT( pPeer, "ORichTextControl::createPeer: invalid peer returned!" ); DBG_ASSERT( pPeer, "ORichTextControl::createPeer: invalid peer returned!" );
if ( pPeer ) if ( pPeer )
{ {
// by definition, the returned component is acquired once
pPeer->release();
// announce the peer to the base class // announce the peer to the base class
setPeer( pPeer ); setPeer( pPeer.get() );
// initialize ourself (and thus the peer) with the model properties // initialize ourself (and thus the peer) with the model properties
updateFromModel(); updateFromModel();
...@@ -254,7 +251,7 @@ namespace frm ...@@ -254,7 +251,7 @@ namespace frm
} }
// ORichTextPeer // ORichTextPeer
ORichTextPeer* ORichTextPeer::Create( const Reference< XControlModel >& _rxModel, vcl::Window* _pParentWindow, WinBits _nStyle ) rtl::Reference<ORichTextPeer> ORichTextPeer::Create( const Reference< XControlModel >& _rxModel, vcl::Window* _pParentWindow, WinBits _nStyle )
{ {
DBG_TESTSOLARMUTEX(); DBG_TESTSOLARMUTEX();
...@@ -265,14 +262,13 @@ namespace frm ...@@ -265,14 +262,13 @@ namespace frm
return nullptr; return nullptr;
// the peer itself // the peer itself
ORichTextPeer* pPeer = new ORichTextPeer; rtl::Reference<ORichTextPeer> pPeer(new ORichTextPeer);
pPeer->acquire(); // by definition, the returned object is acquired once
// the VCL control for the peer // the VCL control for the peer
VclPtrInstance<RichTextControl> pRichTextControl( pEngine, _pParentWindow, _nStyle, nullptr, pPeer ); VclPtrInstance<RichTextControl> pRichTextControl( pEngine, _pParentWindow, _nStyle, nullptr, pPeer.get() );
// some knittings // some knittings
pRichTextControl->SetComponentInterface( pPeer ); pRichTextControl->SetComponentInterface( pPeer.get() );
// outta here // outta here
return pPeer; return pPeer;
......
...@@ -86,10 +86,8 @@ namespace frm ...@@ -86,10 +86,8 @@ namespace frm
public: public:
/** factory method /** factory method
@return
a new ORichTextPeer instance, which has been acquired once!
*/ */
static ORichTextPeer* Create( static rtl::Reference<ORichTextPeer> Create(
const css::uno::Reference< css::awt::XControlModel >& _rxModel, const css::uno::Reference< css::awt::XControlModel >& _rxModel,
vcl::Window* _pParentWindow, vcl::Window* _pParentWindow,
WinBits _nStyle WinBits _nStyle
......
...@@ -131,13 +131,11 @@ namespace frm ...@@ -131,13 +131,11 @@ namespace frm
} }
// create the peer // create the peer
ONavigationBarPeer* pPeer = ONavigationBarPeer::Create( m_xContext, pParentWin, getModel() ); rtl::Reference<ONavigationBarPeer> pPeer = ONavigationBarPeer::Create( m_xContext, pParentWin, getModel() );
assert(pPeer && "ONavigationBarControl::createPeer: invalid peer returned!"); assert(pPeer && "ONavigationBarControl::createPeer: invalid peer returned!");
// by definition, the returned component is acquired once
pPeer->release();
// announce the peer to the base class // announce the peer to the base class
setPeer( pPeer ); setPeer( pPeer.get() );
// initialize ourself (and thus the peer) with the model properties // initialize ourself (and thus the peer) with the model properties
updateFromModel(); updateFromModel();
...@@ -198,14 +196,13 @@ namespace frm ...@@ -198,14 +196,13 @@ namespace frm
// ONavigationBarPeer // ONavigationBarPeer
ONavigationBarPeer* ONavigationBarPeer::Create( const Reference< XComponentContext >& _rxORB, rtl::Reference<ONavigationBarPeer> ONavigationBarPeer::Create( const Reference< XComponentContext >& _rxORB,
vcl::Window* _pParentWindow, const Reference< XControlModel >& _rxModel ) vcl::Window* _pParentWindow, const Reference< XControlModel >& _rxModel )
{ {
DBG_TESTSOLARMUTEX(); DBG_TESTSOLARMUTEX();
// the peer itself // the peer itself
ONavigationBarPeer* pPeer = new ONavigationBarPeer( _rxORB ); rtl::Reference<ONavigationBarPeer> pPeer(new ONavigationBarPeer( _rxORB ));
pPeer->acquire(); // by definition, the returned object is acquired once
// the VCL control for the peer // the VCL control for the peer
Reference< XModel > xContextDocument( getXModel( _rxModel ) ); Reference< XModel > xContextDocument( getXModel( _rxModel ) );
...@@ -220,8 +217,8 @@ namespace frm ...@@ -220,8 +217,8 @@ namespace frm
); );
// some knittings // some knittings
pNavBar->setDispatcher( pPeer ); pNavBar->setDispatcher( pPeer.get() );
pNavBar->SetComponentInterface( pPeer ); pNavBar->SetComponentInterface( pPeer.get() );
// we want a faster repeating rate for the slots in this // we want a faster repeating rate for the slots in this
// toolbox // toolbox
......
...@@ -78,10 +78,8 @@ namespace frm ...@@ -78,10 +78,8 @@ namespace frm
{ {
public: public:
/** factory method /** factory method
@return
a new ONavigationBarPeer instance, which has been acquired once!
*/ */
static ONavigationBarPeer* Create( static rtl::Reference<ONavigationBarPeer> Create(
const css::uno::Reference< css::uno::XComponentContext >& _rxORB, const css::uno::Reference< css::uno::XComponentContext >& _rxORB,
vcl::Window* _pParentWindow, vcl::Window* _pParentWindow,
const css::uno::Reference< css::awt::XControlModel >& _rxModel const css::uno::Reference< css::awt::XControlModel >& _rxModel
......
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