From a9303d85a4f201a42322e8e4ce5ebe6e6ca728b0 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 4 Jul 2018 15:51:02 +0200 Subject: Make brittle SortedAutoCompleteStrings ownership handling more explicit Change-Id: Ieaf2231a84d97528bb1b9a410c4ee0c38966dd27 Reviewed-on: https://gerrit.libreoffice.org/56950 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- include/editeng/swafopt.hxx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/editeng/swafopt.hxx b/include/editeng/swafopt.hxx index e8d7d3a6facf..f3b34adb32a7 100644 --- a/include/editeng/swafopt.hxx +++ b/include/editeng/swafopt.hxx @@ -20,6 +20,9 @@ #ifndef INCLUDED_EDITENG_SWAFOPT_HXX #define INCLUDED_EDITENG_SWAFOPT_HXX +#include + +#include #include #include #include @@ -52,8 +55,23 @@ struct CompareAutoCompleteString class SortedAutoCompleteStrings : public o3tl::sorted_vector { + bool owning_; + + void operator =(SortedAutoCompleteStrings) = delete; + +#if !HAVE_CPP_GUARANTEED_COPY_ELISION +public: +#endif + // For createNonOwningCopy only: + SortedAutoCompleteStrings(SortedAutoCompleteStrings const & other): + sorted_vector(other), owning_(false) {} + public: - ~SortedAutoCompleteStrings() { DeleteAndDestroyAll(); } + SortedAutoCompleteStrings(): owning_(true) {} + + ~SortedAutoCompleteStrings() { if (owning_) DeleteAndDestroyAll(); } + + SortedAutoCompleteStrings createNonOwningCopy() const { return *this; } }; } // namespace editeng -- cgit