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

Noel Grandin noel.grandin at collabora.co.uk
Tue Mar 20 06:46:16 UTC 2018


 filter/source/flash/swfwriter.cxx  |    2 +-
 filter/source/flash/swfwriter.hxx  |    4 ++--
 filter/source/flash/swfwriter2.cxx |   13 ++++---------
 3 files changed, 7 insertions(+), 12 deletions(-)

New commits:
commit 9bac723400d3007c771f8a780a92d40bdaf4b3c1
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Mar 19 14:26:15 2018 +0200

    loplugin:useuniqueptr in Sprite
    
    Change-Id: I55eb8f931cdfd1898ff5a74868dc97f31ce1ae7c
    Reviewed-on: https://gerrit.libreoffice.org/51551
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/filter/source/flash/swfwriter.cxx b/filter/source/flash/swfwriter.cxx
index 4d3921158e68..366b156eb7f6 100644
--- a/filter/source/flash/swfwriter.cxx
+++ b/filter/source/flash/swfwriter.cxx
@@ -248,7 +248,7 @@ void Writer::endTag()
 
     if( mpSprite && ( (nTag == TAG_END) || (nTag == TAG_SHOWFRAME) || (nTag == TAG_DOACTION) || (nTag == TAG_STARTSOUND) || (nTag == TAG_PLACEOBJECT) || (nTag == TAG_PLACEOBJECT2) || (nTag == TAG_REMOVEOBJECT2) || (nTag == TAG_FRAMELABEL) ) )
     {
-        mpSprite->addTag( mpTag.release() );
+        mpSprite->addTag( std::move(mpTag) );
     }
     else
     {
diff --git a/filter/source/flash/swfwriter.hxx b/filter/source/flash/swfwriter.hxx
index 34982a1c588a..61972b30b9d3 100644
--- a/filter/source/flash/swfwriter.hxx
+++ b/filter/source/flash/swfwriter.hxx
@@ -196,10 +196,10 @@ public:
     ~Sprite();
 
     void write( SvStream& out );
-    void addTag( Tag* pNewTag );
+    void addTag( std::unique_ptr<Tag> pNewTag );
 
 private:
-    std::vector< Tag* > maTags;
+    std::vector< std::unique_ptr<Tag> > maTags;
     sal_uInt16  mnId;
     sal_uInt32  mnFrames;
 };
diff --git a/filter/source/flash/swfwriter2.cxx b/filter/source/flash/swfwriter2.cxx
index 85df61b7bd43..512e34654753 100644
--- a/filter/source/flash/swfwriter2.cxx
+++ b/filter/source/flash/swfwriter2.cxx
@@ -334,8 +334,6 @@ Sprite::Sprite( sal_uInt16 nId )
 
 Sprite::~Sprite()
 {
-    for (auto const& tag : maTags)
-        delete tag;
 }
 
 
@@ -358,15 +356,12 @@ void Sprite::write( SvStream& out )
 }
 
 
-void Sprite::addTag( Tag* pNewTag )
+void Sprite::addTag( std::unique_ptr<Tag> pNewTag )
 {
-    if( pNewTag )
-    {
-        if( pNewTag->getTagId() == TAG_SHOWFRAME )
-            mnFrames++;
+    if( pNewTag->getTagId() == TAG_SHOWFRAME )
+        mnFrames++;
 
-        maTags.push_back( pNewTag );
-    }
+    maTags.push_back( std::move(pNewTag) );
 }
 
 


More information about the Libreoffice-commits mailing list