[Libreoffice-commits] core.git: UnoControls/inc UnoControls/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Oct 31 06:31:06 UTC 2018


 UnoControls/inc/basecontainercontrol.hxx         |    2 -
 UnoControls/inc/basecontrol.hxx                  |    2 -
 UnoControls/source/base/basecontainercontrol.cxx |   22 +++++++-----------
 UnoControls/source/base/basecontrol.cxx          |   27 ++++++++++-------------
 UnoControls/source/controls/framecontrol.cxx     |   16 ++++++-------
 UnoControls/source/controls/statusindicator.cxx  |   20 ++++++-----------
 UnoControls/source/inc/framecontrol.hxx          |    2 -
 UnoControls/source/inc/statusindicator.hxx       |    2 -
 8 files changed, 41 insertions(+), 52 deletions(-)

New commits:
commit b3c449b74f64cad8b3c0403acbe283c9a588b690
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Oct 29 11:18:29 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Oct 31 07:30:39 2018 +0100

    loplugin:useuniqueptr in impl_getWindowDescriptor
    
    return by value, the usual C++ optimisations will make this efficient
    
    Change-Id: I7f9634b9663605504c69e0381a6ebc9c76061048
    Reviewed-on: https://gerrit.libreoffice.org/62645
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/UnoControls/inc/basecontainercontrol.hxx b/UnoControls/inc/basecontainercontrol.hxx
index d0dc2e3371f5..d297e417b9ce 100644
--- a/UnoControls/inc/basecontainercontrol.hxx
+++ b/UnoControls/inc/basecontainercontrol.hxx
@@ -139,7 +139,7 @@ public:
 protected:
     using OComponentHelper::disposing;
 
