Some old changes I forgot to commit... BInputServerDevice::InitCheck()

now checks if the fOwner allocation went fine (and returns B_NO_MEMORY 
in case it didn't). Since it can fail, inherited classes should call it 
as well (I modified MouseInputDevice's and KeyboardInputDevice's 
versions for now)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23106 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2007-12-10 21:20:25 +00:00
parent f6c512f8e3
commit d246d9be88
3 changed files with 15 additions and 6 deletions
@@ -445,6 +445,10 @@ status_t
KeyboardInputDevice::InitCheck() KeyboardInputDevice::InitCheck()
{ {
CALLED(); CALLED();
status_t status = BInputServerDevice::InitCheck();
if (status < B_OK)
return status;
// TODO: this doesn't belong here! // TODO: this doesn't belong here!
_RecursiveScan(kKeyboardDevicesDirectory); _RecursiveScan(kKeyboardDevicesDirectory);
@@ -1,9 +1,11 @@
/* /*
* Copyright 2004-2006, Haiku. * Copyright 2004-2007, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Stefano Ceccherini * Stefano Ceccherini ([email protected])
* Jérôme Duval
* Axel Dörfler, [email protected]
*/ */
@@ -97,7 +99,7 @@ LOG(const char *fmt, ...)
extern "C" BInputServerDevice * extern "C" BInputServerDevice *
instantiate_input_device() instantiate_input_device()
{ {
return new MouseInputDevice(); return new (std::nothrow) MouseInputDevice();
} }
@@ -443,7 +445,7 @@ status_t
MouseInputDevice::InitCheck() MouseInputDevice::InitCheck()
{ {
CALLED(); CALLED();
return B_OK; return BInputServerDevice::InitCheck();
} }
+5 -2
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2005, Haiku, Inc. All Rights Reserved. * Copyright 2002-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -8,10 +8,11 @@
#include <InputServerDevice.h> #include <InputServerDevice.h>
#include <new>
BInputServerDevice::BInputServerDevice() BInputServerDevice::BInputServerDevice()
{ {
fOwner = new _BDeviceAddOn_(this); fOwner = new (std::nothrow) _BDeviceAddOn_(this);
} }
@@ -27,6 +28,8 @@ BInputServerDevice::~BInputServerDevice()
status_t status_t
BInputServerDevice::InitCheck() BInputServerDevice::InitCheck()
{ {
if (fOwner == NULL)
return B_NO_MEMORY;
return B_OK; return B_OK;
} }