sc/source/ui/unoobj/funcuno.cxx |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

New commits:
commit 8cf99c39b5dba7d1dbfda70e73ee3a8388037325
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Thu Mar 17 20:09:05 2022 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Thu Mar 17 19:38:39 2022 +0100

    Use ScDocumentUniquePtr in ScTempDocSource
    
    Change-Id: I17d726aba52dd25f221f2ff3e9238f935afa4de5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131715
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx
index d3fe7c342c50..e0d18a7a2ab0 100644
--- a/sc/source/ui/unoobj/funcuno.cxx
+++ b/sc/source/ui/unoobj/funcuno.cxx
@@ -63,7 +63,7 @@ class ScTempDocSource
 {
 private:
     ScTempDocCache& rCache;
-    ScDocument*     pTempDoc;
+    ScDocumentUniquePtr pTempDoc;
 
     static ScDocument*  CreateDocument();       // create and initialize doc
 
@@ -84,11 +84,10 @@ ScDocument* ScTempDocSource::CreateDocument()
 }
 
 ScTempDocSource::ScTempDocSource( ScTempDocCache& rDocCache ) :
-    rCache( rDocCache ),
-    pTempDoc( nullptr )
+    rCache( rDocCache )
 {
     if ( rCache.IsInUse() )
-        pTempDoc = CreateDocument();
+        pTempDoc.reset(CreateDocument());
     else
     {
         rCache.SetInUse( true );
@@ -99,16 +98,14 @@ ScTempDocSource::ScTempDocSource( ScTempDocCache& rDocCache 
) :
 
 ScTempDocSource::~ScTempDocSource() COVERITY_NOEXCEPT_FALSE
 {
-    if ( pTempDoc )
-        delete pTempDoc;
-    else
+    if ( !pTempDoc )
         rCache.SetInUse( false );
 }
 
 ScDocument* ScTempDocSource::GetDocument()
 {
     if ( pTempDoc )
-        return pTempDoc;
+        return pTempDoc.get();
     else
         return rCache.GetDocument();
 }

Reply via email to