Bug 838304 - null out mResult when removing container nodes.

r=Mano
This commit is contained in:
Marco Bonardo 2013-02-05 21:56:05 +01:00
parent 96d37dc57a
commit 47cc1feb6b

View File

@ -232,6 +232,9 @@ nsNavHistoryResultNode::OnRemoving()
* This will find the result for this node. We can ask the nearest container
* for this value (either ourselves or our parents should be a container,
* and all containers have result pointers).
*
* @note The result may be null, if the container is detached from the result
* who owns it.
*/
nsNavHistoryResult*
nsNavHistoryResultNode::GetResult()
@ -240,12 +243,11 @@ nsNavHistoryResultNode::GetResult()
do {
if (node->IsContainer()) {
nsNavHistoryContainerResultNode* container = TO_CONTAINER(node);
NS_ASSERTION(container->mResult, "Containers must have valid results");
return container->mResult;
}
node = node->mParent;
} while (node);
NS_NOTREACHED("No container node found in hierarchy!");
MOZ_ASSERT(false, "No container node found in hierarchy!");
return nullptr;
}
@ -369,6 +371,7 @@ nsNavHistoryContainerResultNode::OnRemoving()
for (int32_t i = 0; i < mChildren.Count(); ++i)
mChildren[i]->OnRemoving();
mChildren.Clear();
mResult = nullptr;
}
@ -691,7 +694,7 @@ nsNavHistoryContainerResultNode::GetSortType()
if (mResult)
return mResult->mSortingMode;
NS_NOTREACHED("We should always have a result");
// This is a detached container, just use natural order.
return nsINavHistoryQueryOptions::SORT_BY_NONE;
}
@ -708,8 +711,6 @@ nsNavHistoryContainerResultNode::GetSortingAnnotation(nsACString& aAnnotation)
mParent->GetSortingAnnotation(aAnnotation);
else if (mResult)
aAnnotation.Assign(mResult->mSortingAnnotation);
else
NS_NOTREACHED("We should always have a result");
}
/**
@ -2051,6 +2052,7 @@ nsNavHistoryQueryResultNode::OnRemoving()
{
nsNavHistoryResultNode::OnRemoving();
ClearChildren(true);
mResult = nullptr;
}
@ -2282,7 +2284,7 @@ nsNavHistoryQueryResultNode::FillChildren()
uint16_t sortType = GetSortType();
if (mResult->mNeedsToApplySortingMode) {
if (mResult && mResult->mNeedsToApplySortingMode) {
// We should repopulate container and then apply sortingMode. To avoid
// sorting 2 times we simply do that here.
mResult->SetSortingMode(mResult->mSortingMode);
@ -2456,7 +2458,7 @@ nsNavHistoryQueryResultNode::GetSortType()
if (mResult)
return mResult->mSortingMode;
NS_NOTREACHED("We should always have a result");
// This is a detached container, just use natural order.
return nsINavHistoryQueryOptions::SORT_BY_NONE;
}
@ -2470,8 +2472,6 @@ nsNavHistoryQueryResultNode::GetSortingAnnotation(nsACString& aAnnotation) {
else if (mResult) {
aAnnotation.Assign(mResult->mSortingAnnotation);
}
else
NS_NOTREACHED("We should always have a result");
}
void
@ -3157,6 +3157,7 @@ nsNavHistoryFolderResultNode::OnRemoving()
{
nsNavHistoryResultNode::OnRemoving();
ClearChildren(true);
mResult = nullptr;
}
@ -3368,7 +3369,7 @@ nsNavHistoryFolderResultNode::OnChildrenFilled()
// nodes and the result node pointers on the containers.
FillStats();
if (mResult->mNeedsToApplySortingMode) {
if (mResult && mResult->mNeedsToApplySortingMode) {
// We should repopulate container and then apply sortingMode. To avoid
// sorting 2 times we simply do that here.
mResult->SetSortingMode(mResult->mSortingMode);