Logo Search packages:      
Sourcecode: inkscape version File versions  Download package

void Inkscape::XML::SimpleNode::removeChild ( Node child  )  [virtual, inherited]

Remove a child of this node.

Once the pointer to the removed node disappears from the stack, the removed node will be collected in the next GC pass, but only as long as its refcount is zero. You should keep a refcount of zero for all nodes in the document except for the document node itself, because they will be held in memory by the parent.

child The child to remove

Implements Inkscape::XML::Node.

Definition at line 404 of file simple-node.cpp.

References Inkscape::XML::SimpleNode::_next, Inkscape::XML::Node::document(), Inkscape::XML::Document::logger(), Inkscape::XML::SimpleNode::next(), Inkscape::XML::CompositeNodeObserver::notifyChildRemoved(), Inkscape::XML::NodeObserver::notifyChildRemoved(), and Inkscape::XML::Node::previous_node().

    g_assert(generic_child->document() == _document);

    SimpleNode *child=dynamic_cast<SimpleNode *>(generic_child);
    SimpleNode *ref=dynamic_cast<SimpleNode *>(previous_node(child));

    g_assert(child->_parent == this);

    Debug::EventTracker<DebugRemoveChild> tracker(*this, *child);

    SimpleNode *next = child->_next;
    if (ref) {
        ref->_next = next;
    } else {
        _first_child = next;
    if (!next) { // removing the last child?
        _last_child = ref;
    } else {
        // removing any other child invalidates the cached positions
        _cached_positions_valid = false;

    child->_next = NULL;

    _document->logger()->notifyChildRemoved(*this, *child, ref);
    _observers.notifyChildRemoved(*this, *child, ref);

Generated by  Doxygen 1.6.0   Back to index