From 95bffa8503714ba84091893adeb97c6557183afa Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 29 Mar 2018 14:17:39 +0200 Subject: [PATCH] Fix crash when typing unicode characters above 7fff into text field Can be reproduced when typing Shift+AltGr+5 into a DirectEntry on macOS. --- panda/src/event/buttonEvent.I | 2 +- panda/src/event/buttonEvent.cxx | 4 ++-- panda/src/event/buttonEvent.h | 4 ++-- panda/src/tform/mouseWatcherParameter.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/panda/src/event/buttonEvent.I b/panda/src/event/buttonEvent.I index 16c68cc0bc..41bea9f2d5 100644 --- a/panda/src/event/buttonEvent.I +++ b/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), diff --git a/panda/src/event/buttonEvent.cxx b/panda/src/event/buttonEvent.cxx index 7353ce7e54..38dbbffb6a 100644 --- a/panda/src/event/buttonEvent.cxx +++ b/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: diff --git a/panda/src/event/buttonEvent.h b/panda/src/event/buttonEvent.h index e37c2fe2ad..d2e2b82176 100644 --- a/panda/src/event/buttonEvent.h +++ b/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 ©); @@ -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; diff --git a/panda/src/tform/mouseWatcherParameter.h b/panda/src/tform/mouseWatcherParameter.h index bacb2a805b..1da5dcfc45 100644 --- a/panda/src/tform/mouseWatcherParameter.h +++ b/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;