forked from ShuriZma/suyu
qt_software_keyboard: Fix infinite loop when moving between buttons
There was a bug where, when using the numeric keyboard, moving between buttons resulted in an infinite loop, resulting in a stuck state. This was due to prev_button being the only one enabled in that row or column, causing the condition in the while loop to always be true. To fix this, detect whether we have returned to that initial row/column and break out of the loop.
This commit is contained in:
parent
bee823db3a
commit
d7d09355e7
|
@ -1401,6 +1401,10 @@ void QtSoftwareKeyboardDialog::MoveButtonDirection(Direction direction) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Store the initial row and column.
|
||||||
|
const auto initial_row = row;
|
||||||
|
const auto initial_column = column;
|
||||||
|
|
||||||
switch (bottom_osk_index) {
|
switch (bottom_osk_index) {
|
||||||
case BottomOSKIndex::LowerCase:
|
case BottomOSKIndex::LowerCase:
|
||||||
case BottomOSKIndex::UpperCase: {
|
case BottomOSKIndex::UpperCase: {
|
||||||
|
@ -1411,6 +1415,11 @@ void QtSoftwareKeyboardDialog::MoveButtonDirection(Direction direction) {
|
||||||
auto* curr_button = keyboard_buttons[index][row][column];
|
auto* curr_button = keyboard_buttons[index][row][column];
|
||||||
|
|
||||||
while (!curr_button || !curr_button->isEnabled() || curr_button == prev_button) {
|
while (!curr_button || !curr_button->isEnabled() || curr_button == prev_button) {
|
||||||
|
// If we returned back to where we started from, break the loop.
|
||||||
|
if (row == initial_row && column == initial_column) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
move_direction(NUM_ROWS_NORMAL, NUM_COLUMNS_NORMAL);
|
move_direction(NUM_ROWS_NORMAL, NUM_COLUMNS_NORMAL);
|
||||||
curr_button = keyboard_buttons[index][row][column];
|
curr_button = keyboard_buttons[index][row][column];
|
||||||
}
|
}
|
||||||
|
@ -1425,6 +1434,11 @@ void QtSoftwareKeyboardDialog::MoveButtonDirection(Direction direction) {
|
||||||
auto* curr_button = numberpad_buttons[row][column];
|
auto* curr_button = numberpad_buttons[row][column];
|
||||||
|
|
||||||
while (!curr_button || !curr_button->isEnabled() || curr_button == prev_button) {
|
while (!curr_button || !curr_button->isEnabled() || curr_button == prev_button) {
|
||||||
|
// If we returned back to where we started from, break the loop.
|
||||||
|
if (row == initial_row && column == initial_column) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
move_direction(NUM_ROWS_NUMPAD, NUM_COLUMNS_NUMPAD);
|
move_direction(NUM_ROWS_NUMPAD, NUM_COLUMNS_NUMPAD);
|
||||||
curr_button = numberpad_buttons[row][column];
|
curr_button = numberpad_buttons[row][column];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue