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

Noel (via logerrit) logerrit at kemper.freedesktop.org
Fri Feb 19 12:16:38 UTC 2021


 ucb/source/core/FileAccess.cxx          |    5 ++---
 ucb/source/ucp/file/bc.cxx              |   10 ++++------
 ucb/source/ucp/file/filnot.cxx          |   14 +++++---------
 ucb/source/ucp/file/filrset.cxx         |   12 +++---------
 ucb/source/ucp/file/filtask.cxx         |   12 ++++--------
 ucb/source/ucp/file/prov.cxx            |    6 ++----
 ucb/source/ucp/ftp/ftpresultsetbase.cxx |    4 +---
 ucb/source/ucp/tdoc/tdoc_storage.cxx    |    5 +++--
 8 files changed, 24 insertions(+), 44 deletions(-)

New commits:
commit de9d840743413470aa57333fbe540d6c8f7dffb1
Author:     Noel <noel.grandin at collabora.co.uk>
AuthorDate: Fri Feb 19 11:28:03 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Feb 19 13:15:56 2021 +0100

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

diff --git a/ucb/source/core/FileAccess.cxx b/ucb/source/core/FileAccess.cxx
index 139c05cb500a..c998318924ff 100644
--- a/ucb/source/core/FileAccess.cxx
+++ b/ucb/source/core/FileAccess.cxx
@@ -543,10 +543,9 @@ Reference< XStream > OFileAccess::openFileReadWrite( const OUString& FileURL )
         {
             // Create file...
             SvMemoryStream aStream(0,0);
-            ::utl::OInputStreamWrapper* pInput = new ::utl::OInputStreamWrapper( aStream );
-            Reference< XInputStream > xInput( pInput );
+            rtl::Reference<::utl::OInputStreamWrapper> pInput = new ::utl::OInputStreamWrapper( aStream );
             InsertCommandArgument aInsertArg;
-            aInsertArg.Data = xInput;
+            aInsertArg.Data = pInput;
             aInsertArg.ReplaceExisting = false;
 
             aCmdArg <<= aInsertArg;
diff --git a/ucb/source/ucp/file/bc.cxx b/ucb/source/ucp/file/bc.cxx
index 2f88d029e721..e77f6ed45e22 100644
--- a/ucb/source/ucp/file/bc.cxx
+++ b/ucb/source/ucp/file/bc.cxx
@@ -19,6 +19,7 @@
 
 #include <rtl/uri.hxx>
 #include <rtl/ustrbuf.hxx>
+#include <rtl/ref.hxx>
 
 #include <tools/diagnose_ex.h>
 #include <com/sun/star/lang/NoSupportException.hpp>
@@ -546,8 +547,7 @@ BaseContent::createNewContent( const ContentInfo& Info )
     else
         dstUncPath = m_aUncPath;
 
-    BaseContent* p = new BaseContent( m_pMyShell, dstUncPath, bFolder );
-    return Reference< XContent >( p );
+    return new BaseContent( m_pMyShell, dstUncPath, bFolder );
 }
 
 
@@ -591,8 +591,7 @@ BaseContent::getParent()
     if( err )
         return Reference< XInterface >( nullptr );
 
