/** * This removes a link, by setting its start and end to NULL, removing from * out list of links etc. * * @param link The link to remove. */ void EditorChunkItemLinkable::removeLink(ChunkLinkPtr link) { delLink(link); ChunkItem* otherCI = static_cast<ChunkItem*>(link->endItem().getObject()); ChunkItem* myselfCI = static_cast<ChunkItem*>(link->startItem().getObject()); EditorChunkItemLinkable* otherLinker = 0; EditorChunkItemLinkable* myselfLinker = 0; if (otherCI->isEditorEntity()) otherLinker = static_cast<EditorChunkEntity*>(otherCI)->chunkItemLinker(); else if (otherCI->isEditorUserDataObject()) otherLinker = static_cast<EditorChunkUserDataObject*>(otherCI)->chunkItemLinker(); if (myselfCI->isEditorEntity()) myselfLinker = static_cast<EditorChunkEntity*>(myselfCI)->chunkItemLinker(); else if (myselfCI->isEditorUserDataObject()) myselfLinker = static_cast<EditorChunkUserDataObject*>(myselfCI)->chunkItemLinker(); if (otherLinker == NULL && myselfLinker == NULL) return; if (otherLinker->chunkItem() == chunkItem()) { if (myselfCI->isEditorEntity()) otherLinker = static_cast<EditorChunkEntity*>(myselfCI)->chunkItemLinker(); else if (myselfCI->isEditorUserDataObject()) otherLinker = static_cast<EditorChunkUserDataObject*>(myselfCI)->chunkItemLinker(); } otherLinker->delLink(link); bool owns = guid() < otherLinker->guid(); LinkInfo::iterator lit = preloadLinks_.find(otherLinker->guid()); if (lit != preloadLinks_.end()) preloadLinks_.erase(lit); lit = otherLinker->preloadLinks_.find(guid()); if (lit != otherLinker->preloadLinks_.end()) otherLinker->preloadLinks_.erase(lit); if (owns) chunkItem()->chunk()->delStaticItem(link); else otherLinker->chunkItem()->chunk()->delStaticItem(link); link->startItem(NULL); link->endItem(NULL); }
MyLinkList<T>::~MyLinkList() { delLink(); }