]> git.lyx.org Git - lyx.git/blobdiff - src/support/unicode.cpp
Remove non-copyable idioms
[lyx.git] / src / support / unicode.cpp
index 343b8def2be42438ad449c085e59a8af3e5fb170..995fa10c5979f0c2224add047f8bf312fc235040 100644 (file)
@@ -52,8 +52,13 @@ namespace lyx {
 static const iconv_t invalid_cd = (iconv_t)(-1);
 
 
-struct IconvProcessor::Impl
+class IconvProcessor::Impl
 {
+public:
+       // noncopyable because iconv_close() is called in destructor
+       Impl(Impl const &) = delete;
+       Impl & operator=(Impl const &) = delete;
+
        Impl(string const & to, string const & from)
                : cd(invalid_cd), tocode_(to), fromcode_(from)
        {}
@@ -61,7 +66,7 @@ struct IconvProcessor::Impl
        ~Impl()
        {
                if (cd != invalid_cd && iconv_close(cd) == -1)
-                               LYXERR0("Error returned from iconv_close(" << errno << ")");
+                       LYXERR0("Error returned from iconv_close(" << errno << ')');
        }
 
        iconv_t cd;
@@ -88,10 +93,13 @@ IconvProcessor::~IconvProcessor()
 }
 
 
-void IconvProcessor::operator=(IconvProcessor const & other)
+IconvProcessor & IconvProcessor::operator=(IconvProcessor const & other)
 {
-       if (&other != this)
+       if (&other != this) {
+               delete pimpl_;
                pimpl_ = new Impl(other.pimpl_->tocode_, other.pimpl_->fromcode_);
+       }
+       return *this;
 }