]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/carbon/textctrl.cpp
add missing Detach() after r56863 changes (thanks troelsk)
[wxWidgets.git] / src / osx / carbon / textctrl.cpp
index 55fb6f4178a28303e0e712227e3a90f152c4e911..fc308b671229bb40f6fa7f26f9abf725852c130f 100644 (file)
@@ -950,7 +950,7 @@ void wxMacMLTEControl::SetBackgroundColour(const wxColour& col )
 
 static inline int wxConvertToTXN(int x)
 {
-    return wx_static_cast(int, x / 254.0 * 72 + 0.5);
+    return static_cast<int>(x / 254.0 * 72 + 0.5);
 }
 
 void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr& style , long from , long to )
@@ -1371,8 +1371,10 @@ void wxMacMLTEControl::SetTXNData( const wxString& st, TXNOffset start, TXNOffse
 #else
     wxMBConvUTF16 converter ;
     ByteCount byteBufferLen = converter.WC2MB( NULL, st.wc_str(), 0 ) ;
-    UniChar *unibuf = (UniChar*)malloc( byteBufferLen ) ;
-    converter.WC2MB( (char*)unibuf, st.wc_str(), byteBufferLen ) ;
+    wxASSERT_MSG( byteBufferLen != wxCONV_FAILED,
+                  _T("Conversion to UTF-16 unexpectedly failed") );
+    UniChar *unibuf = (UniChar*)malloc( byteBufferLen + 2 ) ; // 2 for NUL in UTF-16
+    converter.WC2MB( (char*)unibuf, st.wc_str(), byteBufferLen + 2 ) ;
     TXNSetData( m_txn, kTXNUnicodeTextData, (void*)unibuf, byteBufferLen, start, end ) ;
     free( unibuf ) ;
 #endif
@@ -1907,6 +1909,7 @@ wxMacMLTEClassicControl::wxMacMLTEClassicControl( wxTextCtrl *wxPeer,
         MAC_WXHWND(wxPeer->GetParent()->MacGetTopLevelWindowRef()),
         &bounds, featureSet, &m_controlRef );
     verify_noerr( err );
+    SetControlReference( m_controlRef , (URefCon) wxPeer );
 
     DoCreate();