-    virtual css::awt::WindowDescriptor* impl_getWindowDescriptor(
+    virtual css::awt::WindowDescriptor impl_getWindowDescriptor(
         const css::uno::Reference< css::awt::XWindowPeer >& xParentPeer
     ) override;
 
diff --git a/UnoControls/inc/basecontrol.hxx b/UnoControls/inc/basecontrol.hxx
index b3451ab91734..e10a7ce8ead7 100644
--- a/UnoControls/inc/basecontrol.hxx
+++ b/UnoControls/inc/basecontrol.hxx
@@ -349,7 +349,7 @@ protected:
 
     sal_Int32 impl_getHeight() const { return m_nHeight;}
 
-    virtual css::awt::WindowDescriptor* impl_getWindowDescriptor(
+    virtual css::awt::WindowDescriptor impl_getWindowDescriptor(
         const css::uno::Reference< css::awt::XWindowPeer >& xParentPeer
     );
 
diff --git a/UnoControls/source/base/basecontainercontrol.cxx b/UnoControls/source/base/basecontainercontrol.cxx
index 5d78317cf043..9c6bef517e53 100644
--- a/UnoControls/source/base/basecontainercontrol.cxx
+++ b/UnoControls/source/base/basecontainercontrol.cxx
@@ -364,20 +364,16 @@ void SAL_CALL BaseContainerControl::setVisible ( sal_Bool bVisible )
 
 //  protected method
 
-WindowDescriptor* BaseContainerControl::impl_getWindowDescriptor ( const Reference< XWindowPeer > & rParentPeer )
+WindowDescriptor BaseContainerControl::impl_getWindowDescriptor ( const Reference< XWindowPeer > & rParentPeer )
 {
-    // - used from "createPeer()" to set the values of a WindowDescriptor!!!
-    // - if you will change the descriptor-values, you must override this virtual function
-    // - the caller must release the memory for this dynamical descriptor!!!
-
-    WindowDescriptor    *   aDescriptor = new WindowDescriptor;
-
-    aDescriptor->Type               = WindowClass_CONTAINER;
-    aDescriptor->WindowServiceName  = "window";
-    aDescriptor->ParentIndex        = -1;
-    aDescriptor->Parent             = rParentPeer;
-    aDescriptor->Bounds             = getPosSize ();
-    aDescriptor->WindowAttributes   = 0;
+    WindowDescriptor aDescriptor;
+
+    aDescriptor.Type               = WindowClass_CONTAINER;
+    aDescriptor.WindowServiceName  = "window";
+    aDescriptor.ParentIndex        = -1;
+    aDescriptor.Parent             = rParentPeer;
+    aDescriptor.Bounds             = getPosSize ();
+    aDescriptor.WindowAttributes   = 0;
 
     return aDescriptor;
 }
diff --git a/UnoControls/source/base/basecontrol.cxx b/UnoControls/source/base/basecontrol.cxx
index 1e072f1bb3f7..e2ce368be91d 100644
--- a/UnoControls/source/base/basecontrol.cxx
+++ b/UnoControls/source/base/basecontrol.cxx
@@ -265,11 +265,11 @@ void SAL_CALL BaseControl::createPeer(  const   Reference< XToolkit >&      xToo
     if ( !m_xPeer.is() )
     {
         // use method "BaseControl::getWindowDescriptor()" to change window attributes!
-        WindowDescriptor* pDescriptor = impl_getWindowDescriptor( xParentPeer );
+        WindowDescriptor aDescriptor = impl_getWindowDescriptor( xParentPeer );
 
         if ( m_bVisible )
         {
-            pDescriptor->WindowAttributes |= WindowAttribute::SHOW;
+            aDescriptor.WindowAttributes |= WindowAttribute::SHOW;
         }
 
         // very slow under remote conditions!
@@ -280,12 +280,9 @@ void SAL_CALL BaseControl::createPeer(  const   Reference< XToolkit >&      xToo
             // but first create well known toolkit, if it not exist
             xLocalToolkit.set( Toolkit::create(m_xComponentContext), UNO_QUERY_THROW );
         }
-        m_xPeer         = xLocalToolkit->createWindow( *pDescriptor );
+        m_xPeer         = xLocalToolkit->createWindow( aDescriptor );
         m_xPeerWindow.set( m_xPeer, UNO_QUERY );
 
-        // don't forget to release the memory!
-        delete pDescriptor;
-
         if ( m_xPeerWindow.is() )
         {
             if ( m_xMultiplexer.is() )
@@ -700,22 +697,22 @@ void SAL_CALL BaseControl::windowHidden( const EventObject& /*aEvent*/ )
 
 //  protected method
 
-WindowDescriptor* BaseControl::impl_getWindowDescriptor( const Reference< XWindowPeer >& xParentPeer )
+WindowDescriptor BaseControl::impl_getWindowDescriptor( const Reference< XWindowPeer >& xParentPeer )
 {
     // - used from "createPeer()" to set the values of an css::awt::WindowDescriptor !!!
     // - if you will change the descriptor-values, you must override this virtual function
     // - the caller must release the memory for this dynamical descriptor !!!
 
-    WindowDescriptor* pDescriptor = new WindowDescriptor;
+    WindowDescriptor aDescriptor;
 
-    pDescriptor->Type               = WindowClass_SIMPLE;
-    pDescriptor->WindowServiceName  = "window";
-    pDescriptor->ParentIndex        = -1;
-    pDescriptor->Parent             = xParentPeer;
-    pDescriptor->Bounds             = getPosSize ();
-    pDescriptor->WindowAttributes   = 0;
+    aDescriptor.Type               = WindowClass_SIMPLE;
+    aDescriptor.WindowServiceName  = "window";
+    aDescriptor.ParentIndex        = -1;
+    aDescriptor.Parent             = xParentPeer;
+    aDescriptor.Bounds             = getPosSize ();
+    aDescriptor.WindowAttributes   = 0;
 
-    return pDescriptor;
+    return aDescriptor;
 }
 
 //  protected method
diff --git a/UnoControls/source/controls/framecontrol.cxx b/UnoControls/source/controls/framecontrol.cxx
index 69afc639af71..14b115d5accd 100644
--- a/UnoControls/source/controls/framecontrol.cxx
+++ b/UnoControls/source/controls/framecontrol.cxx
@@ -369,17 +369,17 @@ Reference< XPropertySetInfo > SAL_CALL FrameControl::getPropertySetInfo()
 
 //  BaseControl
 
-WindowDescriptor* FrameControl::impl_getWindowDescriptor( const Reference< XWindowPeer >& xParentPeer )
+WindowDescriptor FrameControl::impl_getWindowDescriptor( const Reference< XWindowPeer >& xParentPeer )
 {
-    WindowDescriptor* pDescriptor   = new WindowDescriptor;
+    WindowDescriptor aDescriptor;
 
-    pDescriptor->Type               = WindowClass_CONTAINER;
-    pDescriptor->ParentIndex        = -1;
-    pDescriptor->Parent             = xParentPeer;
-    pDescriptor->Bounds             = getPosSize ();
-    pDescriptor->WindowAttributes   = 0;
+    aDescriptor.Type               = WindowClass_CONTAINER;
+    aDescriptor.ParentIndex        = -1;
+    aDescriptor.Parent             = xParentPeer;
+    aDescriptor.Bounds             = getPosSize ();
+    aDescriptor.WindowAttributes   = 0;
 
-    return pDescriptor;
+    return aDescriptor;
 }
 
 //  private method
diff --git a/UnoControls/source/controls/statusindicator.cxx b/UnoControls/source/controls/statusindicator.cxx
index 651f55becc0b..4cdf100299ce 100644
--- a/UnoControls/source/controls/statusindicator.cxx
+++ b/UnoControls/source/controls/statusindicator.cxx
@@ -353,21 +353,17 @@ const OUString StatusIndicator::impl_getStaticImplementationName()
 
 //  protected method
 
-WindowDescriptor* StatusIndicator::impl_getWindowDescriptor( const css::uno::Reference< XWindowPeer >& xParentPeer )
+WindowDescriptor StatusIndicator::impl_getWindowDescriptor( const css::uno::Reference< XWindowPeer >& xParentPeer )
 {
-    // - used from "createPeer()" to set the values of an css::awt::WindowDescriptor !!!
-    // - if you will change the descriptor-values, you must override this virtual function
-    // - the caller must release the memory for this dynamical descriptor!!!
+    WindowDescriptor aDescriptor;
 
-    WindowDescriptor* pDescriptor = new WindowDescriptor;
+    aDescriptor.Type               =   WindowClass_SIMPLE;
+    aDescriptor.WindowServiceName  =   "floatingwindow";
+    aDescriptor.ParentIndex        =   -1;
+    aDescriptor.Parent             =   xParentPeer;
+    aDescriptor.Bounds             =   getPosSize ();
 
-    pDescriptor->Type               =   WindowClass_SIMPLE;
-    pDescriptor->WindowServiceName  =   "floatingwindow";
-    pDescriptor->ParentIndex        =   -1;
-    pDescriptor->Parent             =   xParentPeer;
-    pDescriptor->Bounds             =   getPosSize ();
-
-    return pDescriptor;
+    return aDescriptor;
 }
 
 //  protected method
diff --git a/UnoControls/source/inc/framecontrol.hxx b/UnoControls/source/inc/framecontrol.hxx
index 90d3bec494fb..f9bf6294364e 100644
--- a/UnoControls/source/inc/framecontrol.hxx
+++ b/UnoControls/source/inc/framecontrol.hxx
@@ -159,7 +159,7 @@ protected:
 
     //  BaseControl
 
-    virtual css::awt::WindowDescriptor* impl_getWindowDescriptor(
+    virtual css::awt::WindowDescriptor impl_getWindowDescriptor(
         const css::uno::Reference< css::awt::XWindowPeer >& xParentPeer
     ) override;
 
diff --git a/UnoControls/source/inc/statusindicator.hxx b/UnoControls/source/inc/statusindicator.hxx
index 9c5019d8862e..ab55345c6fd4 100644
--- a/UnoControls/source/inc/statusindicator.hxx
+++ b/UnoControls/source/inc/statusindicator.hxx
@@ -161,7 +161,7 @@ public:
     static const OUString impl_getStaticImplementationName();
 
 protected:
-    virtual css::awt::WindowDescriptor* impl_getWindowDescriptor(
+    virtual css::awt::WindowDescriptor impl_getWindowDescriptor(
         const css::uno::Reference< css::awt::XWindowPeer >& xParentPeer
     ) override;
 


More information about the Libreoffice-commits mailing list