[Libreoffice-commits] core.git: sw/inc sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Jul 25 06:46:00 UTC 2018
sw/inc/PostItMgr.hxx | 2 +-
sw/source/uibase/docvw/PostItMgr.cxx | 13 ++++++-------
2 files changed, 7 insertions(+), 8 deletions(-)
New commits:
commit 574a6265fb6adb401efefcc1312a4e1d7e6b4ddc
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Jul 24 10:20:35 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Jul 25 08:45:34 2018 +0200
loplugin:useuniqueptr in SwPostItMgr
Change-Id: I63dd541ac975648083d75fe5ce1ef86e99016faa
Reviewed-on: https://gerrit.libreoffice.org/57936
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx
index 32f77b8488f6..e3f881e59d39 100644
--- a/sw/inc/PostItMgr.hxx
+++ b/sw/inc/PostItMgr.hxx
@@ -132,7 +132,7 @@ class SwPostItMgr: public SfxListener
SwWrtShell* mpWrtShell;
VclPtr<SwEditWin> mpEditWin;
std::vector<SwSidebarItem*> mvPostItFields;
- std::vector<SwPostItPageItem*> mPages;
+ std::vector<std::unique_ptr<SwPostItPageItem>> mPages;
ImplSVEvent * mnEventId;
bool mbWaitingForCalcRects;
VclPtr<sw::annotation::SwAnnotationWin> mpActivePostIt;
diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx
index 2cd8d420db70..2365d8b026ea 100644
--- a/sw/source/uibase/docvw/PostItMgr.cxx
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
@@ -236,8 +236,6 @@ SwPostItMgr::~SwPostItMgr()
RemoveSidebarWin();
EndListening( *mpView->GetDocShell() );
- for (auto const& page : mPages)
- delete page;
mPages.clear();
}
@@ -601,8 +599,9 @@ bool SwPostItMgr::CalcRects()
if (aPageNum > mPages.size())
{
const unsigned long nNumberOfPages = mPages.size();
+ mPages.reserve(aPageNum);
for (unsigned int j=0; j<aPageNum - nNumberOfPages; ++j)
- mPages.push_back( new SwPostItPageItem());
+ mPages.emplace_back( new SwPostItPageItem());
}
mPages[aPageNum-1]->mvSidebarItems.push_back(pItem);
mPages[aPageNum-1]->mPageRect = pItem->maLayoutInfo.mPageFrame;
@@ -651,14 +650,14 @@ void SwPostItMgr::PreparePageContainer()
if (lContainerSize < lPageSize)
{
+ mPages.reserve(lPageSize);
for (int i=0; i<lPageSize - lContainerSize;i++)
- mPages.push_back( new SwPostItPageItem());
+ mPages.emplace_back( new SwPostItPageItem());
}
else if (lContainerSize > lPageSize)
{
for (int i=mPages.size()-1; i >= lPageSize;--i)
{
- delete mPages[i];
mPages.pop_back();
}
}
@@ -686,7 +685,7 @@ void SwPostItMgr::LayoutPostIts()
// - place SwPostIts on their initial position
// - calculate necessary height for all PostIts together
bool bUpdate = false;
- for (SwPostItPageItem* pPage : mPages)
+ for (std::unique_ptr<SwPostItPageItem>& pPage : mPages)
{
// only layout if there are notes on this page
if (pPage->mvSidebarItems.size()>0)
@@ -1972,7 +1971,7 @@ void SwPostItMgr::CorrectPositions()
{
long aAnchorPosX = 0;
long aAnchorPosY = 0;
- for (SwPostItPageItem* pPage : mPages)
+ for (std::unique_ptr<SwPostItPageItem>& pPage : mPages)
{
for (auto const& item : pPage->mvSidebarItems)
{
More information about the Libreoffice-commits
mailing list