]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/window.cpp
obsolete ref to checklistbox
[wxWidgets.git] / src / mac / carbon / window.cpp
index c015cea8ee974736e946c152934d10f00d60aab9..674afb8bd40e161797a98c9be46fc045f33cf30e 100644 (file)
 
 #include "wx/wxprec.h"
 
-#include "wx/menu.h"
 #include "wx/window.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/log.h"
+    #include "wx/app.h"
+#endif
+
+#include "wx/menu.h"
 #include "wx/dc.h"
 #include "wx/dcclient.h"
 #include "wx/utils.h"
-#include "wx/app.h"
 #include "wx/panel.h"
 #include "wx/layout.h"
 #include "wx/dialog.h"
@@ -30,7 +35,6 @@
 #include "wx/statusbr.h"
 #include "wx/menuitem.h"
 #include "wx/spinctrl.h"
-#include "wx/log.h"
 #include "wx/geometry.h"
 #include "wx/textctrl.h"
 
@@ -504,19 +508,20 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even
     UniChar buf[2] ;
     if ( GetEventParameter( event, kEventParamTextInputSendText, typeUnicodeText, NULL, 0 , &dataSize, NULL ) == noErr )
     {
-        numChars = dataSize / sizeof( UniChar) ;
+        numChars = dataSize / sizeof( UniChar) + 1;
         charBuf = buf ;
 
-        if ( dataSize > sizeof(buf) )
+        if ( (size_t) numChars * 2 > sizeof(buf) )
             charBuf = new UniChar[ numChars ] ;
         else
             charBuf = buf ;
 
         uniChars = new wchar_t[ numChars ] ;
         GetEventParameter( event, kEventParamTextInputSendText, typeUnicodeText, NULL, dataSize , NULL , charBuf ) ;
+        charBuf[ numChars - 1 ] = 0;
 #if SIZEOF_WCHAR_T == 2
         uniChars = (wchar_t*) charBuf ;
-        memcpy( uniChars , charBuf , dataSize ) ;
+        memcpy( uniChars , charBuf , numChars * 2 ) ;
 #else
         // the resulting string will never have more chars than the utf16 version, so this is safe
         wxMBConvUTF16 converter ;