From 51c5bfa4881b5def142092e10dd402fd40e2e712 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 4 May 2010 17:07:07 +0000 Subject: Cache fixes? --- src/cache.h | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/cache.h') diff --git a/src/cache.h b/src/cache.h index 896aa71..dc5ab39 100644 --- a/src/cache.h +++ b/src/cache.h @@ -318,16 +318,26 @@ namespace Bu printf("Shouldn't erase, references still exist!\n"); return; } + + obtype *pObj = hEnt.get( cId ).pData; + pCalc->onDestroy( pObj, cId ); + hEnt.erase( cId ); + + pStore->destroy( pObj, cId ); } catch( Bu::HashException &e ) { - get( cId ); - } - - obtype *pObj = hEnt.get( cId ).pData; - pCalc->onDestroy( pObj, cId ); - hEnt.erase( cId ); + pCalc->onDestroy( cId ); - pStore->destroy( pObj, cId ); + if( hEnt.has( cId ) ) + { + // The object was loaded by onDestroy + erase( cId ); + } + else + { + pStore->destroy( cId ); + } + } } typedef Bu::List KeyList; -- cgit v1.2.3