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
parent d77dae5390
commit 664e1bfd0d

View File

@ -198,7 +198,8 @@ PlacesTreeView.prototype = {
* @return [parentNode, parentRow]
*/
_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
if (parent == this._rootNode)
@ -212,6 +213,10 @@ PlacesTreeView.prototype = {
* Gets the node at a given row.
*/
_getNodeForRow: function PTV__getNodeForRow(aRow) {
if (aRow < 0) {
return null;
}
let node = this._rows[aRow];
if (node !== undefined)
return node;