-    FileContentIdentifier* p = new FileContentIdentifier( ParentUnq );
-    Reference< XContentIdentifier > Identifier( p );
+    rtl::Reference<FileContentIdentifier> Identifier = new FileContentIdentifier( ParentUnq );
 
     try
     {
@@ -1133,8 +1132,7 @@ BaseContent::cEXC( const OUString& aNewName )
 
     Reference< XContentIdentifier > xOldRef = m_xContentIdentifier;
     m_aUncPath = aNewName;
-    FileContentIdentifier* pp = new FileContentIdentifier( aNewName );
-    m_xContentIdentifier.set( pp );
+    m_xContentIdentifier = new FileContentIdentifier( aNewName );
 
     std::unique_ptr<ContentEventNotifier> p;
     if( m_pContentEventListeners )
diff --git a/ucb/source/ucp/file/filnot.cxx b/ucb/source/ucp/file/filnot.cxx
index c5d25b38d058..19a9d2e0b141 100644
--- a/ucb/source/ucp/file/filnot.cxx
+++ b/ucb/source/ucp/file/filnot.cxx
@@ -19,6 +19,7 @@
 
 #include <com/sun/star/ucb/ContentAction.hpp>
 #include <com/sun/star/beans/PropertySetInfoChange.hpp>
+#include <rtl/ref.hxx>
 #include "filnot.hxx"
 #include "filid.hxx"
 #include "bc.hxx"
@@ -58,8 +59,7 @@ ContentEventNotifier::ContentEventNotifier( TaskManager* pMyShell,
 
 void ContentEventNotifier::notifyChildInserted( const OUString& aChildName )
 {
-    FileContentIdentifier* p = new FileContentIdentifier( aChildName );
-    uno::Reference< XContentIdentifier > xChildId( p );
+    rtl::Reference<FileContentIdentifier> xChildId = new FileContentIdentifier( aChildName );
 
     uno::Reference< XContent > xChildContent = m_pMyShell->m_pProvider->queryContent( xChildId );
 
@@ -96,21 +96,17 @@ void ContentEventNotifier::notifyDeleted()
 
 void ContentEventNotifier::notifyRemoved( const OUString& aChildName )
 {
-    FileContentIdentifier* p = new FileContentIdentifier( aChildName );
-    uno::Reference< XContentIdentifier > xChildId( p );
+    rtl::Reference<FileContentIdentifier> xChildId = new FileContentIdentifier( aChildName );
 
-    BaseContent* pp = new BaseContent( m_pMyShell,xChildId,aChildName );
+    rtl::Reference<BaseContent> pp = new BaseContent( m_pMyShell,xChildId,aChildName );
     {
         osl::MutexGuard aGuard( pp->m_aMutex );
         pp->m_nState |= BaseContent::Deleted;
     }
 
-    uno::Reference< XContent > xDeletedContent( pp );
-
-
     ContentEvent aEvt( m_xCreatorContent,
                        ContentAction::REMOVED,
-                       xDeletedContent,
+                       pp,
                        m_xCreatorId );
 
     for( const auto& r : m_sListeners )
diff --git a/ucb/source/ucp/file/filrset.cxx b/ucb/source/ucp/file/filrset.cxx
index 470ec88d6f58..5447af1433a9 100644
--- a/ucb/source/ucp/file/filrset.cxx
+++ b/ucb/source/ucp/file/filrset.cxx
@@ -600,17 +600,13 @@ XResultSet_impl::getMetaData()
         // @@@ #82177# - Determine correct value!
         aColumnData[ n ].isCaseSensitive = false;
 
-        ::ucbhelper::ResultSetMetaData* p =
-            new ::ucbhelper::ResultSetMetaData(
+        return new ::ucbhelper::ResultSetMetaData(
                 m_pMyShell->m_xContext,
                 m_sProperty,
                 aColumnData );
-        return uno::Reference< sdbc::XResultSetMetaData >( p );
     }
 
-    ::ucbhelper::ResultSetMetaData* p =
-            new ::ucbhelper::ResultSetMetaData( m_pMyShell->m_xContext, m_sProperty );
-    return uno::Reference< sdbc::XResultSetMetaData >( p );
+    return new ::ucbhelper::ResultSetMetaData( m_pMyShell->m_xContext, m_sProperty );
 }
 
 
@@ -630,9 +626,7 @@ XResultSet_impl::getPropertySetInfo()
     seq[1].Type = cppu::UnoType<sal_Bool>::get();
     seq[1].Attributes = beans::PropertyAttribute::READONLY;
 
-    XPropertySetInfo_impl* p = new XPropertySetInfo_impl( m_pMyShell,
-                                                          seq );
-    return uno::Reference< beans::XPropertySetInfo > ( p );
+    return new XPropertySetInfo_impl( m_pMyShell, seq );
 }
 
 
diff --git a/ucb/source/ucp/file/filtask.cxx b/ucb/source/ucp/file/filtask.cxx
index 1a95350105b7..89e085773568 100644
--- a/ucb/source/ucp/file/filtask.cxx
+++ b/ucb/source/ucp/file/filtask.cxx
@@ -804,8 +804,7 @@ TaskManager::ls( sal_Int32 CommandId,
 uno::Reference< XCommandInfo >
 TaskManager::info_c()
 {
-    XCommandInfo_impl* p = new XCommandInfo_impl( this );
-    return uno::Reference< XCommandInfo >( p );
+    return new XCommandInfo_impl( this );
 }
 
 
@@ -820,8 +819,7 @@ uno::Reference< beans::XPropertySetInfo >
 TaskManager::info_p( const OUString& aUnqPath )
 {
     osl::MutexGuard aGuard( m_aMutex );
-    XPropertySetInfo_impl* p = new XPropertySetInfo_impl( this,aUnqPath );
-    return uno::Reference< beans::XPropertySetInfo >( p );
+    return new XPropertySetInfo_impl( this,aUnqPath );
 }
 
 
@@ -1108,8 +1106,7 @@ TaskManager::getv( sal_Int32 CommandId,
             });
     }
 
-    XRow_impl* p = new XRow_impl( this,seq );
-    return uno::Reference< sdbc::XRow >( p );
+    return new XRow_impl( this,seq );
 }
 
 
