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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Jul 17 10:34:39 UTC 2018


 sc/inc/document.hxx                |   10 ++++++----
 sc/source/core/data/documen2.cxx   |    2 +-
 sc/source/core/data/document.cxx   |   16 ++++++++--------
 sc/source/core/data/document10.cxx |    2 +-
 4 files changed, 16 insertions(+), 14 deletions(-)

New commits:
commit 8898bae2affc470db4b70baa3050edfad163e2e5
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Jul 16 12:13:01 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Jul 17 12:34:12 2018 +0200

    coverity#1401328 Uncaught exception
    
    Change-Id: I112260f1ea02c2173be56dde1d78497fc8339cec
    Reviewed-on: https://gerrit.libreoffice.org/57543
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index f2ee35bc693a..4fcee74748ca 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -35,10 +35,11 @@
 #include "typedstrdata.hxx"
 #include "calcmacros.hxx"
 #include "calcconfig.hxx"
+#include <o3tl/deleter.hxx>
 #include <svl/hint.hxx>
-#include <tools/gen.hxx>
-#include <svl/zforlist.hxx>
 #include <svl/typedwhich.hxx>
+#include <svl/zforlist.hxx>
+#include <tools/gen.hxx>
 
 #include <cassert>
 #include <memory>
@@ -49,7 +50,6 @@
 #include "markdata.hxx"
 
 namespace com { namespace sun { namespace star { namespace chart2 { class XChartDocument; } } } }
-namespace o3tl { template <typename T> struct default_delete; }
 
 class Timer;
 
@@ -297,6 +297,8 @@ enum ScMutationGuardFlags
     CORE = 0x0001, /// Core calc data structures should not be mutated
 };
 
+typedef std::unique_ptr<ScTable, o3tl::default_delete<ScTable>> ScTableUniquePtr;
+
 class ScDocument
 {
 friend class ScValueIterator;
@@ -326,7 +328,7 @@ friend class sc::TableColumnBlockPositionSet;
 friend struct ScMutationGuard;
 friend struct ScMutationDisable;
 
-    typedef std::vector<std::unique_ptr<ScTable>> TableContainer;
+    typedef std::vector<ScTableUniquePtr> TableContainer;
 
 public:
     enum class HardRecalcState
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index b39d0866be24..f3f63f2811f3 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -783,7 +783,7 @@ bool ScDocument::MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress )
                 pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_REORDER,
                             aSourceRange, 0,0,nDz ) );
 
-            std::unique_ptr<ScTable> pSaveTab = std::move(maTabs[nOldPos]);
+            ScTableUniquePtr pSaveTab = std::move(maTabs[nOldPos]);
             maTabs.erase(maTabs.begin()+nOldPos);
             maTabs.insert(maTabs.begin()+nNewPos, std::move(pSaveTab));
             TableContainer::iterator it = maTabs.begin();
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index fd69d4b25e1f..44699a55a7b3 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -123,7 +123,7 @@ using ::std::set;
 
 namespace {
 
-std::pair<SCTAB,SCTAB> getMarkedTableRange(const std::vector<std::unique_ptr<ScTable>>& rTables, const ScMarkData& rMark)
+std::pair<SCTAB,SCTAB> getMarkedTableRange(const std::vector<ScTableUniquePtr>& rTables, const ScMarkData& rMark)
 {
     SCTAB nTabStart = MAXTAB;
     SCTAB nTabEnd = 0;
@@ -724,7 +724,7 @@ bool ScDocument::DeleteTab( SCTAB nTab )
                 if ( pUnoBroadcaster )
                     pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,-1 ) );
 
-                for (std::unique_ptr<ScTable> & pTab : maTabs)
+                for (auto & pTab : maTabs)
                     if (pTab)
                         pTab->UpdateDeleteTab(aCxt);
 
@@ -819,7 +819,7 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets )
                 if ( pUnoBroadcaster )
                     pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,-1*nSheets ) );
 
-                for (std::unique_ptr<ScTable> & pTab : maTabs)
+                for (auto & pTab : maTabs)
                     if (pTab)
                         pTab->UpdateDeleteTab(aCxt);
 
@@ -1212,7 +1212,7 @@ namespace {
 
 struct SetDirtyIfPostponedHandler
 {
-    void operator() (std::unique_ptr<ScTable> & p)
+    void operator() (ScTableUniquePtr & p)
     {
         if (p)
             p->SetDirtyIfPostponed();
@@ -1221,7 +1221,7 @@ struct SetDirtyIfPostponedHandler
 
 struct BroadcastRecalcOnRefMoveHandler
 {
-    void operator() (std::unique_ptr<ScTable> & p)
+    void operator() (ScTableUniquePtr & p)
     {
         if (p)
             p->BroadcastRecalcOnRefMove();
@@ -1958,7 +1958,7 @@ void ScDocument::InitUndoSelected( const ScDocument* pSrcDoc, const ScMarkData&
         for (SCTAB nTab = 0; nTab <= rTabSelection.GetLastSelected(); nTab++)
             if ( rTabSelection.GetTableSelect( nTab ) )
             {
-                std::unique_ptr<ScTable> pTable(new ScTable(this, nTab, OUString(), bColInfo, bRowInfo));
+                ScTableUniquePtr pTable(new ScTable(this, nTab, OUString(), bColInfo, bRowInfo));
                 if (nTab < static_cast<SCTAB>(maTabs.size()))
                     maTabs[nTab] = std::move(pTable);
                 else
@@ -3976,7 +3976,7 @@ void ScDocument::CompileXML()
         pRangeName->CompileUnresolvedXML(aCxt);
 
     std::for_each(maTabs.begin(), maTabs.end(),
-        [&](std::unique_ptr<ScTable> & pTab)
+        [&](ScTableUniquePtr & pTab)
         {
             if (pTab)
                 pTab->CompileXML(aCxt, aProgress);
@@ -6666,7 +6666,7 @@ SCROW ScDocument::GetNotePosition( SCTAB nTab, SCCOL nCol, size_t nIndex ) const
 
 void ScDocument::GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const
 {
-    for (const std::unique_ptr<ScTable> & pTab : maTabs)
+    for (const auto & pTab : maTabs)
     {
         if (!pTab)
             continue;
diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index de1122d5297f..41a00c7a8a2c 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -477,7 +477,7 @@ public:
         mpCxt->setColumnSet( rpColSet);
     }
 
-    void operator() (std::unique_ptr<ScTable> & p)
+    void operator() (ScTableUniquePtr & p)
     {
         if (p)
             p->StartListeners(*mpCxt, false);


More information about the Libreoffice-commits mailing list