Changeset 11167

Show
Ignore:
Timestamp:
04/02/07 12:55:55 (2 years ago)
Author:
dmorissette
Message:

Backport fix for MITAB bug 1663 - problem writing collections (GDAL #1541)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.4/gdal/ogr/ogrsf_frmts/mitab/mitab_mapcoordblock.cpp

    r8593 r11167  
    3232 * 
    3333 * $Log: mitab_mapcoordblock.cpp,v $ 
     34 * Revision 1.16  2007/02/23 18:56:44  dmorissette 
     35 * Fixed another problem writing collections when the header of objects 
     36 * part of a collection were split on multiple blocks. Fix WriteBytes() 
     37 * to reload next coord block in TABReadWrite mode if there is one (bug 1663) 
     38 * 
    3439 * Revision 1.14  2005/10/06 19:15:31  dmorissette 
    3540 * Collections: added support for reading/writing pen/brush/symbol ids and 
     
    723728            // still allows strings longer than one block (see 'else' below). 
    724729            // 
    725             int nNewBlockOffset = m_poBlockManagerRef->AllocNewBlock(); 
    726             SetNextCoordBlock(nNewBlockOffset); 
    727  
    728             if (CommitToFile() != 0 || 
    729                 InitNewBlock(m_fp, 512, nNewBlockOffset) != 0) 
     730 
     731            if ( m_nNextCoordBlock != 0 ) 
    730732            { 
    731                 // An error message should have already been reported. 
    732                 return -1; 
     733                // We're in read/write mode and there is already an allocated 
     734                // block following this one in the chain ... just reload it  
     735                // and continue writing to it 
     736 
     737                CPLAssert( m_eAccess == TABReadWrite ); 
     738 
     739                if (CommitToFile() != 0 || 
     740                     ReadFromFile(m_fp, m_nNextCoordBlock, m_nBlockSize) != 0) 
     741                { 
     742                    // An error message should have already been reported. 
     743                    return -1; 
     744                } 
    733745            } 
    734  
    735             m_numBlocksInChain++; 
     746            else 
     747            { 
     748                // Need to alloc a new block. 
     749 
     750                int nNewBlockOffset = m_poBlockManagerRef->AllocNewBlock(); 
     751                SetNextCoordBlock(nNewBlockOffset); 
     752 
     753                if (CommitToFile() != 0 || 
     754                    InitNewBlock(m_fp, m_nBlockSize, nNewBlockOffset) != 0) 
     755                { 
     756                    // An error message should have already been reported. 
     757                    return -1; 
     758                } 
     759 
     760                m_numBlocksInChain++; 
     761            } 
    736762        } 
    737763        else