- fix for error with utf8 textinput for buttons
[blender.git] / source / blender / windowmanager / intern / wm_event_system.c
index 3e9bce651a8bc445bd61fc705adee60a98ba8f9d..09ec8bf84ba0b03ee0804d5c30f5a21bd25fa672 100644 (file)
@@ -454,11 +454,12 @@ void WM_event_print(wmEvent *event)
 
                printf("wmEvent - type:%d/%s, val:%d/%s, "
                           "shift:%d, ctrl:%d, alt:%d, oskey:%d, keymodifier:%d, "
-                          "mouse:(%d,%d), ascii:'%c', utf8:'%.6s', "
+                          "mouse:(%d,%d), ascii:'%c', utf8:'%.*s', "
                           "keymap_idname:%s, pointer:%p\n",
                           event->type, type_id, event->val, val_id,
                           event->shift, event->ctrl, event->alt, event->oskey, event->keymodifier,
-                          event->x, event->y, event->ascii, event->utf8_buf,
+                          event->x, event->y, event->ascii,
+                      BLI_str_utf8_size(event->utf8_buf), event->utf8_buf,
                           event->keymap_idname, (void *)event);
        }
        else {
@@ -2629,6 +2630,13 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
                                /* TODO. should this also zero utf8?, dont for now, campbell */
                        }
 
+                       if (event.utf8_buf[0]) {
+                               if (BLI_str_utf8_size(event.utf8_buf) == -1) {
+                                       printf("%s: ghost detected an invalid unicode character '%d'!\n", __func__, (int)(unsigned char)event.utf8_buf[0]);
+                                       event.utf8_buf[0]= '\0';
+                               }
+                       }
+
                        /* modifiers */
                        /* assigning both first and second is strange - campbell */
                        switch(event.type) {