From ba474deb8b0f363f5a89e9b3ce89210bef3cd2e2 Mon Sep 17 00:00:00 2001 From: "benjamin%smedbergs.us" Date: Tue, 18 Jul 2006 18:25:31 +0000 Subject: [PATCH] Bug 325348, r=annie.sullivan Bookmarks in results not updated when there is no tree attached. Original committer: brettw%gmail.com Original revision: 1.46 Original date: 2006/01/31 22:25:24 git-svn-id: svn://10.0.0.236/trunk@202972 18797224-902f-48f8-a5cc-f745e15eee43 --- .../components/places/src/nsNavHistoryResult.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mozilla/toolkit/components/places/src/nsNavHistoryResult.cpp b/mozilla/toolkit/components/places/src/nsNavHistoryResult.cpp index 3a29df1d41a..dde6c721002 100644 --- a/mozilla/toolkit/components/places/src/nsNavHistoryResult.cpp +++ b/mozilla/toolkit/components/places/src/nsNavHistoryResult.cpp @@ -2595,7 +2595,7 @@ nsNavHistoryFolderResultNode::StartIncrementalUpdate() if (! mOptions->ExcludeItems() && ! mOptions->ExcludeQueries()) { // easy case: we are visible, always do incremental update - if (AreChildrenVisible()) + if (mExpanded || AreChildrenVisible()) return PR_TRUE; nsNavHistoryResult* result = GetResult(); @@ -2640,8 +2640,16 @@ nsNavHistoryFolderResultNode::OnItemAdded(nsIURI* aBookmark, PRInt64 aFolder, NS_ASSERTION(aFolder == mFolderId, "Got wrong bookmark update"); if (mOptions->ExcludeItems()) return NS_OK; // don't update items when we aren't displaying them - if (aIndex < 0 || aIndex > mChildren.Count()) - return NS_ERROR_INVALID_ARG; + + // here, try to do something reasonable if the bookmark service gives us + // a bogus index. + if (aIndex < 0) { + NS_NOTREACHED("Invalid index for item adding: <0"); + aIndex = 0; + } else if (aIndex > mChildren.Count()) { + NS_NOTREACHED("Invalid index for item adding: greater than count"); + aIndex = mChildren.Count(); + } if (! StartIncrementalUpdate()) return NS_OK;