Patch by Clemens Zeidler: Move debugging output after the check for fConnected

in UpdateSettings() to avoid a crash when there is no TouchPad at all.
Changes by myself: Adapted coding style and added a comment to ConnectToTouchPad()
on why the loop is not exited as soon as the device is found.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28457 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2008-11-02 10:46:50 +00:00
parent 19d40f9eb7
commit 2c4a095da8
+24 -27
View File
@@ -17,18 +17,18 @@ TouchpadPref::TouchpadPref()
ConnectToTouchPad();
if(LoadSettings() != B_OK){
if (LoadSettings() != B_OK)
Defaults();
}
fStartSettings = fSettings;
}
TouchpadPref::~TouchpadPref()
{
if(fConnected){
if (fConnected)
delete fTouchPad;
}
SaveSettings();
}
@@ -43,10 +43,10 @@ TouchpadPref::Revert()
status_t
TouchpadPref::UpdateSettings()
{
LOG("UpdateSettings of device %s\n", fTouchPad->Name());
if(!fConnected){
if (!fConnected)
return B_ERROR;
}
LOG("UpdateSettings of device %s\n", fTouchPad->Name());
BMessage msg;
msg.AddBool("scroll_twofinger", fSettings.scroll_twofinger);
@@ -57,6 +57,7 @@ TouchpadPref::UpdateSettings()
msg.AddInt16("scroll_ystepsize", fSettings.scroll_ystepsize);
msg.AddInt8("scroll_acceleration", fSettings.scroll_acceleration);
msg.AddInt8("tapgesture_sensibility", fSettings.tapgesture_sensibility);
return fTouchPad->Control(MS_SET_TOUCHPAD_SETTINGS, &msg);
}
@@ -74,8 +75,8 @@ TouchpadPref::GetSettingsPath(BPath &path)
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
if (status < B_OK)
return status;
path.Append(TOUCHPAD_SETTINGS_FILE);
return B_OK;
return path.Append(TOUCHPAD_SETTINGS_FILE);
}
@@ -93,18 +94,17 @@ TouchpadPref::LoadSettings()
return status;
if (settingsFile.Read(&fSettings, sizeof(touchpad_settings))
!= sizeof(touchpad_settings))
{
!= sizeof(touchpad_settings)) {
LOG("failed to load settings\n");
return B_ERROR;
}
if (settingsFile.Read(&fWindowPosition, sizeof(BPoint))
!= sizeof(BPoint))
{
!= sizeof(BPoint)) {
LOG("failed to load settings\n");
return B_ERROR;
}
return B_OK;
}
@@ -123,18 +123,17 @@ TouchpadPref::SaveSettings()
return status;
if (settingsFile.Write(&fSettings, sizeof(touchpad_settings))
!= sizeof(touchpad_settings))
{
!= sizeof(touchpad_settings)) {
LOG("can't save settings\n");
return B_ERROR;
}
if (settingsFile.Write(&fWindowPosition, sizeof(BPoint))
!= sizeof(BPoint))
{
!= sizeof(BPoint)) {
LOG("can't save window position\n");
return B_ERROR;
}
return B_OK;
}
@@ -144,30 +143,28 @@ TouchpadPref::ConnectToTouchPad()
{
BList devList;
status_t status = get_input_devices(&devList);
if(status != B_OK){
if (status != B_OK)
return status;
}
int32 i = 0;
while (true) {
BInputDevice* dev = (BInputDevice*)devList.ItemAt(i);
if(!dev)
if (dev == NULL)
break;
i++;
LOG("input device %s\n", dev->Name());
bool isTouchpad = false;
BString name = dev->Name();
if(name.FindFirst("Touchpad") != B_ERROR
if (name.FindFirst("Touchpad") >= 0
&& dev->Type() == B_POINTING_DEVICE
&& !fConnected)
{
isTouchpad = true;
&& !fConnected) {
fConnected = true;
fTouchPad = dev;
}
else{
// Don't bail out here, since we need to delete the other devices
// yet.
} else {
delete dev;
}
}