Bug 422743 ? Crash in nsVoidArray::Count() during bookmark synchronization (for ondrej@allpeers.com, r=dietrich)

This commit is contained in:
dietrich@mozilla.com 2008-03-28 11:32:23 -07:00
parent 88be55ce34
commit 090fcdcc08
2 changed files with 18 additions and 4 deletions

View File

@ -2865,11 +2865,17 @@ nsNavHistoryFolderResultNode::nsNavHistoryFolderResultNode(
nsNavHistoryResultNode::RESULT_TYPE_FOLDER,
PR_FALSE, aDynamicContainerType, aOptions),
mContentsValid(PR_FALSE),
mQueryItemId(-1)
mQueryItemId(-1),
mIsRegisteredFolderObserver(PR_FALSE)
{
mItemId = aFolderId;
}
nsNavHistoryFolderResultNode::~nsNavHistoryFolderResultNode()
{
if (mIsRegisteredFolderObserver && mResult)
mResult->RemoveBookmarkFolderObserver(this, mItemId);
}
// nsNavHistoryFolderResultNode::OnRemoving
//
@ -3111,6 +3117,7 @@ nsNavHistoryFolderResultNode::FillChildren()
nsNavHistoryResult* result = GetResult();
NS_ENSURE_TRUE(result, NS_ERROR_FAILURE);
result->AddBookmarkFolderObserver(this, mItemId);
mIsRegisteredFolderObserver = PR_TRUE;
mContentsValid = PR_TRUE;
return NS_OK;
@ -3129,9 +3136,10 @@ nsNavHistoryFolderResultNode::ClearChildren(PRBool unregister)
mChildren.Clear();
if (unregister && mContentsValid) {
nsNavHistoryResult* result = GetResult();
if (result)
result->RemoveBookmarkFolderObserver(this, mItemId);
if (mResult) {
mResult->RemoveBookmarkFolderObserver(this, mItemId);
mIsRegisteredFolderObserver = PR_FALSE;
}
}
mContentsValid = PR_FALSE;
}

View File

@ -753,6 +753,8 @@ public:
PRInt64 aFolderId,
const nsACString& aDynamicContainerType);
virtual ~nsNavHistoryFolderResultNode();
NS_DECL_ISUPPORTS_INHERITED
NS_FORWARD_COMMON_RESULTNODE_TO_BASE_NO_GETITEMMID
NS_IMETHOD GetType(PRUint32* type) {
@ -798,6 +800,10 @@ public:
nsNavHistoryResultNode* FindChildById(PRInt64 aItemId,
PRUint32* aNodeIndex);
private:
PRBool mIsRegisteredFolderObserver;
};
// nsNavHistorySeparatorResultNode