| 621 | //----------------------------------------------------------------------------- |
| 622 | |
| 623 | void SimGroup::_addObject( SimObject* obj, bool forcePushBack ) |
| 624 | { |
| 625 | // Make sure we aren't adding ourself. This isn't the most robust check |
| 626 | // but it should be good enough to prevent some self-foot-shooting. |
| 627 | if( obj == this ) |
| 628 | { |
| 629 | Con::errorf( "SimGroup::addObject - (%d) can't add self!", getIdString() ); |
| 630 | return; |
| 631 | } |
| 632 | |
| 633 | if( obj->getGroup() == this ) |
| 634 | return; |
| 635 | |
| 636 | lock(); |
| 637 | |
| 638 | obj->incRefCount(); |
| 639 | |
| 640 | if( obj->getGroup() ) |
| 641 | obj->getGroup()->removeObject( obj ); |
| 642 | |
| 643 | if( forcePushBack ? objectList.pushBack( obj ) : objectList.pushBackForce( obj ) ) |
| 644 | { |
| 645 | mNameDictionary.insert( obj ); |
| 646 | obj->mGroup = this; |
| 647 | |
| 648 | obj->onGroupAdd(); |
| 649 | |
| 650 | getSetModificationSignal().trigger( SetObjectAdded, this, obj ); |
| 651 | if( obj->isProperlyAdded() ) |
| 652 | onObjectAdded_callback( obj ); |
| 653 | } |
| 654 | else |
| 655 | obj->decRefCount(); |
| 656 | |
| 657 | unlock(); |
| 658 | |
| 659 | // SimObjects will automatically remove them from their group |
| 660 | // when deleted so we don't hook up a delete notification. |
| 661 | } |
| 662 | |
| 663 | //----------------------------------------------------------------------------- |
| 664 |
nothing calls this directly
no test coverage detected