diff options
author | Alexander Gavriliuk <alexandrgproductengine@lindenlab.com> | 2024-10-09 16:21:50 +0200 |
---|---|---|
committer | Guru <alexandrgproductengine@lindenlab.com> | 2024-10-09 22:45:29 +0200 |
commit | a9dfb9d918fe12851ef93110baa149e1c49d2efa (patch) | |
tree | 56b621624f4cfbf2be40ba979825bc18b7b82fff /indra/llui | |
parent | 7b6baea0f6c9c4c9a4f69fdbed4d11f0d5a80018 (diff) |
#2696 The viewer crashes on gestures floater (fix navigation)
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llscrolllistctrl.cpp | 87 |
1 files changed, 43 insertions, 44 deletions
diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index ddd1d81cb4..8093536868 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -1105,38 +1105,32 @@ S32 LLScrollListCtrl::getItemIndex( const LLUUID& target_id ) const void LLScrollListCtrl::selectPrevItem( bool extend_selection) { + updateSort(); + LLScrollListItem* prev_item = NULL; - if (!getFirstSelected()) - { - // select last item - selectNthItem(getItemCount() - 1); - } - else + for (LLScrollListItem* item : mItemList) { - updateSort(); - - item_list::iterator iter; - for (LLScrollListItem* cur_item : mItemList) + if (item->getSelected()) { - if (cur_item->getSelected()) - { - if (prev_item) - { - selectItem(prev_item, cur_item->getSelectedCell(), !extend_selection); - } - else - { - reportInvalidInput(); - } - break; - } + break; + } - // don't allow navigation to disabled elements - prev_item = cur_item->getEnabled() ? cur_item : prev_item; + // don't allow navigation to disabled elements + if (item->getEnabled()) + { + prev_item = item; } } + if (!prev_item) + { + reportInvalidInput(); + return; + } + + selectItem(prev_item, prev_item->getSelectedCell(), !extend_selection); + if ((mCommitOnSelectionChange || mCommitOnKeyboardMovement)) { commitIfChanged(); @@ -1147,36 +1141,41 @@ void LLScrollListCtrl::selectPrevItem( bool extend_selection) void LLScrollListCtrl::selectNextItem( bool extend_selection) { + updateSort(); + + LLScrollListItem* current_item = NULL; LLScrollListItem* next_item = NULL; - if (!getFirstSelected()) - { - selectFirstItem(); - } - else + for (LLScrollListItem* item : mItemList) { - updateSort(); - - for (LLScrollListItem* cur_item : mItemList) + if (current_item) { - if (cur_item->getSelected()) + if (item->getEnabled()) { - if (next_item) - { - selectItem(next_item, cur_item->getSelectedCell(), !extend_selection); - } - else - { - reportInvalidInput(); - } + next_item = item; break; } - - // don't allow navigation to disabled items - next_item = cur_item->getEnabled() ? cur_item : next_item; } + else if (item->getSelected()) + { + current_item = item; + next_item = NULL; + continue; + } + else if (!next_item && item->getEnabled()) + { + next_item = item; + } + } + + if (!next_item) + { + reportInvalidInput(); + return; } + selectItem(next_item, next_item->getSelectedCell(), !extend_selection); + if (mCommitOnKeyboardMovement) { onCommit(); |