fix for bug #384731: "Bookmark This Page" throws exception on close in bookmarkProperties.js if you have "bookmarkPropertiesDialog/lastUsed" annotations that point to itemIds for folder that don't exist

fix for bug #384733:  "Add Bookmark" dialog truncated if you have "bookmarkPropertiesDialog/lastUsed" annotations that point to itemIds for folder that don't exist

r=mano
This commit is contained in:
sspitzer@mozilla.org 2007-06-22 16:19:47 -07:00
Родитель 907d30783a
Коммит 751a4ccf41
1 изменённых файлов: 16 добавлений и 3 удалений

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

@ -371,12 +371,19 @@ var BookmarkPropertiesPanel = {
* @return the new menu item. * @return the new menu item.
*/ */
_appendFolderItemToMenupopup: _appendFolderItemToMenupopup:
function BPP__appendFolderItemToMenuList(aMenupopup, aFolderId) { function BPP__appendFolderItemToMenupopup(aMenupopup, aFolderId) {
try {
var folderTitle = PlacesUtils.bookmarks.getItemTitle(aFolderId);
}
catch (ex) {
NS_ASSERT(folderTitle, "no title found for folderId of " + aFolderId);
return null;
}
// First make sure the folders-separator is visible // First make sure the folders-separator is visible
this._element("foldersSeparator").hidden = false; this._element("foldersSeparator").hidden = false;
var folderMenuItem = document.createElement("menuitem"); var folderMenuItem = document.createElement("menuitem");
var folderTitle = PlacesUtils.bookmarks.getItemTitle(aFolderId)
folderMenuItem.folderId = aFolderId; folderMenuItem.folderId = aFolderId;
folderMenuItem.setAttribute("label", folderTitle); folderMenuItem.setAttribute("label", folderTitle);
folderMenuItem.className = "menuitem-iconic folder-icon"; folderMenuItem.className = "menuitem-iconic folder-icon";
@ -424,6 +431,12 @@ var BookmarkPropertiesPanel = {
var defaultItem = var defaultItem =
this._getFolderMenuItem(this._defaultInsertionPoint.itemId, true); this._getFolderMenuItem(this._defaultInsertionPoint.itemId, true);
// if we fail to get a menuitem for the default insertion point
// use the Bookmarks root
if (!defaultItem)
defaultItem = this._element("bookmarksRootItem");
this._folderMenuList.selectedItem = defaultItem; this._folderMenuList.selectedItem = defaultItem;
}, },
@ -1055,7 +1068,7 @@ var BookmarkPropertiesPanel = {
var menupopup = this._folderMenuList.menupopup; var menupopup = this._folderMenuList.menupopup;
// 0: Bookmarks root, 1: toolbar folder, 2: separator // 0: Bookmarks root, 1: toolbar folder, 2: separator
for (var i=3; i < menupopup.childNodes.length; i++) { for (var i=3; i < menupopup.childNodes.length; i++) {
if (menupopup.childNodes[i].folderId == aFolderId) if (menupopup.childNodes[i].folderId == aFolderId)
return menupopup.childNodes[i]; return menupopup.childNodes[i];
} }