[Libreoffice-commits] core.git: sd/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Dec 21 17:51:05 UTC 2018
sd/source/ui/sidebar/MasterPagesSelector.cxx | 13 ++++---------
sd/source/ui/sidebar/MasterPagesSelector.hxx | 2 +-
2 files changed, 5 insertions(+), 10 deletions(-)
New commits:
commit 441d38ea26a951f13e883789c74b17a607d81205
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Dec 21 14:14:18 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Dec 21 18:50:41 2018 +0100
pass UserData by unique_ptr in MasterPagesSelector
Change-Id: I4dbd6b37f969ea3afb441b449d416eedd6bd5cec
Reviewed-on: https://gerrit.libreoffice.org/65530
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sd/source/ui/sidebar/MasterPagesSelector.cxx b/sd/source/ui/sidebar/MasterPagesSelector.cxx
index 86b6ab52e7e3..6ef4023993b7 100644
--- a/sd/source/ui/sidebar/MasterPagesSelector.cxx
+++ b/sd/source/ui/sidebar/MasterPagesSelector.cxx
@@ -450,17 +450,12 @@ MasterPagesSelector::UserData* MasterPagesSelector::GetUserData (int nIndex) con
return nullptr;
}
-void MasterPagesSelector::SetUserData (int nIndex, UserData* pData)
+void MasterPagesSelector::SetUserData (int nIndex, std::unique_ptr<UserData> pData)
{
const ::osl::MutexGuard aGuard (maMutex);
- if (nIndex>0 && static_cast<unsigned int>(nIndex)<=PreviewValueSet::GetItemCount())
- {
- UserData* pOldData = GetUserData(nIndex);
- if (pOldData!=nullptr && pOldData!=pData)
- delete pOldData;
- PreviewValueSet::SetItemData(static_cast<sal_uInt16>(nIndex), pData);
- }
+ delete GetUserData(nIndex);
+ PreviewValueSet::SetItemData(static_cast<sal_uInt16>(nIndex), pData.release());
}
void MasterPagesSelector::SetItem (
@@ -493,7 +488,7 @@ void MasterPagesSelector::SetItem (
mpContainer->GetPageNameForToken(aToken),
nIndex);
}
- SetUserData(nIndex, new UserData(nIndex,aToken));
+ SetUserData(nIndex, o3tl::make_unique<UserData>(nIndex,aToken));
AddTokenToIndexEntry(nIndex,aToken);
}
diff --git a/sd/source/ui/sidebar/MasterPagesSelector.hxx b/sd/source/ui/sidebar/MasterPagesSelector.hxx
index c058368c2793..55b0acdaca39 100644
--- a/sd/source/ui/sidebar/MasterPagesSelector.hxx
+++ b/sd/source/ui/sidebar/MasterPagesSelector.hxx
@@ -123,7 +123,7 @@ protected:
typedef ::std::pair<int, MasterPageContainer::Token> UserData;
UserData* GetUserData (int nIndex) const;
- void SetUserData (int nIndex, UserData* pData);
+ void SetUserData (int nIndex, std::unique_ptr<UserData> pData);
sal_Int32 GetIndexForToken (MasterPageContainer::Token aToken) const;
typedef ::std::vector<MasterPageContainer::Token> ItemList;
More information about the Libreoffice-commits
mailing list