MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / removeChild

Method removeChild

source/MRMesh/MRObject.cpp:406–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

404}
405
406bool Object::removeChild( Object* child )
407{
408 assert( child );
409 if ( !child )
410 return false;
411
412 auto oldParent = child->parent();
413 if ( oldParent != this )
414 return false;
415
416 child->parent_ = nullptr;
417 needRedraw_ = true;
418
419 auto it = std::remove_if( children_.begin(), children_.end(), [child]( const std::shared_ptr<Object>& obj )
420 {
421 return !obj || obj.get() == child;
422 } );
423 if ( it != children_.end() )
424 {
425 children_.erase( it, children_.end() );
426 return true;
427 }
428
429 auto bit = std::remove_if( bastards_.begin(), bastards_.end(), [child]( const std::weak_ptr<Object>& wobj )
430 {
431 auto obj = wobj.lock();
432 return !obj || obj.get() == child;
433 } );
434 assert( bit != bastards_.end() );
435 bastards_.erase( bit, bastards_.end() );
436
437 return true;
438}
439
440void Object::removeAllChildren()
441{

Callers 9

checkPathFunction · 0.80
TESTFunction · 0.80
TESTFunction · 0.80
drawDialogMethod · 0.80
onDisable_Method · 0.80
makeObjectTreeFromFolderFunction · 0.80
detachFromParentMethod · 0.80
addChildMethod · 0.80
addChildBeforeMethod · 0.80

Calls 5

eraseMethod · 0.80
parentMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getMethod · 0.45

Tested by 2

TESTFunction · 0.64
TESTFunction · 0.64