Author: kuemmel
Date: Sat Jan 15 20:52:55 2011
New Revision: 37217
URL: http://www.lyx.org/trac/changeset/37217
Log:
fix #7240 Random crashes: iconv() is not thread save
Modified:
lyx-devel/trunk/src/support/unicode.cpp
Modified: lyx-devel/trunk/src/support/unicode.cpp
==============================================================================
--- lyx-devel/trunk/src/support/unicode.cpp Sat Jan 15 13:09:23 2011
(r37216)
+++ lyx-devel/trunk/src/support/unicode.cpp Sat Jan 15 20:52:55 2011
(r37217)
@@ -25,6 +25,8 @@
#include <ostream>
#include <string>
+#include <QMutexLocker>
+
using namespace std;
namespace {
@@ -64,6 +66,8 @@
iconv_t cd;
string tocode_;
string fromcode_;
+
+ QMutex mutex_; // iconv() is not thread save
};
@@ -120,6 +124,8 @@
int IconvProcessor::convert(char const * buf, size_t buflen,
char * outbuf, size_t maxoutsize)
{
+ QMutexLocker lock(&pimpl_->mutex_);
+
if (buflen == 0)
return 0;