@@ -2531,8 +2528,7 @@ TaskManager::getv(
             });
     }
 
-    XRow_impl* p = new XRow_impl( this,seq );
-    row = uno::Reference< sdbc::XRow >( p );
+    row = new XRow_impl( this,seq );
     return true;
 }
 
diff --git a/ucb/source/ucp/file/prov.cxx b/ucb/source/ucp/file/prov.cxx
index 1577488df3e4..525e099b0cf4 100644
--- a/ucb/source/ucp/file/prov.cxx
+++ b/ucb/source/ucp/file/prov.cxx
@@ -189,8 +189,7 @@ FileProvider::createContentIdentifier(
                       const OUString& ContentId )
 {
     init();
-    FileContentIdentifier* p = new FileContentIdentifier( ContentId,false );
-    return Reference< XContentIdentifier >( p );
+    return new FileContentIdentifier( ContentId,false );
 }
 
 
@@ -329,8 +328,7 @@ void FileProvider::initProperties()
     // static const sal_Int32 DOS_NOTATION = (sal_Int32)2;
     // static const sal_Int32 MAC_NOTATION = (sal_Int32)3;
 
-    XPropertySetInfoImpl2* p = new XPropertySetInfoImpl2();
-    m_xPropertySetInfo.set( p );
+    m_xPropertySetInfo = new XPropertySetInfoImpl2();
 }
 
 
diff --git a/ucb/source/ucp/ftp/ftpresultsetbase.cxx b/ucb/source/ucp/ftp/ftpresultsetbase.cxx
index cb3d017af7d3..ff2c970f181e 100644
--- a/ucb/source/ucp/ftp/ftpresultsetbase.cxx
+++ b/ucb/source/ucp/ftp/ftpresultsetbase.cxx
@@ -508,9 +508,7 @@ void SAL_CALL ResultSetBase::removeVetoableChangeListener(
 uno::Reference< sdbc::XResultSetMetaData > SAL_CALL
 ResultSetBase::getMetaData()
 {
-    ::ucbhelper::ResultSetMetaData* p =
-          new ::ucbhelper::ResultSetMetaData( m_xContext, m_sProperty );
-    return uno::Reference< sdbc::XResultSetMetaData >( p );
+    return new ::ucbhelper::ResultSetMetaData( m_xContext, m_sProperty );
 }
 
 
diff --git a/ucb/source/ucp/tdoc/tdoc_storage.cxx b/ucb/source/ucp/tdoc/tdoc_storage.cxx
index 49493ec7b73f..7fc0f247a60b 100644
--- a/ucb/source/ucp/tdoc/tdoc_storage.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_storage.cxx
@@ -215,9 +215,10 @@ StorageElementFactory::createStorage( const OUString & rUri,
             return xStorage;
         }
 
-        aIt->second = new Storage( m_xContext, this, aUriKey, xParentStorage, xStorage );
+        rtl::Reference<Storage> pNewStorage = new Storage( m_xContext, this, aUriKey, xParentStorage, xStorage );
+        aIt->second = pNewStorage.get();
         aIt->second->m_aContainerIt = aIt;
-        return aIt->second;
+        return pNewStorage;
     }
 }
 


More information about the Libreoffice-commits mailing list