Show
Ignore:
Timestamp:
12/03/07 15:48:13 (1 year ago)
Author:
cneumann
Message:

fixed: compile errors

reference counting


It compiles on linux (when disabling the VRML Loader) and the first
ref counting tests seem to work.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/Carsten_PtrWork2/Source/System/FieldContainer/Base/OSGFieldContainer.inl

    r1017 r1030  
    104104FieldContainer::subReference(void) 
    105105{ 
     106    FINFO(("FieldContainer::subReference [%p] START\n", this)); 
     107 
    106108     --_internalRefCount; 
    107109     
    108     if((_internalRefCount                    <= 0) &&  
    109        (_weakRefCount                        <= 0) && 
    110        (_pAspectStore->getExternalRefCount() <= 0)   ) 
    111     { 
    112         // empty pointer fields, destroy aspect 
    113         this->resolveLinks (); 
    114         this->destroyAspect(); 
    115     } 
    116     else if((_internalRefCount                    <= 0) &&  
    117             (_pAspectStore->getExternalRefCount() <= 0)   ) 
    118     { 
    119         // empty pointer fields 
     110    if((this         ->_resolveInProgress    == false) && 
     111       (this         ->_internalRefCount     <= 0    ) &&  
     112       (_pAspectStore->getExternalRefCount() <= 0    )   ) 
     113    { 
     114        FINFO(("FieldContainer::subReference [%p] E, I - RESOLVE\n", this)); 
     115     
     116        this->_resolveInProgress = true; 
    120117        this->resolveLinks(); 
    121     } 
     118         
     119        if(this->_weakRefCount <= 0) 
     120        { 
     121            FINFO(("FieldContainer::subReference [%p] E, I, W - RESOLVE, DESTROY\n", this)); 
     122                 
     123            this->destroyAspect(); 
     124        } 
     125        else 
     126        { 
     127            this->_resolveInProgress = false; 
     128        } 
     129    } 
     130            
     131    FINFO(("FieldContainer::subReference [%p] STOP\n", this)); 
    122132} 
    123133 
     
    164174FieldContainer::subExternalReference(void) 
    165175{ 
     176    FINFO(("FieldContainer::subExternalReference [%p] START\n", this)); 
     177 
    166178    _pAspectStore->acquireExternalReferenceCountLock(); 
    167179     
     
    170182    if(_pAspectStore->getExternalRefCount() <= 0) 
    171183    { 
     184        FINFO(("FieldContainer::subExternalReference [%p] E\n", this)); 
     185     
    172186        _pAspectStore->releaseExternalReferenceCountLock(); 
    173187         
     
    178192            FieldContainerPtr pAspect = _pAspectStore->getPtr(i); 
    179193             
    180             if((pAspect                    != NullFC) && 
    181                (pAspect->getRefCount()     <= 0    ) && 
    182                (pAspect->getWeakRefCount() <= 0     )   ) 
     194            if((pAspect                    != NullFC) && 
     195               (pAspect->_resolveInProgress == false ) && 
     196               (pAspect->_internalRefCount <= 0     )   ) 
    183197            { 
    184                 // empty fields, destroy aspect 
    185                              pAspect->resolveLinks (                   ); 
    186                 lastAspect = pAspect->destroyAspect(pAspect->getId(), i); 
     198                FINFO(("FieldContainer::subExternalReference [%p] E, I - RESOLVE\n", pAspect)); 
     199             
     200                pAspect->_resolveInProgress = true; 
     201                pAspect->resolveLinks(); 
    187202                 
    188                 if(lastAspect == true) 
    189                     break; 
     203                if(pAspect->_weakRefCount <= 0) 
     204                { 
     205                    FINFO(("FieldContainer::subExternalReference [%p] E, I, W - RESOLVE, DESTROY\n", pAspect)); 
     206                 
     207                    lastAspect = pAspect->destroyAspect(pAspect->getId(), i); 
     208                } 
     209                else 
     210                { 
     211                    pAspect->_resolveInProgress = false; 
     212                } 
    190213            } 
    191             else if((pAspect                != NullFC) && 
    192                     (pAspect->getRefCount() <= 0     )   ) 
    193             { 
    194                 pAspect->resolveLinks();  // empty pointer fields 
    195             } 
     214             
     215            if(lastAspect == true) 
     216                break; 
    196217        } 
    197218    } 
     
    200221        _pAspectStore->releaseExternalReferenceCountLock(); 
    201222    } 
     223     
     224    FINFO(("FieldContainer::subExternalReference [%p] STOP\n", this)); 
    202225} 
    203226 
     
    228251FieldContainer::subWeakReference(void) 
    229252{ 
     253    FINFO(("FieldContainer::subWeakReference [%p] START\n", this)); 
     254 
    230255    --_weakRefCount; 
    231256     
    232     if((_internalRefCount                    <= 0) &&  
    233        (_weakRefCount                        <= 0) && 
    234        (_pAspectStore->getExternalRefCount() <= 0)   ) 
    235     { 
    236         this->resolveLinks ();  // empty pointer fields 
     257    if((this         ->_resolveInProgress    == false) && 
     258       (this         ->_internalRefCount     <= 0    ) && 
     259       (this         ->_weakRefCount         <= 0    ) && 
     260       (_pAspectStore->getExternalRefCount() <= 0    )   ) 
     261    { 
     262        FINFO(("FieldContainer::subWeakReference [%p] E, I, W - DESTROY\n", this)); 
     263 
    237264        this->destroyAspect(); 
    238265    } 
     266     
     267    FINFO(("FieldContainer::subWeakReference [%p] STOP\n", this)); 
    239268} 
    240269 
     
    250279inline 
    251280FieldContainer::FieldContainer(void) : 
    252      Inherited        (    ), 
    253 #ifdef OSG_MT_CPTR_ASPECT 
    254     _pAspectStore     (NULL), 
    255 #endif 
    256     _pFieldFlags      (NULL), 
    257     _mfChangedFunctors(    ), 
    258     _internalRefCount (   0), 
    259     _weakRefCount     (   0) 
     281     Inherited        (     ), 
     282#ifdef OSG_MT_CPTR_ASPECT 
     283    _pAspectStore     (NULL ), 
     284#endif 
     285    _pFieldFlags      (NULL ), 
     286    _mfChangedFunctors(     ), 
     287    _internalRefCount (    0), 
     288    _weakRefCount     (    0), 
     289    _resolveInProgress(false), 
     290    _destroyInProgress(false) 
    260291{ 
    261292    _pFieldFlags = new FieldFlags; 
     
    271302    _mfChangedFunctors(source._mfChangedFunctors), 
    272303    _internalRefCount (                        0), 
    273     _weakRefCount     (                        0) 
     304    _weakRefCount     (                        0), 
     305    _resolveInProgress(false                    ), 
     306    _destroyInProgress(false                    ) 
    274307{ 
    275308    _pFieldFlags = new FieldFlags(*(source._pFieldFlags));