]> git.lyx.org Git - features.git/commitdiff
fix #7240 Random crashes: iconv() is not thread save
authorPeter Kümmel <syntheticpp@gmx.net>
Sat, 15 Jan 2011 19:52:55 +0000 (19:52 +0000)
committerPeter Kümmel <syntheticpp@gmx.net>
Sat, 15 Jan 2011 19:52:55 +0000 (19:52 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37217 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/unicode.cpp

index 26c6a239d759d5a355712ccccadb6afa0839092c..0e773f5327d67d0a1630ec2e66b9a1f62a0d5ec8 100644 (file)
@@ -25,6 +25,8 @@
 #include <ostream>
 #include <string>
 
+#include <QMutexLocker>
+
 using namespace std;
 
 namespace {
@@ -64,6 +66,8 @@ struct IconvProcessor::Impl
        iconv_t cd;
        string tocode_;
        string fromcode_;
+
+       QMutex mutex_; // iconv() is not thread save
 };
 
 
@@ -120,6 +124,8 @@ bool IconvProcessor::init()
 int IconvProcessor::convert(char const * buf, size_t buflen,
                char * outbuf, size_t maxoutsize)
 {
+       QMutexLocker lock(&pimpl_->mutex_);
+
        if (buflen == 0)
                return 0;