Code hardening

This commit is contained in:
Bertrand Songis
2019-10-23 14:38:37 +02:00
parent 29edeb1967
commit 303bb7e381
+22 -9
View File
@@ -97,22 +97,35 @@ void FormGroup::addField(FormField * field)
void FormGroup::setFocus(uint8_t flag) void FormGroup::setFocus(uint8_t flag)
{ {
TRACE_WINDOWS("FormGroup::setFocus(%d)", flag);
if (windowFlags & FORM_FORWARD_FOCUS) { if (windowFlags & FORM_FORWARD_FOCUS) {
switch (flag) { switch (flag) {
case SET_FOCUS_FIRST: case SET_FOCUS_FIRST:
first->setFocus(SET_FOCUS_FIRST); if (first)
first->setFocus(SET_FOCUS_FIRST);
break; break;
case SET_FOCUS_BACKWARD: case SET_FOCUS_BACKWARD:
if (focusWindow == first) if (focusWindow == first) {
previous->setFocus(SET_FOCUS_BACKWARD); if (previous == this)
else last->setFocus(SET_FOCUS_BACKWARD);
last->setFocus(SET_FOCUS_BACKWARD); else if (previous)
previous->setFocus(SET_FOCUS_BACKWARD);
}
else {
if (last)
last->setFocus(SET_FOCUS_BACKWARD);
}
break; break;
default: default:
if (focusWindow == previous) if (focusWindow == previous) {
first->setFocus(); if (first)
else first->setFocus();
next->setFocus(); }
else {
if (next)
next->setFocus();
}
break; break;
} }
} }