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

Jochen Nitschke j.nitschke+logerrit at ok.de
Wed Jan 11 07:51:11 UTC 2017


 sc/inc/rangelst.hxx                 |    4 ++--
 sc/source/core/tool/rangelst.cxx    |   30 +++++++++++++-----------------
 sc/source/filter/excel/xehelper.cxx |    2 +-
 sc/source/ui/miscdlgs/crnrdlg.cxx   |    3 ---
 sc/source/ui/unoobj/nameuno.cxx     |    6 +-----
 5 files changed, 17 insertions(+), 28 deletions(-)

New commits:
commit 6139bca62399286bec70cbec4c7c10b2297ff22a
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date:   Thu Jan 5 20:13:31 2017 +0100

    don't emit objects on ScRange*List::Remove
    
    Change-Id: I6be23f6659079f5c60be9574c717fd4f7de23bc4
    Reviewed-on: https://gerrit.libreoffice.org/32754
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/inc/rangelst.hxx b/sc/inc/rangelst.hxx
index 18eb33d..3fe510c 100644
--- a/sc/inc/rangelst.hxx
+++ b/sc/inc/rangelst.hxx
@@ -75,7 +75,7 @@ public:
 
     ScRangeList     GetIntersectedRange(const ScRange& rRange) const;
 
-    ScRange*        Remove(size_t nPos);
+    void            Remove(size_t nPos);
     void            RemoveAll();
 
     ScRange         Combine() const;
@@ -123,7 +123,7 @@ public:
     ScRangePair**       CreateNameSortedArray( size_t& nCount, ScDocument* ) const;
 
     void                Remove(size_t nPos);
-    ScRangePair*        Remove(ScRangePair* pAdr);
+    void                Remove(ScRangePair* pAdr);
 
     size_t              size() const;
     ScRangePair*        operator[](size_t idx);
diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index 2081352..8c40bf4f 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -330,7 +330,6 @@ void ScRangeList::Join( const ScRange& r, bool bIsInList )
             {   // innerhalb der Liste Range loeschen
                 Remove(nOldPos);
                 i--;
-                delete pOver;
                 pOver = nullptr;
                 if ( nOldPos )
                     nOldPos--;          // Seek richtig aufsetzen
@@ -948,8 +947,7 @@ bool ScRangeList::DeleteArea( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
     {
         if(FindRangeIn< ScRange >(aRange)(maRanges[i]))
         {
-            ScRange* pRange = Remove(i);
-            delete pRange;
+            Remove(i);
             bChanged = true;
         }
         else
@@ -1079,17 +1077,16 @@ size_t ScRangeList::GetCellCount() const
     return for_each(maRanges.begin(), maRanges.end(), func).getCellCount();
 }
 
-ScRange* ScRangeList::Remove(size_t nPos)
+void ScRangeList::Remove(size_t nPos)
 {
     if (maRanges.size() <= nPos)
         // Out-of-bound condition.  Bail out.
-        return nullptr;
+        return;
 
     iterator itr = maRanges.begin();
     advance(itr, nPos);
-    ScRange* p = *itr;
+    delete *itr;
     maRanges.erase(itr);
-    return p;
 }
 
 void ScRangeList::RemoveAll()
@@ -1237,24 +1234,25 @@ void ScRangePairList::Remove(size_t nPos)
 
     vector<ScRangePair*>::iterator itr = maPairs.begin();
     advance(itr, nPos);
+    delete *itr;
     maPairs.erase(itr);
 }
 
-ScRangePair* ScRangePairList::Remove( ScRangePair* Adr)
+void ScRangePairList::Remove( ScRangePair* Adr)
 {
-    ScRangePair* p = nullptr;
-
-    if (Adr == nullptr) return nullptr;
+    if (Adr == nullptr)
+        return;
 
-    for ( vector<ScRangePair*>::iterator itr = maPairs.begin(); itr < maPairs.end(); ++itr )
+    for ( vector<ScRangePair*>::iterator itr = maPairs.begin(); itr != maPairs.end(); ++itr )
     {
-        if ( Adr == (p = *itr) )
+        if (Adr == *itr)
         {
+            delete *itr;
             maPairs.erase( itr );
-            break;
+            return;
         }
     }
-    return p;
+    assert(false);
 }
 
 ScRangePair* ScRangePairList::operator [](size_t idx)
@@ -1323,7 +1321,6 @@ void ScRangePairList::DeleteOnTab( SCTAB nTab )
         if ( aRange.aStart.Tab() == nTab && aRange.aEnd.Tab() == nTab )
         {
             Remove( nPos );
-            delete pR;
             nListCount = maPairs.size();
         }
         else
@@ -1544,7 +1541,6 @@ void ScRangePairList::Join( const ScRangePair& r, bool bIsInList )
             {   // innerhalb der Liste RangePair loeschen
                 Remove( nOldPos );
                 i--;
-                delete pOver;
                 pOver = nullptr;
                 if ( nOldPos )
                     nOldPos--;          // Seek richtig aufsetzen
diff --git a/sc/source/filter/excel/xehelper.cxx b/sc/source/filter/excel/xehelper.cxx
index ba13ae2..22d3ebb 100644
--- a/sc/source/filter/excel/xehelper.cxx
+++ b/sc/source/filter/excel/xehelper.cxx
@@ -252,7 +252,7 @@ void XclExpAddressConverter::ValidateRangeList( ScRangeList& rScRanges, bool bWa
     {
         ScRange* pScRange = rScRanges[ --nRange ];
         if( !CheckRange( *pScRange, bWarn ) )
-            delete rScRanges.Remove(nRange);
+            rScRanges.Remove(nRange);
     }
 }
 
diff --git a/sc/source/ui/miscdlgs/crnrdlg.cxx b/sc/source/ui/miscdlgs/crnrdlg.cxx
index d8c3bee..953f105 100644
--- a/sc/source/ui/miscdlgs/crnrdlg.cxx
+++ b/sc/source/ui/miscdlgs/crnrdlg.cxx
@@ -539,12 +539,10 @@ IMPL_LINK_NOARG(ScColRowNameRangesDlg, AddBtnHdl, Button*, void)
             if ( ( pPair = xColNameRanges->Find( theCurArea ) ) != nullptr )
             {
                 xColNameRanges->Remove( pPair );
-                delete pPair;
             }
             if ( ( pPair = xRowNameRanges->Find( theCurArea ) ) != nullptr )
             {
                 xRowNameRanges->Remove( pPair );
-                delete pPair;
             }
             if ( pBtnColHead->IsChecked() )
                 xColNameRanges->Join( ScRangePair( theCurArea, theCurData ) );
@@ -605,7 +603,6 @@ IMPL_LINK_NOARG(ScColRowNameRangesDlg, RemoveBtnHdl, Button*, void)
                 xColNameRanges->Remove( pPair );
             else
                 xRowNameRanges->Remove( pPair );
-            delete pPair;
 
             UpdateNames();
             const sal_Int32 nCnt = pLbRange->GetEntryCount();
diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx
index a8f31d1..b71f9f5 100644
--- a/sc/source/ui/unoobj/nameuno.cxx
+++ b/sc/source/ui/unoobj/nameuno.cxx
@@ -975,15 +975,12 @@ void ScLabelRangeObj::Modify_Impl( const ScRange* pLabel, const ScRange* pData )
             ScRangePair* pEntry = xNewList->Find( aRange );
             if (pEntry)
             {
-                xNewList->Remove( pEntry );     // only removed from list, not deleted
-
                 if ( pLabel )
                     pEntry->GetRange(0) = *pLabel;
                 if ( pData )
                     pEntry->GetRange(1) = *pData;
 
-                xNewList->Join( *pEntry );
-                delete pEntry;
+                xNewList->Join( *pEntry, true );
 
                 if (bColumn)
                     rDoc.GetColNameRangesRef() = xNewList;
@@ -1139,7 +1136,6 @@ void SAL_CALL ScLabelRangesObj::removeByIndex( sal_Int32 nIndex )
             if (pEntry)
             {
                 xNewList->Remove( pEntry );
-                delete pEntry;
 
                 if (bColumn)
                     rDoc.GetColNameRangesRef() = xNewList;


More information about the Libreoffice-commits mailing list