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

Noel (via logerrit) logerrit at kemper.freedesktop.org
Sat Feb 20 06:34:31 UTC 2021


 svtools/source/config/itemholder2.cxx             |    3 ++-
 svtools/source/control/accessibleruler.cxx        |    2 +-
 svtools/source/control/valueacc.cxx               |    4 ++--
 svtools/source/hatchwindow/hatchwindowfactory.cxx |    4 ++--
 svtools/source/misc/acceleratorexecute.cxx        |   11 ++++++-----
 svtools/source/uno/unoiface.cxx                   |    2 +-
 6 files changed, 14 insertions(+), 12 deletions(-)

New commits:
commit 197bcde5c4d771ace11962213c11c9763be11039
Author:     Noel <noel.grandin at collabora.co.uk>
AuthorDate: Fri Feb 19 15:54:19 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Feb 20 07:33:33 2021 +0100

    loplugin:refcounting in svtools
    
    Change-Id: I20f6b07aded513a4100d7ae4c7d74365a93dacca
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111221
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/svtools/source/config/itemholder2.cxx b/svtools/source/config/itemholder2.cxx
index 692f182a08f8..cb02d6de5e5c 100644
--- a/svtools/source/config/itemholder2.cxx
+++ b/svtools/source/config/itemholder2.cxx
@@ -33,6 +33,7 @@
 #include <unotools/options.hxx>
 #include <svtools/miscopt.hxx>
 #include <tools/diagnose_ex.h>
