[Libreoffice-commits] core.git: sfx2/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Aug 13 07:20:06 UTC 2020


 sfx2/source/view/ipclient.cxx |   23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

New commits:
commit 0e8681d4a13719e87344ab24f83bd746a51ce8a1
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Aug 12 11:52:31 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Aug 13 09:19:23 2020 +0200

    simplify memory management in SfxInPlaceClient_Impl
    
    no need for the impl class to hold a reference to itself
    
    Change-Id: I4ee3fc46df93d9ba087590af33d78834a454161f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100619
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx
index ad718537b76c..c394535ea2a0 100644
--- a/sfx2/source/view/ipclient.cxx
+++ b/sfx2/source/view/ipclient.cxx
@@ -113,7 +113,6 @@ public:
     bool                            m_bResizeNoScale;
 
     uno::Reference < embed::XEmbeddedObject > m_xObject;
-    uno::Reference < embed::XEmbeddedClient > m_xClient;
 
 
     SfxInPlaceClient_Impl()
@@ -625,7 +624,6 @@ SfxInPlaceClient::SfxInPlaceClient( SfxViewShell* pViewShell, vcl::Window *pDraw
     m_xImp->m_pClient = this;
     m_xImp->m_nAspect = nAspect;
     m_xImp->m_aScaleWidth = m_xImp->m_aScaleHeight = Fraction(1,1);
-    m_xImp->m_xClient = static_cast< embed::XEmbeddedClient* >( m_xImp.get() );
     pViewShell->NewIPClient_Impl(this);
     m_xImp->m_aTimer.SetDebugName( "sfx::SfxInPlaceClient m_xImpl::m_aTimer" );
     m_xImp->m_aTimer.SetTimeout( SFX_CLIENTACTIVATE_TIMEOUT );
@@ -644,7 +642,7 @@ SfxInPlaceClient::~SfxInPlaceClient()
     m_xImp->m_pClient = nullptr;
 
     // the next call will destroy m_xImp if no other reference to it exists
-    m_xImp->m_xClient.clear();
+    m_xImp.clear();
 
     // TODO/LATER:
     // the class is not intended to be used in multithreaded environment;
@@ -692,13 +690,13 @@ void SfxInPlaceClient::SetObject( const uno::Reference < embed::XEmbeddedObject
 {
     if ( m_xImp->m_xObject.is() && rObject != m_xImp->m_xObject )
     {
-        DBG_ASSERT( GetObject()->getClientSite() == m_xImp->m_xClient, "Wrong ClientSite!" );
-        if ( GetObject()->getClientSite() == m_xImp->m_xClient )
+        DBG_ASSERT( GetObject()->getClientSite() == static_cast<cppu::OWeakObject*>(m_xImp.get()), "Wrong ClientSite!" );
+        if ( GetObject()->getClientSite() == static_cast<cppu::OWeakObject*>(m_xImp.get()) )
         {
             if ( GetObject()->getCurrentState() != embed::EmbedStates::LOADED )
                 SetObjectState( embed::EmbedStates::RUNNING );
-            m_xImp->m_xObject->removeEventListener( uno::Reference < document::XEventListener >( m_xImp->m_xClient, uno::UNO_QUERY ) );
-            m_xImp->m_xObject->removeStateChangeListener( uno::Reference < embed::XStateChangeListener >( m_xImp->m_xClient, uno::UNO_QUERY ) );
+            m_xImp->m_xObject->removeEventListener( m_xImp.get() );
+            m_xImp->m_xObject->removeStateChangeListener( m_xImp.get() );
             try
             {
                 m_xImp->m_xObject->setClientSite( nullptr );
@@ -720,12 +718,12 @@ void SfxInPlaceClient::SetObject( const uno::Reference < embed::XEmbeddedObject
     {
         // as soon as an object was connected to a client it has to be checked whether the object wants
         // to be activated
-        rObject->addStateChangeListener( uno::Reference < embed::XStateChangeListener >( m_xImp->m_xClient, uno::UNO_QUERY ) );
-        rObject->addEventListener( uno::Reference < document::XEventListener >( m_xImp->m_xClient, uno::UNO_QUERY ) );
+        rObject->addStateChangeListener( m_xImp.get() );
+        rObject->addEventListener( m_xImp.get() );
 
         try
         {
-            rObject->setClientSite( m_xImp->m_xClient );
+            rObject->setClientSite( m_xImp.get() );
         }
         catch( uno::Exception& )
         {
@@ -949,7 +947,7 @@ ErrCode SfxInPlaceClient::DoVerb( long nVerb )
                 m_pViewSh->GetViewFrame()->GetFrame().LockResize_Impl(true);
                 try
                 {
-                    m_xImp->m_xObject->setClientSite( m_xImp->m_xClient );
+                    m_xImp->m_xObject->setClientSite( m_xImp.get() );
 
                     m_xImp->m_xObject->doVerb( nVerb );
                 }
@@ -1016,8 +1014,7 @@ ErrCode SfxInPlaceClient::DoVerb( long nVerb )
 void SfxInPlaceClient::VisAreaChanged()
 {
     uno::Reference < embed::XInplaceObject > xObj( m_xImp->m_xObject, uno::UNO_QUERY );
-    uno::Reference < embed::XInplaceClient > xClient( m_xImp->m_xClient, uno::UNO_QUERY );
-    if ( xObj.is() && xClient.is() )
+    if ( xObj.is() )
         m_xImp->SizeHasChanged();
 }
 


More information about the Libreoffice-commits mailing list