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/OSGMParentFCPointerField.inl

    r1046 r1060  
    596596                      AllocatorT >::getBinSize(void) const 
    597597{ 
    598     FWARNING(("MParentFCPointerField<ObjectT, NamespaceI, AllocatorT>" 
    599               "::getBinSize(void) const: Parent pointers should NOT be " 
    600               "serialized/deserialized.\n")); 
    601                
    602598    return MFieldTraits::getBinSize(&(this->getRawStorage().front()),  
    603599                                      this->getRawStorage().size ()  ); 
     
    609605                      NamespaceI, 
    610606                      AllocatorT >::copyToBin(BinaryDataHandler &pMem) const 
    611 
    612     FWARNING(("MParentFCPointerField<ObjectT, NamespaceI, AllocatorT>" 
    613               "::copyToBin(BinaryDataHandler &pMem): Parent pointers should " 
    614               "NOT be serialized/deserialized.\n")); 
    615                
     607{               
    616608    UInt32 n = this->getRawStorage().size(); 
    617609     
     
    630622                      AllocatorT >::copyFromBin(BinaryDataHandler &pMem) 
    631623{ 
    632     FWARNING(("MParentFCPointerField<ObjectT, NamespaceI, AllocatorT>" 
    633               "::copyFromBin(BinaryDataHandler &pMem): Parent pointers should " 
    634               "NOT be serialized/deserialized.\n")); 
    635  
    636     UInt32 n; 
    637  
    638     pMem.getValue(n); 
    639     clear(); 
    640  
    641 #ifdef __hpux 
    642     StoredType tmpVal; 
    643     resize(n, tmpVal); 
    644 #else 
    645     resize(n); 
    646 #endif 
    647  
    648     if(n != 0) 
     624    UInt32 newSize; 
     625     
     626    pMem.getValue(newSize); 
     627     
     628    if(newSize > 0) 
    649629    { 
    650         MFieldTraits::copyFromBin(pMem, &(this->editRawStorage()[0]), n); 
     630        UInt32 oldSize = this->getRawStorage().size(); 
    651631         
    652         StorageIter vI = this->editRawStorage().begin(); 
    653         StorageIter vE = this->editRawStorage().end  (); 
     632        if(newSize > oldSize) 
     633        { 
     634            // [0, oldSize[ contains entries that are being replaced 
     635            this->editRawStorage().resize(newSize); 
    654636         
    655         for(; vI != vE; ++vI) 
     637            StorageIter vI = this->editRawStorage().begin(); 
     638            StorageIter vE = this->editRawStorage().begin() + oldSize;     
     639         
     640            for(; vI != vE; ++vI) 
     641            { 
     642                ValueType pNewObj; 
     643             
     644                MFieldTraits::copyFromBin(pMem, pNewObj); 
     645                     
     646                incRefCount(pNewObj); 
     647                decRefCount(*vI    ); 
     648                 
     649                *vI = pNewObj; 
     650            } 
     651         
     652            // [oldSize, newSize[ contains entries that are added 
     653            MFieldTraits::copyFromBin(pMem, &(*vI), newSize - oldSize); 
     654             
     655            vE = this->editRawStorage().end(); 
     656             
     657            for(; vI != vE; ++vI) 
     658                incRefCount(*vI); 
     659        } 
     660        else 
    656661        { 
    657             incRefCount(vI->getPointer()); 
     662            // [0, newSize[ contains entries that are being replaced 
     663            StorageIter vI = this->editRawStorage().begin(); 
     664            StorageIter vE = this->editRawStorage().begin() + newSize; 
     665         
     666            for(; vI != vE; ++vI) 
     667            { 
     668                ValueType pNewObj; 
     669                 
     670                MFieldTraits::copyFromBin(pMem, pNewObj); 
     671                 
     672                incRefCount(pNewObj); 
     673                decRefCount(*vI    ); 
     674                 
     675                *vI = pNewObj; 
     676            } 
     677             
     678            // [newSize, oldSize[ contains entries that are being removed 
     679            vE = this->editRawStorage().end(); 
     680             
     681            for(; vI != vE; ++vI) 
     682                decRefCount(*vI); 
     683                 
     684            this->editRawStorage().resize(newSize); 
    658685        } 
     686    } 
     687    else 
     688    { 
     689        this->clear(); 
    659690    } 
    660691}