summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Morph2022-07-24 07:27:10 -0400
committerGravatar Morph2022-07-24 07:27:41 -0400
commitd7d09355e723270870fde85c1000988bfd48f2ca (patch)
treea55f6ec1ec25f8b69570050dd85baf58685feaf3 /src
parentapplet/swkbd: Implement optional symbol keys (diff)
downloadyuzu-d7d09355e723270870fde85c1000988bfd48f2ca.tar.gz
yuzu-d7d09355e723270870fde85c1000988bfd48f2ca.tar.xz
yuzu-d7d09355e723270870fde85c1000988bfd48f2ca.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/applets/qt_software_keyboard.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/yuzu/applets/qt_software_keyboard.cpp b/src/yuzu/applets/qt_software_keyboard.cpp
index 91dca2760..e60506197 100644
--- a/src/yuzu/applets/qt_software_keyboard.cpp
+++ b/src/yuzu/applets/qt_software_keyboard.cpp
@@ -1401,6 +1401,10 @@ void QtSoftwareKeyboardDialog::MoveButtonDirection(Direction direction) {
1401 } 1401 }
1402 }; 1402 };
1403 1403
1404 // Store the initial row and column.
1405 const auto initial_row = row;
1406 const auto initial_column = column;
1407
1404 switch (bottom_osk_index) { 1408 switch (bottom_osk_index) {
1405 case BottomOSKIndex::LowerCase: 1409 case BottomOSKIndex::LowerCase:
1406 case BottomOSKIndex::UpperCase: { 1410 case BottomOSKIndex::UpperCase: {
@@ -1411,6 +1415,11 @@ void QtSoftwareKeyboardDialog::MoveButtonDirection(Direction direction) {
1411 auto* curr_button = keyboard_buttons[index][row][column]; 1415 auto* curr_button = keyboard_buttons[index][row][column];
1412 1416
1413 while (!curr_button || !curr_button->isEnabled() || curr_button == prev_button) { 1417 while (!curr_button || !curr_button->isEnabled() || curr_button == prev_button) {
1418 // If we returned back to where we started from, break the loop.
1419 if (row == initial_row && column == initial_column) {
1420 break;
1421 }
1422
1414 move_direction(NUM_ROWS_NORMAL, NUM_COLUMNS_NORMAL); 1423 move_direction(NUM_ROWS_NORMAL, NUM_COLUMNS_NORMAL);
1415 curr_button = keyboard_buttons[index][row][column]; 1424 curr_button = keyboard_buttons[index][row][column];
1416 } 1425 }
@@ -1425,6 +1434,11 @@ void QtSoftwareKeyboardDialog::MoveButtonDirection(Direction direction) {
1425 auto* curr_button = numberpad_buttons[row][column]; 1434 auto* curr_button = numberpad_buttons[row][column];
1426 1435
1427 while (!curr_button || !curr_button->isEnabled() || curr_button == prev_button) { 1436 while (!curr_button || !curr_button->isEnabled() || curr_button == prev_button) {
1437 // If we returned back to where we started from, break the loop.
1438 if (row == initial_row && column == initial_column) {
1439 break;
1440 }
1441
1428 move_direction(NUM_ROWS_NUMPAD, NUM_COLUMNS_NUMPAD); 1442 move_direction(NUM_ROWS_NUMPAD, NUM_COLUMNS_NUMPAD);
1429 curr_button = numberpad_buttons[row][column]; 1443 curr_button = numberpad_buttons[row][column];
1430 } 1444 }