Browse Source

Fix crash when typing unicode characters above 7fff into text field

Can be reproduced when typing Shift+AltGr+5 into a DirectEntry on macOS.
rdb 7 năm trước cách đây
mục cha
commit
95bffa8503

+ 1 - 1
panda/src/event/buttonEvent.I

@@ -41,7 +41,7 @@ ButtonEvent(ButtonHandle button, ButtonEvent::Type type, double time) :
  *
  */
 INLINE ButtonEvent::
-ButtonEvent(short keycode, double time) :
+ButtonEvent(int keycode, double time) :
   _button(ButtonHandle::none()),
   _keycode(keycode),
   _highlight_start(0),

+ 2 - 2
panda/src/event/buttonEvent.cxx

@@ -84,7 +84,7 @@ write_datagram(Datagram &dg) const {
     break;
 
   case T_keystroke:
-    dg.add_int16(_keycode);
+    dg.add_uint16(_keycode);
     break;
 
   case T_candidate:
@@ -119,7 +119,7 @@ read_datagram(DatagramIterator &scan) {
     break;
 
   case T_keystroke:
-    _keycode = scan.get_int16();
+    _keycode = scan.get_uint16();
     break;
 
   case T_candidate:

+ 2 - 2
panda/src/event/buttonEvent.h

@@ -86,7 +86,7 @@ public:
 
   INLINE ButtonEvent();
   INLINE ButtonEvent(ButtonHandle button, Type type, double time = ClockObject::get_global_clock()->get_frame_time());
-  INLINE ButtonEvent(short keycode, double time = ClockObject::get_global_clock()->get_frame_time());
+  INLINE ButtonEvent(int keycode, double time = ClockObject::get_global_clock()->get_frame_time());
   INLINE ButtonEvent(const wstring &candidate_string, size_t highlight_start,
                      size_t highlight_end, size_t cursor_pos);
   INLINE ButtonEvent(const ButtonEvent &copy);
@@ -109,7 +109,7 @@ public:
 
   // _keycode will be filled in if type is T_keystroke.  It will be the
   // Unicode character that was typed.
-  short _keycode;
+  int _keycode;
 
   // _candidate_string will be filled in if type is T_candidate.
   wstring _candidate_string;

+ 1 - 1
panda/src/tform/mouseWatcherParameter.h

@@ -74,7 +74,7 @@ PUBLISHED:
 
 public:
   ButtonHandle _button;
-  short _keycode;
+  int _keycode;
   wstring _candidate_string;
   size_t _highlight_start;
   size_t _highlight_end;