зеркало из https://github.com/mozilla/pjs.git
Protecting against setting an invalid current item on the tree. Prep work
for 47795. r=hyatt.
This commit is contained in:
Родитель
889df4877d
Коммит
d82b9ba62b
|
@ -2511,12 +2511,20 @@ nsXULElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
|||
}
|
||||
|
||||
if (newSelectIndex != -1) {
|
||||
nsCOMPtr<nsIDOMElement> newSelectItem;
|
||||
treeBox->GetItemAtIndex(newSelectIndex, getter_AddRefs(newSelectItem));
|
||||
if (newSelectItem) {
|
||||
nsCOMPtr<nsIDOMXULElement> xulSelItem = do_QueryInterface(newSelectItem);
|
||||
if (xulSelItem)
|
||||
treeElement->SetCurrentItem(xulSelItem);
|
||||
// Make sure the index is still valid
|
||||
PRInt32 treeRows;
|
||||
treeBox->GetRowCount(&treeRows);
|
||||
if (treeRows > 0) {
|
||||
newSelectIndex = PR_MIN((treeRows - 1), newSelectIndex);
|
||||
nsCOMPtr<nsIDOMElement> newSelectItem;
|
||||
treeBox->GetItemAtIndex(newSelectIndex, getter_AddRefs(newSelectItem));
|
||||
if (newSelectItem) {
|
||||
nsCOMPtr<nsIDOMXULElement> xulSelItem = do_QueryInterface(newSelectItem);
|
||||
if (xulSelItem)
|
||||
treeElement->SetCurrentItem(xulSelItem);
|
||||
}
|
||||
} else {
|
||||
treeElement->SetCurrentItem(nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2511,12 +2511,20 @@ nsXULElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
|||
}
|
||||
|
||||
if (newSelectIndex != -1) {
|
||||
nsCOMPtr<nsIDOMElement> newSelectItem;
|
||||
treeBox->GetItemAtIndex(newSelectIndex, getter_AddRefs(newSelectItem));
|
||||
if (newSelectItem) {
|
||||
nsCOMPtr<nsIDOMXULElement> xulSelItem = do_QueryInterface(newSelectItem);
|
||||
if (xulSelItem)
|
||||
treeElement->SetCurrentItem(xulSelItem);
|
||||
// Make sure the index is still valid
|
||||
PRInt32 treeRows;
|
||||
treeBox->GetRowCount(&treeRows);
|
||||
if (treeRows > 0) {
|
||||
newSelectIndex = PR_MIN((treeRows - 1), newSelectIndex);
|
||||
nsCOMPtr<nsIDOMElement> newSelectItem;
|
||||
treeBox->GetItemAtIndex(newSelectIndex, getter_AddRefs(newSelectItem));
|
||||
if (newSelectItem) {
|
||||
nsCOMPtr<nsIDOMXULElement> xulSelItem = do_QueryInterface(newSelectItem);
|
||||
if (xulSelItem)
|
||||
treeElement->SetCurrentItem(xulSelItem);
|
||||
}
|
||||
} else {
|
||||
treeElement->SetCurrentItem(nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче