* InputDeviceListItem::fDevice was not maintaining it's own memory for the
device path, but instead pointing to memory owned by some device addon instance. * Added TODO in the AddOnManager init code about a possible race condition which I have not varified yet. * Check the return code of BList::RemoveItem() before deleting the item... pure defensive programming. * For the time being, print a warning into the syslog when a device name is registered twice. * When failing to Unflatten() an event, don't continue in the code after deleting it. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28319 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -64,13 +64,25 @@ KeymapMethod InputServer::gKeymapMethod;
|
|||||||
extern "C" _EXPORT BView* instantiate_deskbar_item();
|
extern "C" _EXPORT BView* instantiate_deskbar_item();
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - InputDeviceListItem
|
||||||
|
|
||||||
|
|
||||||
InputDeviceListItem::InputDeviceListItem(BInputServerDevice& serverDevice,
|
InputDeviceListItem::InputDeviceListItem(BInputServerDevice& serverDevice,
|
||||||
input_device_ref& device)
|
const input_device_ref& device)
|
||||||
:
|
:
|
||||||
fServerDevice(&serverDevice),
|
fServerDevice(&serverDevice),
|
||||||
fDevice(device),
|
fDevice(),
|
||||||
fRunning(false)
|
fRunning(false)
|
||||||
{
|
{
|
||||||
|
fDevice.name = strdup(device.name);
|
||||||
|
fDevice.type = device.type;
|
||||||
|
fDevice.cookie = device.cookie;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
InputDeviceListItem::~InputDeviceListItem()
|
||||||
|
{
|
||||||
|
free(fDevice.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -217,6 +229,8 @@ InputServer::InputServer()
|
|||||||
fAddOnManager = new(std::nothrow) ::AddOnManager(SafeMode());
|
fAddOnManager = new(std::nothrow) ::AddOnManager(SafeMode());
|
||||||
if (fAddOnManager != NULL) {
|
if (fAddOnManager != NULL) {
|
||||||
fAddOnManager->Run();
|
fAddOnManager->Run();
|
||||||
|
// TODO: The BLooper thread may already start running here,
|
||||||
|
// is this a problem?
|
||||||
fAddOnManager->LoadState();
|
fAddOnManager->LoadState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1124,8 +1138,8 @@ InputServer::UnregisterDevices(BInputServerDevice& serverDevice,
|
|||||||
|
|
||||||
if (item->ServerDevice() == &serverDevice && item->HasName(device->name)) {
|
if (item->ServerDevice() == &serverDevice && item->HasName(device->name)) {
|
||||||
item->Stop();
|
item->Stop();
|
||||||
fInputDeviceList.RemoveItem(j);
|
if (fInputDeviceList.RemoveItem(j))
|
||||||
delete item;
|
delete item;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1137,8 +1151,8 @@ InputServer::UnregisterDevices(BInputServerDevice& serverDevice,
|
|||||||
|
|
||||||
if (item->ServerDevice() == &serverDevice) {
|
if (item->ServerDevice() == &serverDevice) {
|
||||||
item->Stop();
|
item->Stop();
|
||||||
fInputDeviceList.RemoveItem(i);
|
if (fInputDeviceList.RemoveItem(i))
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1170,6 +1184,7 @@ InputServer::RegisterDevices(BInputServerDevice& serverDevice,
|
|||||||
InputDeviceListItem* item = (InputDeviceListItem*)fInputDeviceList.ItemAt(j);
|
InputDeviceListItem* item = (InputDeviceListItem*)fInputDeviceList.ItemAt(j);
|
||||||
|
|
||||||
if (item->HasName(device->name)) {
|
if (item->HasName(device->name)) {
|
||||||
|
debug_printf("InputServer::RegisterDevices() device_ref already exists: %s\n", device->name);
|
||||||
PRINT(("RegisterDevices found %s\n", device->name));
|
PRINT(("RegisterDevices found %s\n", device->name));
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
@@ -1396,6 +1411,7 @@ InputServer::_EventLoop()
|
|||||||
if ((err = event->Unflatten(buffer)) < 0) {
|
if ((err = event->Unflatten(buffer)) < 0) {
|
||||||
PRINTERR(("[InputServer] Unflatten() error: (0x%lx) %s\n", err, strerror(err)));
|
PRINTERR(("[InputServer] Unflatten() error: (0x%lx) %s\n", err, strerror(err)));
|
||||||
delete event;
|
delete event;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
events.AddItem(event);
|
events.AddItem(event);
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ class BottomlineWindow;
|
|||||||
class InputDeviceListItem {
|
class InputDeviceListItem {
|
||||||
public:
|
public:
|
||||||
InputDeviceListItem(BInputServerDevice& serverDevice,
|
InputDeviceListItem(BInputServerDevice& serverDevice,
|
||||||
input_device_ref& device);
|
const input_device_ref& device);
|
||||||
|
~InputDeviceListItem();
|
||||||
|
|
||||||
void Start();
|
void Start();
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|||||||
Reference in New Issue
Block a user