if (treeView)
if (treeView) { nsCOMPtr<nsITreeSelection> sel; treeView->GetSelection(getter_AddRefs(sel)); if (sel) sel->SetTree(nsnull);
nsTreeBoxObject::SetDocument(nsIDocument* aDocument){  // this should only be called with a null document, which indicates  // that we're being torn down.  NS_ASSERTION(aDocument == nsnull, "SetDocument called with non-null document");  // Drop the view's ref to us.  nsCOMPtr<nsISupports> suppView;  GetPropertyAsSupports(NS_LITERAL_STRING("view").get(), getter_AddRefs(suppView));  nsCOMPtr<nsITreeView> treeView(do_QueryInterface(suppView));  if (treeView)    treeView->SetTree(nsnull); // Break the circular ref between the view and us.  return nsBoxObject::SetDocument(aDocument);}