From c9c20dc23b0ca9bc11d6bcc6a324fabb2325080e Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Tue, 1 Jul 2014 22:23:06 +0200 Subject: [PATCH] Make IconvProcessor::Impl noncopyable The compiler-generated copy-constructor and assigment operators would be wrong for IconvProcessor::Impl, since cd would be copied, and iconv_close() could thus be called twice on the same descriptor. The old code did work, but now IconvProcessor::Impl cannot be copied by accident in the future. --- src/support/unicode.cpp | 6 +++++- src/support/unicode.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/support/unicode.cpp b/src/support/unicode.cpp index 954aa79322..26f834a58b 100644 --- a/src/support/unicode.cpp +++ b/src/support/unicode.cpp @@ -52,8 +52,12 @@ namespace lyx { static const iconv_t invalid_cd = (iconv_t)(-1); -struct IconvProcessor::Impl +class IconvProcessor::Impl { + // noncopyable because iconv_close() is called in destructor + Impl(Impl const &); + Impl & operator=(Impl const &); +public: Impl(string const & to, string const & from) : cd(invalid_cd), tocode_(to), fromcode_(from) {} diff --git a/src/support/unicode.h b/src/support/unicode.h index 87a8392158..aad4f8d408 100644 --- a/src/support/unicode.h +++ b/src/support/unicode.h @@ -68,7 +68,7 @@ private: /// \return true if the processor is ready to use. bool init(); /// hide internals - struct Impl; + class Impl; Impl * pimpl_; }; -- 2.39.2