]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/string.cpp
use HandleWindowEvent() in Close() as it can be called from a GTK+ callback (#9565)
[wxWidgets.git] / src / common / string.cpp
index a287759822baabf199d1bc79f2845cba128072b3..c3bc9331cbe9ae8ab64e6dce94104d3eb27de2cd 100644 (file)
@@ -369,6 +369,9 @@ wxString::SubstrBufFromMB wxString::ConvertStr(const char *psz, size_t nLength,
         // UTF-8 sequence and psz may be invalid:
         if ( wxStringOperations::IsValidUtf8String(psz, nLength) )
         {
+            // we must pass the real string length to SubstrBufFromMB ctor
+            if ( nLength == npos )
+                nLength = psz ? strlen(psz) : 0;
             return SubstrBufFromMB(wxCharBuffer::CreateNonOwned(psz), nLength);
         }
         // else: do the roundtrip through wchar_t*
@@ -1236,17 +1239,17 @@ size_t wxString::Replace(const wxString& strOld,
 
     size_t uiCount = 0;   // count of replacements made
 
-    size_t uiOldLen = strOld.length();
-    size_t uiNewLen = strNew.length();
+    const size_t uiOldLen = strOld.m_impl.length();
+    const size_t uiNewLen = strNew.m_impl.length();
 
-    for ( size_t dwPos = 0; dwPos < length(); )
+    for ( size_t dwPos = 0; dwPos < m_impl.length(); )
     {
-        dwPos = find(strOld, dwPos);
+        dwPos = m_impl.find(strOld.m_impl, dwPos);
         if ( dwPos == npos )
             break;
 
         // replace this occurance of the old string with the new one
-        replace(dwPos, uiOldLen, strNew, uiNewLen);
+        m_impl.replace(dwPos, uiOldLen, strNew.m_impl);
 
         // move up pos past the string that was replaced
         dwPos += uiNewLen;