status_t VariablesView::VariableTableModel::_AddNode(Variable* variable, ModelNode* parent, ValueNodeChild* nodeChild, bool isPresentationNode) { // Don't create nodes for unspecified types -- we can't get/show their // value anyway. Type* nodeChildRawType = nodeChild->GetType()->ResolveRawType(false); if (nodeChildRawType->Kind() == TYPE_UNSPECIFIED) return B_OK; ModelNode* node = new(std::nothrow) ModelNode(parent, variable, nodeChild, isPresentationNode); BReference<ModelNode> nodeReference(node, true); if (node == NULL || node->Init() != B_OK) return B_NO_MEMORY; int32 childIndex; if (parent != NULL) { childIndex = parent->CountChildren(); if (!parent->AddChild(node)) return B_NO_MEMORY; // the parent has a reference, now } else { childIndex = fNodes.CountItems(); if (!fNodes.AddItem(node)) return B_NO_MEMORY; nodeReference.Detach(); // the fNodes list has a reference, now } fNodeTable.Insert(node); // mark a compound type child of a address type parent hidden if (parent != NULL) { ValueNode* parentValueNode = parent->NodeChild()->Node(); if (parentValueNode != NULL && parentValueNode->GetType()->ResolveRawType(false)->Kind() == TYPE_ADDRESS && nodeChildRawType->Kind() == TYPE_COMPOUND) { node->SetHidden(true); } } // notify table model listeners if (!node->IsHidden()) { TreeTablePath path; if (parent == NULL || _GetTreePath(parent, path)) NotifyNodesAdded(path, childIndex, 1); } // if the node is hidden, add its children if (node->IsHidden()) _AddChildNodes(nodeChild); return B_OK; }