loplugin:useuniqueptr in SvxOutlinerForwarder

Change-Id: Ie861132b43b0a01ee8b4f3bc201bbf12f8af9f36
Reviewed-on: https://gerrit.libreoffice.org/54181
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2018-05-09 14:00:59 +02:00
parent 6da400912e
commit 19b4520fbf
3 changed files with 13 additions and 20 deletions

View File

@ -49,6 +49,10 @@ public:
// and the logic depends on overriding methods. // and the logic depends on overriding methods.
if (fn == SRCDIR "/sfx2/source/dialog/tabdlg.cxx") if (fn == SRCDIR "/sfx2/source/dialog/tabdlg.cxx")
return; return;
// pLongArr is being deleted here because we temporarily overwrite a pointer to someone else's buffer, with a pointer
// to our own buffer
if (fn == SRCDIR "/editeng/source/misc/txtrange.cxx")
return;
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
} }

View File

@ -109,8 +109,7 @@ SfxItemSet SvxOutlinerForwarder::GetAttribs( const ESelection& rSel, EditEngineA
else else
{ {
// no, we need delete the old cache // no, we need delete the old cache
delete mpAttribsCache; mpAttribsCache.reset();
mpAttribsCache = nullptr;
} }
} }
@ -122,7 +121,7 @@ SfxItemSet SvxOutlinerForwarder::GetAttribs( const ESelection& rSel, EditEngineA
if( EditEngineAttribs::All == nOnlyHardAttrib ) if( EditEngineAttribs::All == nOnlyHardAttrib )
{ {
mpAttribsCache = new SfxItemSet( aSet ); mpAttribsCache.reset(new SfxItemSet( aSet ));
maAttribCacheSelection = rSel; maAttribCacheSelection = rSel;
} }
@ -146,12 +145,11 @@ SfxItemSet SvxOutlinerForwarder::GetParaAttribs( sal_Int32 nPara ) const
else else
{ {
// no, we need delete the old cache // no, we need delete the old cache
delete mpParaAttribsCache; mpParaAttribsCache.reset();
mpParaAttribsCache = nullptr;
} }
} }
mpParaAttribsCache = new SfxItemSet( rOutliner.GetParaAttribs( nPara ) ); mpParaAttribsCache.reset(new SfxItemSet( rOutliner.GetParaAttribs( nPara ) ));
mnParaAttribsCache = nPara; mnParaAttribsCache = nPara;
EditEngine& rEditEngine = const_cast<EditEngine&>(rOutliner.GetEditEngine()); EditEngine& rEditEngine = const_cast<EditEngine&>(rOutliner.GetEditEngine());
@ -253,17 +251,8 @@ SfxItemState SvxOutlinerForwarder::GetItemState( sal_Int32 nPara, sal_uInt16 nWh
void SvxOutlinerForwarder::flushCache() void SvxOutlinerForwarder::flushCache()
{ {
if( mpAttribsCache ) mpAttribsCache.reset();
{ mpParaAttribsCache.reset();
delete mpAttribsCache;
mpAttribsCache = nullptr;
}
if( mpParaAttribsCache )
{
delete mpParaAttribsCache;
mpParaAttribsCache = nullptr;
}
} }
LanguageType SvxOutlinerForwarder::GetLanguage( sal_Int32 nPara, sal_Int32 nIndex ) const LanguageType SvxOutlinerForwarder::GetLanguage( sal_Int32 nPara, sal_Int32 nIndex ) const

View File

@ -22,8 +22,8 @@
#include <editeng/unoedsrc.hxx> #include <editeng/unoedsrc.hxx>
#include <editeng/editengdllapi.h> #include <editeng/editengdllapi.h>
#include <editeng/editdata.hxx> #include <editeng/editdata.hxx>
#include <memory>
class Outliner; class Outliner;
@ -37,14 +37,14 @@ private:
/** this pointer may be null or point to an item set for the attribs of /** this pointer may be null or point to an item set for the attribs of
the selection maAttribsSelection */ the selection maAttribsSelection */
mutable SfxItemSet* mpAttribsCache; mutable std::unique_ptr<SfxItemSet> mpAttribsCache;
/** if we have a cached attribute item set, this is the selection of it */ /** if we have a cached attribute item set, this is the selection of it */
mutable ESelection maAttribCacheSelection; mutable ESelection maAttribCacheSelection;
/** this pointer may be null or point to an item set for the paragraph /** this pointer may be null or point to an item set for the paragraph
mnParaAttribsCache */ mnParaAttribsCache */
mutable SfxItemSet* mpParaAttribsCache; mutable std::unique_ptr<SfxItemSet> mpParaAttribsCache;
/** if we have a cached para attribute item set, this is the paragraph of it */ /** if we have a cached para attribute item set, this is the paragraph of it */
mutable sal_Int32 mnParaAttribsCache; mutable sal_Int32 mnParaAttribsCache;