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
This commit is contained in:
Jérôme Duval 2007-08-09 22:31:01 +00:00
parent 6f922173d2
commit ac66f539e6
2 changed files with 9 additions and 2 deletions

View File

@ -8,6 +8,7 @@
#include "kb_mouse_driver.h"
#include <Application.h>
#include <Autolock.h>
#include <Directory.h>
#include <Entry.h>
#include <NodeMonitor.h>
@ -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))

View File

@ -12,6 +12,7 @@
#include <Handler.h>
#include <InputServerDevice.h>
#include <Locker.h>
#include <List.h>
#include <stdio.h>
@ -74,6 +75,7 @@ class KeyboardInputDevice : public BInputServerDevice {
BList fDevices;
Keymap fKeymap;
TMWindow *fTMWindow;
BLocker fKeymapLock;
};
extern "C" BInputServerDevice *instantiate_input_device();