From 095b04ff89f961a9995bdb84ef24ef1b7bcda035 Mon Sep 17 00:00:00 2001 From: "myk%mozilla.org" Date: Thu, 19 Oct 2006 18:17:31 +0000 Subject: [PATCH] bug 356017: make sure folder item is selected before retrieving selected resource in bookmarks tree to avoid exception which prevents the Add Bookmarks dialog from properly creating the bookmark and closing when the user presses the Add button r=gavin git-svn-id: svn://10.0.0.236/trunk@213850 18797224-902f-48f8-a5cc-f745e15eee43 --- .../browser/components/bookmarks/content/addBookmark2.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mozilla/browser/components/bookmarks/content/addBookmark2.js b/mozilla/browser/components/bookmarks/content/addBookmark2.js index d71b23dd57c..83e4b918508 100644 --- a/mozilla/browser/components/bookmarks/content/addBookmark2.js +++ b/mozilla/browser/components/bookmarks/content/addBookmark2.js @@ -303,6 +303,14 @@ function selectMenulistFolder(aEvent) function selectTreeFolder() { + // If no item is selected, we obviously can't do anything with the selection. + // This happens when the bookmarks tree rebuilds, since the rebuild starts + // by removing all items from the tree, including the currently selected item, + // and removing the selection also triggers the "select" handler which calls + // this function. + if (gBookmarksTree.currentIndex == -1) + return; + var resource = gBookmarksTree.currentResource; if (resource == gSelectedFolder) return;