]> git.saurik.com Git - wxWidgets.git/commitdiff
Make wxMBConv_iconv MT-safe by not using wxString in it.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 31 Oct 2010 13:41:03 +0000 (13:41 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 31 Oct 2010 13:41:03 +0000 (13:41 +0000)
Use just "char *" for wxMBConv_iconv::m_name to avoid MT-safety problems
related to using a wxString (which is not always MT-safe) from multiple
threads.

See #12630.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65968 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/strconv.cpp

index f46ccf449845b8d68c0643bd62229697f1bd091d..fb90c2b03b5fb261b3dcaec87f6503610facbdb1 100644 (file)
@@ -2113,7 +2113,7 @@ public:
 
     virtual wxMBConv *Clone() const
     {
 
     virtual wxMBConv *Clone() const
     {
-        wxMBConv_iconv *p = new wxMBConv_iconv(m_name.ToAscii());
+        wxMBConv_iconv *p = new wxMBConv_iconv(m_name);
         p->m_minMBCharWidth = m_minMBCharWidth;
         return p;
     }
         p->m_minMBCharWidth = m_minMBCharWidth;
         return p;
     }
@@ -2143,7 +2143,7 @@ private:
 
 
     // name of the encoding handled by this conversion
 
 
     // name of the encoding handled by this conversion
-    wxString m_name;
+    const char *m_name;
 
     // cached result of GetMBNulLen(); set to 0 meaning "unknown"
     // initially
 
     // cached result of GetMBNulLen(); set to 0 meaning "unknown"
     // initially
@@ -2167,7 +2167,7 @@ wxString wxMBConv_iconv::ms_wcCharsetName;
 bool wxMBConv_iconv::ms_wcNeedsSwap = false;
 
 wxMBConv_iconv::wxMBConv_iconv(const char *name)
 bool wxMBConv_iconv::ms_wcNeedsSwap = false;
 
 wxMBConv_iconv::wxMBConv_iconv(const char *name)
-              : m_name(name)
+              : m_name(wxStrdup(name))
 {
     m_minMBCharWidth = 0;
 
 {
     m_minMBCharWidth = 0;
 
@@ -2284,6 +2284,8 @@ wxMBConv_iconv::wxMBConv_iconv(const char *name)
 
 wxMBConv_iconv::~wxMBConv_iconv()
 {
 
 wxMBConv_iconv::~wxMBConv_iconv()
 {
+    free(const_cast<char *>(m_name));
+
     if ( m2w != ICONV_T_INVALID )
         iconv_close(m2w);
     if ( w2m != ICONV_T_INVALID )
     if ( m2w != ICONV_T_INVALID )
         iconv_close(m2w);
     if ( w2m != ICONV_T_INVALID )