Changeset 11537

Show
Ignore:
Timestamp:
05/15/07 23:35:17 (2 years ago)
Author:
warmerdam
Message:

improve error propagation up during open (#1635)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/ogr/ogrsf_frmts/s57/ogrs57datasource.cpp

    r10645 r11537  
    229229    } 
    230230 
     231    int bSuccess = TRUE; 
     232 
    231233    nModules = 1; 
    232234    papoModules = (S57Reader **) CPLMalloc(sizeof(void*)); 
     
    301303 
    302304        for( iModule = 0; iModule < nModules; iModule++ ) 
    303         { 
    304305            papoModules[iModule]->SetClassBased( OGRS57Driver::GetS57Registrar() ); 
    305         } 
    306306         
    307307        panClassCount = (int *) CPLCalloc(sizeof(int),MAX_CLASSES); 
    308308 
    309309        for( iModule = 0; iModule < nModules; iModule++ ) 
    310             papoModules[iModule]->CollectClassList(panClassCount,MAX_CLASSES); 
     310        { 
     311            bSuccess &=  
     312                papoModules[iModule]->CollectClassList(panClassCount, 
     313                                                       MAX_CLASSES); 
     314        } 
    311315 
    312316        for( iClass = 0; iClass < MAX_CLASSES; iClass++ ) 
     
    354358    } 
    355359     
    356     return TRUE
     360    return bSuccess
    357361} 
    358362 
  • trunk/gdal/ogr/ogrsf_frmts/s57/s57.h

    r11415 r11537  
    299299    const char          *GetDSNM() { return pszDSNM; } 
    300300 
    301     void                Ingest(); 
     301    int                 Ingest(); 
    302302    int                 ApplyUpdates( DDFModule * ); 
    303303    int                 FindAndApplyUpdates( const char *pszPath=NULL ); 
  • trunk/gdal/ogr/ogrsf_frmts/s57/s57reader.cpp

    r10645 r11537  
    343343/************************************************************************/ 
    344344 
    345 void S57Reader::Ingest() 
     345int S57Reader::Ingest() 
    346346 
    347347{ 
     
    349349     
    350350    if( poModule == NULL || bFileIngested ) 
    351         return
     351        return TRUE
    352352 
    353353/* -------------------------------------------------------------------- */ 
     
    355355/*      appropriate indexes.                                            */ 
    356356/* -------------------------------------------------------------------- */ 
     357    CPLErrorReset(); 
    357358    while( (poRecord = poModule->ReadRecord()) != NULL ) 
    358359    { 
     
    432433    } 
    433434 
     435    if( CPLGetLastErrorType() == CE_Failure ) 
     436        return FALSE; 
     437 
    434438    bFileIngested = TRUE; 
    435439 
     
    438442/* -------------------------------------------------------------------- */ 
    439443    if( nOptionFlags & S57M_UPDATES ) 
    440         FindAndApplyUpdates(); 
     444        return FindAndApplyUpdates(); 
     445    else 
     446        return TRUE; 
    441447} 
    442448 
     
    495501 
    496502{ 
    497     if( !bFileIngested
    498         Ingest()
     503    if( !bFileIngested && !Ingest()
     504        return NULL
    499505 
    500506/* -------------------------------------------------------------------- */ 
     
    21702176    int         bSuccess = TRUE; 
    21712177 
    2172     if( !bFileIngested
    2173         Ingest()
     2178    if( !bFileIngested && !Ingest()
     2179        return FALSE
    21742180 
    21752181    for( int iFEIndex = 0; iFEIndex < oFE_Index.GetCount(); iFEIndex++ ) 
     
    25172523/*      Ensure base file is loaded.                                     */ 
    25182524/* -------------------------------------------------------------------- */ 
    2519     Ingest(); 
     2525    if( !bFileIngested && !Ingest() ) 
     2526        return FALSE; 
    25202527 
    25212528/* -------------------------------------------------------------------- */ 
    25222529/*      Read records, and apply as updates.                             */ 
    25232530/* -------------------------------------------------------------------- */ 
     2531    CPLErrorReset(); 
    25242532    while( (poRecord = poUpdateModule->ReadRecord()) != NULL ) 
    25252533    { 
     
    26362644    } 
    26372645 
    2638     return TRUE
     2646    return CPLGetLastErrorType() != CE_Failure
    26392647} 
    26402648 
     
    27642772        return OGRERR_FAILURE; 
    27652773 
    2766     Ingest(); 
     2774    if( !Ingest() ) 
     2775        return OGRERR_FAILURE; 
    27672776 
    27682777/* -------------------------------------------------------------------- */