[Libreoffice-commits] core.git: 2 commits - ucb/source vcl/source
Noel Grandin
noel.grandin at collabora.co.uk
Fri Feb 2 06:38:38 UTC 2018
ucb/source/ucp/file/filtask.cxx | 56 ++++++----------------------------------
ucb/source/ucp/file/filtask.hxx | 7 ++---
vcl/source/edit/textdat2.hxx | 6 ++--
vcl/source/edit/textdata.cxx | 2 -
vcl/source/edit/texteng.cxx | 3 --
vcl/source/edit/textundo.cxx | 1
6 files changed, 15 insertions(+), 60 deletions(-)
New commits:
commit 056ee671e2d3d15eb1dd9231f4628298cbbd0ede
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Jan 29 09:00:05 2018 +0200
loplugin:useuniqueptr in TEParaPortions
Change-Id: I530c432176ea6bd338387d2f8855f9f477e8ca75
Reviewed-on: https://gerrit.libreoffice.org/49093
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/vcl/source/edit/textdat2.hxx b/vcl/source/edit/textdat2.hxx
index cef44ae687b2..27b110b6e322 100644
--- a/vcl/source/edit/textdat2.hxx
+++ b/vcl/source/edit/textdat2.hxx
@@ -212,15 +212,15 @@ public:
class TEParaPortions
{
private:
- std::vector<TEParaPortion*> mvData;
+ std::vector<std::unique_ptr<TEParaPortion>> mvData;
public:
TEParaPortions() : mvData() {}
~TEParaPortions();
sal_uInt32 Count() const { return static_cast<sal_uInt32>(mvData.size()); }
- TEParaPortion* GetObject( sal_uInt32 nIndex ) { return mvData[nIndex]; }
- void Insert( TEParaPortion* pObject, sal_uInt32 nPos ) { mvData.insert( mvData.begin()+nPos, pObject ); }
+ TEParaPortion* GetObject( sal_uInt32 nIndex ) { return mvData[nIndex].get(); }
+ void Insert( TEParaPortion* pObject, sal_uInt32 nPos ) { mvData.emplace( mvData.begin()+nPos, pObject ); }
void Remove( sal_uInt32 nPos ) { mvData.erase( mvData.begin()+nPos ); }
};
diff --git a/vcl/source/edit/textdata.cxx b/vcl/source/edit/textdata.cxx
index 72e8b3c309a8..bc8302174cab 100644
--- a/vcl/source/edit/textdata.cxx
+++ b/vcl/source/edit/textdata.cxx
@@ -267,8 +267,6 @@ void TEParaPortion::CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormat
TEParaPortions::~TEParaPortions()
{
- for (auto const& elem : mvData)
- delete elem;
}
IdleFormatter::IdleFormatter()
diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx
index 6baa37e08d0a..06d96b716fe5 100644
--- a/vcl/source/edit/texteng.cxx
+++ b/vcl/source/edit/texteng.cxx
@@ -523,7 +523,6 @@ TextPaM TextEngine::ImpConnectParagraphs( sal_uInt32 nLeft, sal_uInt32 nRight )
pLeftPortion->MarkSelectionInvalid( aPaM.GetIndex() );
mpTEParaPortions->Remove( nRight );
- delete pRightPortion;
// the right Node is deleted by EditDoc::ConnectParagraphs()
return aPaM;
@@ -601,7 +600,6 @@ TextPaM TextEngine::ImpDeleteText( const TextSelection& rSel )
void TextEngine::ImpRemoveParagraph( sal_uInt32 nPara )
{
TextNode* pNode = mpDoc->GetNodes()[ nPara ];
- std::unique_ptr<TEParaPortion> xPortion(mpTEParaPortions->GetObject( nPara ));
// the Node is handled by Undo and is deleted if appropriate
mpDoc->GetNodes().erase( mpDoc->GetNodes().begin() + nPara );
@@ -611,7 +609,6 @@ void TextEngine::ImpRemoveParagraph( sal_uInt32 nPara )
delete pNode;
mpTEParaPortions->Remove( nPara );
- xPortion.reset();
ImpParagraphRemoved( nPara );
}
diff --git a/vcl/source/edit/textundo.cxx b/vcl/source/edit/textundo.cxx
index 5c58bde20b8a..15cea12cba2e 100644
--- a/vcl/source/edit/textundo.cxx
+++ b/vcl/source/edit/textundo.cxx
@@ -165,7 +165,6 @@ void TextUndoDelPara::Redo()
// pNode is not valid anymore in case an Undo joined paragraphs
mpNode = GetDoc()->GetNodes()[ mnPara ];
- delete GetTEParaPortions()->GetObject( mnPara );
GetTEParaPortions()->Remove( mnPara );
// do not delete Node because of Undo!
commit 904263cdd05d86756da68f0b843e876747dcf3a2
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Tue Jan 23 16:21:13 2018 +0200
loplugin:useuniqueptr in TaskManager::UnqPathData
Change-Id: I6b6e7b59113fcae8dfafa4ed8586b87d2c82489e
Reviewed-on: https://gerrit.libreoffice.org/49092
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/ucb/source/ucp/file/filtask.cxx b/ucb/source/ucp/file/filtask.cxx
index 55344c00edd0..7cca2f8abf16 100644
--- a/ucb/source/ucp/file/filtask.cxx
+++ b/ucb/source/ucp/file/filtask.cxx
@@ -71,46 +71,13 @@ using namespace com::sun::star::ucb;
#define THROW_WHERE ""
#endif
-TaskManager::UnqPathData::UnqPathData()
- : properties( nullptr ),
- notifier( nullptr ),
- xS( nullptr ),
- xC( nullptr ),
- xA( nullptr )
-{
- // empty
-}
-
-
-TaskManager::UnqPathData::UnqPathData( const UnqPathData& a )
- : properties( a.properties ),
- notifier( a.notifier ),
- xS( a.xS ),
- xC( a.xC ),
- xA( a.xA )
-{
-}
+TaskManager::UnqPathData::UnqPathData() = default;
+TaskManager::UnqPathData::UnqPathData(TaskManager::UnqPathData&&) = default;
-TaskManager::UnqPathData& TaskManager::UnqPathData::operator=( UnqPathData& a )
-{
- properties = a.properties;
- notifier = a.notifier;
- xS = a.xS;
- xC = a.xC;
- xA = a.xA;
- a.properties = nullptr;
- a.notifier = nullptr;
- a.xS = nullptr;
- a.xC = nullptr;
- a.xA = nullptr;
- return *this;
-}
TaskManager::UnqPathData::~UnqPathData()
{
- delete properties;
- delete notifier;
}
TaskManager::MyProperty::MyProperty( const OUString& thePropertyName )
@@ -533,10 +500,10 @@ TaskManager::registerNotifier( const OUString& aUnqPath, Notifier* pNotifier )
osl::MutexGuard aGuard( m_aMutex );
ContentMap::iterator it =
- m_aContent.emplace( aUnqPath,UnqPathData() ).first;
+ m_aContent.emplace( aUnqPath, UnqPathData() ).first;
if( ! it->second.notifier )
- it->second.notifier = new NotifierList;
+ it->second.notifier.reset( new NotifierList );
std::vector< Notifier* >& nlist = *( it->second.notifier );
@@ -2245,7 +2212,7 @@ void
TaskManager::load( const ContentMap::iterator& it, bool create )
{
if( ! it->second.properties )
- it->second.properties = new PropertySet;
+ it->second.properties.reset( new PropertySet );
if( ( ! it->second.xS.is() ||
! it->second.xC.is() ||
@@ -2772,14 +2739,11 @@ TaskManager::getContentExchangedEventListeners( const OUString& aOldPrefix,
aNewName,UnqPathData() ).first;
// copy Ownership also
- delete itnew->second.properties;
- itnew->second.properties = itold->second.properties;
- itold->second.properties = nullptr;
+ itnew->second.properties = std::move(itold->second.properties);
// copy existing list
- std::vector< Notifier* >* copyList = itnew->second.notifier;
- itnew->second.notifier = itold->second.notifier;
- itold->second.notifier = nullptr;
+ std::unique_ptr<std::vector< Notifier* >> copyList = std::move(itnew->second.notifier);
+ itnew->second.notifier = std::move(itold->second.notifier);
m_aContent.erase( itold );
@@ -2805,7 +2769,6 @@ TaskManager::getContentExchangedEventListeners( const OUString& aOldPrefix,
++copyIt;
}
}
- delete copyList;
}
}
}
@@ -2903,8 +2866,7 @@ TaskManager::erasePersistentSet( const OUString& aUnqPath,
it->second.xC = nullptr;
it->second.xA = nullptr;
- delete it->second.properties;
- it->second.properties = nullptr;
+ it->second.properties.reset();
}
}
diff --git a/ucb/source/ucp/file/filtask.hxx b/ucb/source/ucp/file/filtask.hxx
index 0cb948e9a420..966a0cdbcbbc 100644
--- a/ucb/source/ucp/file/filtask.hxx
+++ b/ucb/source/ucp/file/filtask.hxx
@@ -230,12 +230,11 @@ namespace fileaccess
{
public:
UnqPathData();
+ UnqPathData(UnqPathData&&);
~UnqPathData();
- UnqPathData( const UnqPathData& );
- UnqPathData& operator=( UnqPathData& );
- PropertySet* properties;
- NotifierList* notifier;
+ std::unique_ptr<PropertySet> properties;
+ std::unique_ptr<NotifierList> notifier;
// Three views on the PersistentPropertySet
css::uno::Reference< css::ucb::XPersistentPropertySet > xS;
More information about the Libreoffice-commits
mailing list