[Bf-blender-cvs] [e385bdb228a] master: Fix a bug in the T34039 hack in case when a modifier key is not mapped.

Alexander Gavrilov noreply at git.blender.org
Sat Nov 16 09:57:34 CET 2019


Commit: e385bdb228acd3a4c64a886e6fee39f5fcb3cebf
Author: Alexander Gavrilov
Date:   Sat Nov 16 11:56:38 2019 +0300
Branches: master
https://developer.blender.org/rBe385bdb228acd3a4c64a886e6fee39f5fcb3cebf

Fix a bug in the T34039 hack in case when a modifier key is not mapped.

In order to recover from a transient Focus Out - Focus In disruption
in the middle of a shortcut, which can be caused by certain window
managers, Blender has code that checks which modifier keys are pressed
after Focus In and restores the modifier state based on that.

If one of the Ctrl, Shift, Alt, Super keys is not mapped anywhere
in the active keyboard layout, XKeysymToKeycode returns the invalid
zero keycode, and reading the key state produces garbage, which can
cause an invalid modifier state. Check the return value to avoid this.

===================================================================

M	intern/ghost/intern/GHOST_SystemX11.cpp

===================================================================

diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 1ca412fbccc..cb2a04a8a87 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -700,7 +700,7 @@ bool GHOST_SystemX11::processEvents(bool waitForEvent)
 
               for (int i = 0; i < (sizeof(modifiers) / sizeof(*modifiers)); i++) {
                 KeyCode kc = XKeysymToKeycode(m_display, modifiers[i]);
-                if (((xevent.xkeymap.key_vector[kc >> 3] >> (kc & 7)) & 1) != 0) {
+                if (kc != 0 && ((xevent.xkeymap.key_vector[kc >> 3] >> (kc & 7)) & 1) != 0) {
                   pushEvent(new GHOST_EventKey(getMilliSeconds(),
                                                GHOST_kEventKeyDown,
                                                window,



More information about the Bf-blender-cvs mailing list