]> git.lyx.org Git - lyx.git/commitdiff
Make IconvProcessor::Impl noncopyable
authorGeorg Baum <baum@lyx.org>
Tue, 1 Jul 2014 20:23:06 +0000 (22:23 +0200)
committerGeorg Baum <baum@lyx.org>
Tue, 1 Jul 2014 20:23:06 +0000 (22:23 +0200)
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
src/support/unicode.h

index 954aa79322b5e7d509a4ea6195480494d0fa152e..26f834a58bec98aa4c38f2155ebac98365b1b3c5 100644 (file)
@@ -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)
        {}
index 87a8392158a232c2f6a5814ed21ffa040be8f704..aad4f8d408f697ca7a7c11ca78769331f34f4d72 100644 (file)
@@ -68,7 +68,7 @@ private:
        /// \return true if the processor is ready to use.
        bool init();
        /// hide internals
-       struct Impl;
+       class Impl;
        Impl * pimpl_;
 };