From ac66f539e66377bcc8e26d19811bbe1fe28f3808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Thu, 9 Aug 2007 22:31:01 +0000 Subject: [PATCH] added a lock around keymap uses to avoid a reload in the middle of the key event process this fixes bug #1177 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21881 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../devices/keyboard/KeyboardInputDevice.cpp | 9 +++++++-- .../input_server/devices/keyboard/KeyboardInputDevice.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp index 66fec0521b..c1a01f8db1 100644 --- a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp +++ b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp @@ -8,6 +8,7 @@ #include "kb_mouse_driver.h" #include +#include #include #include #include @@ -365,7 +366,8 @@ get_short_name(const char *longName) KeyboardInputDevice::KeyboardInputDevice() : - fTMWindow(NULL) + fTMWindow(NULL), + fKeymapLock("keymap lock") { #if DEBUG if (sLogFile == NULL) @@ -428,7 +430,8 @@ KeyboardInputDevice::_InitFromSettings(void *cookie, uint32 opcode) if (opcode == 0 || opcode == B_KEY_MAP_CHANGED - || opcode == B_KEY_LOCKS_CHANGED) { + || opcode == B_KEY_LOCKS_CHANGED) { + BAutolock lock(fKeymapLock); fKeymap.LoadCurrent(); device->modifiers = fKeymap.Locks(); _SetLeds(device); @@ -697,6 +700,8 @@ KeyboardInputDevice::_DeviceWatcher(void *arg) } } + BAutolock lock(owner->fKeymapLock); + uint32 modifiers = keymap->Modifier(keycode); if (modifiers && (!(modifiers & (B_CAPS_LOCK | B_NUM_LOCK | B_SCROLL_LOCK)) diff --git a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.h b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.h index fa769ce798..8ce254b05b 100644 --- a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.h +++ b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.h @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -74,6 +75,7 @@ class KeyboardInputDevice : public BInputServerDevice { BList fDevices; Keymap fKeymap; TMWindow *fTMWindow; + BLocker fKeymapLock; }; extern "C" BInputServerDevice *instantiate_input_device();