Initialize ffd to -1 in the constructor otherwise many checks may fail
afterwards, and BJoystick won't work. Also reset it to -1 in the destructor for symmetry. Found by Carwyn Jones. Thanks! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40900 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -49,6 +49,7 @@ LOG(const char *fmt, ...)
|
||||
BJoystick::BJoystick()
|
||||
:
|
||||
fBeBoxMode(false),
|
||||
ffd(-1),
|
||||
fDevices(new BList),
|
||||
fJoystickInfo(new _joystick_info())
|
||||
{
|
||||
@@ -61,8 +62,10 @@ BJoystick::BJoystick()
|
||||
|
||||
BJoystick::~BJoystick()
|
||||
{
|
||||
if (ffd >= 0)
|
||||
if (ffd >= 0) {
|
||||
close(ffd);
|
||||
ffd = -1;
|
||||
}
|
||||
|
||||
for (int32 count = fDevices->CountItems() - 1; count >= 0; count--) {
|
||||
free(fDevices->RemoveItem(count));
|
||||
@@ -132,17 +135,18 @@ void
|
||||
BJoystick::Close(void)
|
||||
{
|
||||
CALLED();
|
||||
if (ffd >= 0)
|
||||
if (ffd >= 0) {
|
||||
close(ffd);
|
||||
ffd = -1;
|
||||
ffd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BJoystick::ScanDevices(bool use_disabled)
|
||||
BJoystick::ScanDevices(bool useDisabled)
|
||||
{
|
||||
CALLED();
|
||||
if (use_disabled) {
|
||||
if (useDisabled) {
|
||||
_BJoystickTweaker temp(*this);
|
||||
temp.scan_including_disabled();
|
||||
}
|
||||
@@ -228,6 +232,7 @@ BJoystick::CountButtons()
|
||||
return fJoystickInfo->num_buttons;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BJoystick::GetControllerModule(BString *out_name)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user