Various cleanups to how the selection indices are maintained when part of the selection is occluded by a collapse operation, which could cause a crash in some instances. This fixes ticket #3711.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30015 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
b494a17f1c
commit
cd03af05a4
@ -483,6 +483,8 @@ BOutlineListView::Collapse(BListItem* item)
|
|||||||
int32 startIndex = index;
|
int32 startIndex = index;
|
||||||
int32 max = FullListCountItems() - fullIndex - 1;
|
int32 max = FullListCountItems() - fullIndex - 1;
|
||||||
int32 count = 0;
|
int32 count = 0;
|
||||||
|
bool selectionChanged = false;
|
||||||
|
|
||||||
BListItem** items = (BListItem**)fFullList.Items() + fullIndex + 1;
|
BListItem** items = (BListItem**)fFullList.Items() + fullIndex + 1;
|
||||||
|
|
||||||
while (max-- > 0) {
|
while (max-- > 0) {
|
||||||
@ -493,9 +495,10 @@ BOutlineListView::Collapse(BListItem* item)
|
|||||||
if (item->IsItemVisible()) {
|
if (item->IsItemVisible()) {
|
||||||
fList.RemoveItem(item);
|
fList.RemoveItem(item);
|
||||||
item->SetItemVisible(false);
|
item->SetItemVisible(false);
|
||||||
if (item->IsSelected())
|
if (item->IsSelected()) {
|
||||||
|
selectionChanged = true;
|
||||||
item->Deselect();
|
item->Deselect();
|
||||||
|
}
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,19 +507,21 @@ BOutlineListView::Collapse(BListItem* item)
|
|||||||
|
|
||||||
_RecalcItemTops(startIndex);
|
_RecalcItemTops(startIndex);
|
||||||
// fix selection hints
|
// fix selection hints
|
||||||
// TODO: revise for multi selection lists
|
if (index < fFirstSelected && index + count < fFirstSelected) {
|
||||||
if (index < fFirstSelected) {
|
// all items removed were higher than the selection range,
|
||||||
if (index + count < fFirstSelected) {
|
// adjust the indexes to correspond to their new visible positions
|
||||||
fFirstSelected -= count;
|
fFirstSelected -= count;
|
||||||
fLastSelected -= count;
|
fLastSelected -= count;
|
||||||
} else {
|
|
||||||
// select top item
|
|
||||||
//fFirstSelected = fLastSelected = index;
|
|
||||||
//item->Select();
|
|
||||||
Select(index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32 maxIndex = fList.CountItems() - 1;
|
||||||
|
if (fFirstSelected > maxIndex)
|
||||||
|
fFirstSelected = maxIndex;
|
||||||
|
if (fLastSelected > maxIndex)
|
||||||
|
fLastSelected = maxIndex;
|
||||||
|
if (selectionChanged)
|
||||||
|
SelectionChanged();
|
||||||
|
|
||||||
_FixupScrollBar();
|
_FixupScrollBar();
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user