Bug 580814 - Avoid accessing rows that don't exist in treeviews for Places. r=mak

This commit is contained in:
OHZEKI Tetsuharu 2012-03-04 12:36:14 -05:00
Родитель 74f4120e75
Коммит 7d9e28804c
1 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -198,7 +198,8 @@ PlacesTreeView.prototype = {
* @return [parentNode, parentRow] * @return [parentNode, parentRow]
*/ */
_getParentByChildRow: function PTV__getParentByChildRow(aChildRow) { _getParentByChildRow: function PTV__getParentByChildRow(aChildRow) {
let parent = this._getNodeForRow(aChildRow).parent; let node = this._getNodeForRow(aChildRow);
let parent = (node === null) ? this._rootNode : node.parent;
// The root node is never visible // The root node is never visible
if (parent == this._rootNode) if (parent == this._rootNode)
@ -212,6 +213,10 @@ PlacesTreeView.prototype = {
* Gets the node at a given row. * Gets the node at a given row.
*/ */
_getNodeForRow: function PTV__getNodeForRow(aRow) { _getNodeForRow: function PTV__getNodeForRow(aRow) {
if (aRow < 0) {
return null;
}
let node = this._rows[aRow]; let node = this._rows[aRow];
if (node !== undefined) if (node !== undefined)
return node; return node;