Show
Ignore:
Timestamp:
02/12/08 09:51:59 (9 months ago)
Author:
cneumann
Message:

fixed: - pointer fields: sync/copyFromBin order of inc/dec refcount

(always inc new pointer first, then dec old pointer)

  • cluster server: commented out writing of .osg file on each frame
  • multi display window: merged fix from trunk (r1058)
  • tutorial 12: empty address check

added: - pointer field handles: implemented equal and share

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/Carsten_PtrWork2/Source/System/FieldContainer/Fields/OSGMWeakFCPointerField.inl

    r1041 r1060  
    502502                    AllocatorT >::copyFromBin(BinaryDataHandler &pMem) 
    503503{ 
    504     UInt32 n; 
    505  
    506     pMem.getValue(n); 
    507     clear(); 
    508  
    509 #ifdef __hpux 
    510     StoredType tmpVal; 
    511     resize(n, tmpVal); 
    512 #else 
    513     resize(n); 
    514 #endif 
    515  
    516     if(n != 0) 
    517     { 
    518         MFieldTraits::copyFromBin(pMem, &(this->editRawStorage()[0]), n); 
    519          
    520         StorageIter vI = this->editRawStorage().begin(); 
    521         StorageIter vE = this->editRawStorage().end  (); 
    522          
    523         for(; vI != vE; ++vI) 
     504    UInt32 newSize; 
     505     
     506    pMem.getValue(newSize); 
     507     
     508    if(newSize > 0) 
     509    { 
     510        UInt32 oldSize = this->getRawStorage().size(); 
     511         
     512        if(newSize > oldSize) 
    524513        { 
    525             incRefCount(*vI); 
     514            // [0, oldSize[ contains entries that are being replaced 
     515            this->editRawStorage().resize(newSize); 
     516         
     517            StorageIter vI = this->editRawStorage().begin(); 
     518            StorageIter vE = this->editRawStorage().begin() + oldSize;     
     519         
     520            for(; vI != vE; ++vI) 
     521            { 
     522                ValueType pNewObj; 
     523             
     524                MFieldTraits::copyFromBin(pMem, pNewObj); 
     525                     
     526                incRefCount(pNewObj); 
     527                decRefCount(*vI    ); 
     528                 
     529                *vI = pNewObj; 
     530            } 
     531         
     532            // [oldSize, newSize[ contains entries that are added 
     533            MFieldTraits::copyFromBin(pMem, &(*vI), newSize - oldSize); 
     534             
     535            vE = this->editRawStorage().end(); 
     536             
     537            for(; vI != vE; ++vI) 
     538                incRefCount(*vI); 
    526539        } 
     540        else 
     541        { 
     542            // [0, newSize[ contains entries that are being replaced 
     543            StorageIter vI = this->editRawStorage().begin(); 
     544            StorageIter vE = this->editRawStorage().begin() + newSize; 
     545         
     546            for(; vI != vE; ++vI) 
     547            { 
     548                ValueType pNewObj; 
     549                 
     550                MFieldTraits::copyFromBin(pMem, pNewObj); 
     551                 
     552                incRefCount(pNewObj); 
     553                decRefCount(*vI    ); 
     554                 
     555                *vI = pNewObj; 
     556            } 
     557             
     558            // [newSize, oldSize[ contains entries that are being removed 
     559            vE = this->editRawStorage().end(); 
     560             
     561            for(; vI != vE; ++vI) 
     562                decRefCount(*vI); 
     563                 
     564            this->editRawStorage().resize(newSize); 
     565        } 
     566    } 
     567    else 
     568    { 
     569        this->clear(); 
    527570    } 
    528571}