+#include <rtl/ref.hxx>
 
 namespace svtools {
 
@@ -75,7 +76,7 @@ ItemHolder2::~ItemHolder2()
 
 void ItemHolder2::holdConfigItem(EItem eItem)
 {
-    static ItemHolder2* pHolder = new ItemHolder2();
+    static rtl::Reference<ItemHolder2> pHolder = new ItemHolder2();
     pHolder->impl_addItem(eItem);
 }
 
diff --git a/svtools/source/control/accessibleruler.cxx b/svtools/source/control/accessibleruler.cxx
index cfd54364e3ae..7d557a622ad4 100644
--- a/svtools/source/control/accessibleruler.cxx
+++ b/svtools/source/control/accessibleruler.cxx
@@ -197,7 +197,7 @@ uno::Reference< XAccessibleRelationSet > SAL_CALL SvtRulerAccessible::getAccessi
 uno::Reference< XAccessibleStateSet > SAL_CALL SvtRulerAccessible::getAccessibleStateSet()
 {
     ::osl::MutexGuard                       aGuard( m_aMutex );
-    utl::AccessibleStateSetHelper*          pStateSetHelper = new utl::AccessibleStateSetHelper;
+    rtl::Reference<utl::AccessibleStateSetHelper> pStateSetHelper = new utl::AccessibleStateSetHelper;
 
     if( IsAlive() )
     {
diff --git a/svtools/source/control/valueacc.cxx b/svtools/source/control/valueacc.cxx
index ff0e18959a9b..5db6e920eae3 100644
--- a/svtools/source/control/valueacc.cxx
+++ b/svtools/source/control/valueacc.cxx
@@ -218,7 +218,7 @@ uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL ValueItemAcc::g
 uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL ValueItemAcc::getAccessibleStateSet()
 {
     const SolarMutexGuard aSolarGuard;
-    ::utl::AccessibleStateSetHelper*    pStateSet = new ::utl::AccessibleStateSetHelper;
+    rtl::Reference<::utl::AccessibleStateSetHelper> pStateSet = new ::utl::AccessibleStateSetHelper;
 
     if( mpParent )
     {
@@ -638,7 +638,7 @@ uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL ValueSetAcc::ge
 uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL ValueSetAcc::getAccessibleStateSet()
 {
     ThrowIfDisposed();
-    ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper();
+    rtl::Reference<::utl::AccessibleStateSetHelper> pStateSet = new ::utl::AccessibleStateSetHelper();
 
     // Set some states.
     pStateSet->AddState (accessibility::AccessibleStateType::ENABLED);
diff --git a/svtools/source/hatchwindow/hatchwindowfactory.cxx b/svtools/source/hatchwindow/hatchwindowfactory.cxx
index 520cc1a25a01..36fe6c9c1104 100644
--- a/svtools/source/hatchwindow/hatchwindowfactory.cxx
+++ b/svtools/source/hatchwindow/hatchwindowfactory.cxx
@@ -56,9 +56,9 @@ uno::Reference< embed::XHatchWindow > SAL_CALL OHatchWindowFactory::createHatchW
         throw lang::IllegalArgumentException(); // TODO
 
     SolarMutexGuard aGuard;
-    VCLXHatchWindow* pResult = new VCLXHatchWindow();
+    rtl::Reference<VCLXHatchWindow> pResult = new VCLXHatchWindow();
     pResult->initializeWindow( xParent, aBounds, aHandlerSize );
-    return uno::Reference< embed::XHatchWindow >( static_cast< embed::XHatchWindow* >( pResult ) );
+    return pResult;
 }
 
 OUString SAL_CALL OHatchWindowFactory::getImplementationName()
diff --git a/svtools/source/misc/acceleratorexecute.cxx b/svtools/source/misc/acceleratorexecute.cxx
index 5ff9e5fa8aae..a378587fd8e5 100644
--- a/svtools/source/misc/acceleratorexecute.cxx
+++ b/svtools/source/misc/acceleratorexecute.cxx
@@ -36,6 +36,7 @@
 #include <sal/log.hxx>
 #include <vcl/lok.hxx>
 #include <osl/mutex.hxx>
+#include <rtl/ref.hxx>
 
 namespace svt
 {
@@ -57,7 +58,7 @@ class AsyncAccelExec : public cppu::WeakImplHelper<css::lang::XEventListener>
             This instance can be forced to execute its internal set request
             asynchronous. After that it deletes itself!
          */
-        static AsyncAccelExec* createOneShotInstance(const css::uno::Reference<css::lang::XComponent>& xFrame,
+        static rtl::Reference<AsyncAccelExec> createOneShotInstance(const css::uno::Reference<css::lang::XComponent>& xFrame,
                                                     const css::uno::Reference<css::frame::XDispatch>& xDispatch,
                                                     const css::util::URL& rURL);
 
@@ -215,7 +216,7 @@ bool AcceleratorExecute::execute(const css::awt::KeyEvent& aAWTKey)
         }
         else
         {
-            AsyncAccelExec* pExec = AsyncAccelExec::createOneShotInstance(xFrame, xDispatch, aURL);
+            rtl::Reference<AsyncAccelExec> pExec = AsyncAccelExec::createOneShotInstance(xFrame, xDispatch, aURL);
             pExec->execAsync();
         }
     }
@@ -451,20 +452,20 @@ AsyncAccelExec::AsyncAccelExec(const css::uno::Reference<css::lang::XComponent>&
     , m_aURL(rURL)
     , m_aAsyncCallback(LINK(this, AsyncAccelExec, impl_ts_asyncCallback))
 {
+    acquire();
 }
 
-AsyncAccelExec* AsyncAccelExec::createOneShotInstance(const css::uno::Reference<css::lang::XComponent> &xFrame,
+rtl::Reference<AsyncAccelExec> AsyncAccelExec::createOneShotInstance(const css::uno::Reference<css::lang::XComponent> &xFrame,
                                                      const css::uno::Reference< css::frame::XDispatch >& xDispatch,
                                                      const css::util::URL& rURL)
 {
-    AsyncAccelExec* pExec = new AsyncAccelExec(xFrame, xDispatch, rURL);
+    rtl::Reference<AsyncAccelExec> pExec = new AsyncAccelExec(xFrame, xDispatch, rURL);
     return pExec;
 }
 
 
 void AsyncAccelExec::execAsync()
 {
-    acquire();
     if (m_xFrame.is())
         m_xFrame->addEventListener(this);
     m_aAsyncCallback.Post();
diff --git a/svtools/source/uno/unoiface.cxx b/svtools/source/uno/unoiface.cxx
index 748fcc9dd700..71bc18150c08 100644
--- a/svtools/source/uno/unoiface.cxx
+++ b/svtools/source/uno/unoiface.cxx
@@ -25,7 +25,7 @@
 
 extern "C" {
 
-SAL_DLLPUBLIC_EXPORT vcl::Window* CreateWindow( VCLXWindow** ppNewComp, const css::awt::WindowDescriptor* pDescriptor, vcl::Window* pParent, WinBits nWinBits )
+SAL_DLLPUBLIC_EXPORT vcl::Window* CreateWindow( rtl::Reference<VCLXWindow>* ppNewComp, const css::awt::WindowDescriptor* pDescriptor, vcl::Window* pParent, WinBits nWinBits )
 {
     vcl::Window* pWindow = nullptr;
     OUString aServiceName( pDescriptor->WindowServiceName );


More information about the Libreoffice-commits mailing list