From bb209f2f53edc1b0d268d561e0c12bf93e83fb41 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 11 Sep 2018 09:42:35 +0200 Subject: Revert "clang bugprone-unused-return-value" comment from sberg: aren't these changes broken in general, when the called function may throw an exception before it takes ownership of the passed-in pointer? So revert, except for (a) PlainTextFilterDetect::detect, which was definitely a leak (b) SwCursor::FindAll, where unique_ptr was being unnecessarily used This reverts commit 7764ae70b04058a64a3999529e98d1115ba59d1c. Change-Id: I555e651b44e245b031729013d2ce88d26e8a357e Reviewed-on: https://gerrit.libreoffice.org/60301 Reviewed-by: Noel Grandin Tested-by: Noel Grandin --- sd/source/ui/tools/SdGlobalResourceContainer.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sd/source') diff --git a/sd/source/ui/tools/SdGlobalResourceContainer.cxx b/sd/source/ui/tools/SdGlobalResourceContainer.cxx index 26ec1df742db..b6408cdf04be 100644 --- a/sd/source/ui/tools/SdGlobalResourceContainer.cxx +++ b/sd/source/ui/tools/SdGlobalResourceContainer.cxx @@ -99,7 +99,7 @@ void SdGlobalResourceContainer::AddResource ( mpImpl->maResources.end(), pResource.get()); if (iResource == mpImpl->maResources.end()) - mpImpl->maResources.push_back(pResource.release()); + mpImpl->maResources.push_back(pResource.get()); else { // Because the given resource is a unique_ptr it is highly unlikely @@ -107,6 +107,9 @@ void SdGlobalResourceContainer::AddResource ( SAL_WARN ( "sd.tools", "SdGlobalResourceContainer:AddResource(): Resource added twice."); } + // We can not put the unique_ptr into the vector so we release the + // unique_ptr and document that we take ownership explicitly. + pResource.release(); } void SdGlobalResourceContainer::AddResource ( -- cgit