// Note: This routine doesn't delete the control. It just removes it from the control list bool CGUIControlGroup::RemoveControl(const CGUIControl *control) { for (iControls it = m_children.begin(); it != m_children.end(); ++it) { CGUIControl *child = *it; if (child->IsGroup() && ((CGUIControlGroup *)child)->RemoveControl(control)) return true; if (control == child) { m_children.erase(it); RemoveLookup(child); SetInvalid(); return true; } } return false; }
void LocaleStringLookup::RemoveLookup(CTSTR lookupVal, StringLookupNode *node) { if(!node) node = top; UINT childID = node->FindSubNodeID(lookupVal); if(childID == INVALID) return; StringLookupNode *child = node->subNodes[childID]; lookupVal += child->str.Length(); TCHAR ch = *lookupVal; if(ch) RemoveLookup(lookupVal, child); if(!ch) { if(!child->subNodes.Num()) { if(child->leaf) { cache.RemoveItem(child->leaf); delete child->leaf; } node->subNodes.Remove(childID); delete child; } else { if(child->leaf) { cache.RemoveItem(child->leaf); delete child->leaf; } child->leaf = NULL; if(child->subNodes.Num() == 1) { StringLookupNode *subNode = child->subNodes[0]; child->str += subNode->str; child->leaf = subNode->leaf; child->subNodes.CopyList(subNode->subNodes); subNode->subNodes.Clear(); delete subNode; } } } else if(!child->subNodes.Num() && !child->leaf) { node->subNodes.Remove(childID); delete child; } //if not a leaf node and only have one child node, then merge with child node if(!node->leaf && node->subNodes.Num() == 1 && node != top) { StringLookupNode *subNode = node->subNodes[0]; node->str += subNode->str; node->leaf = subNode->leaf; node->subNodes.CopyList(subNode->subNodes); subNode->subNodes.Clear(); delete subNode; } }