persistentstorage/centralrepository/cenrepsrv/obsrvr_noc.cpp
branchRCL_3
changeset 24 cc28652e0254
parent 23 26645d81f48d
--- a/persistentstorage/centralrepository/cenrepsrv/obsrvr_noc.cpp	Tue Aug 31 16:57:14 2010 +0300
+++ b/persistentstorage/centralrepository/cenrepsrv/obsrvr_noc.cpp	Wed Sep 01 12:39:58 2010 +0100
@@ -704,23 +704,29 @@
 	TInt biggestBlock;
 	TInt firstAvail = myHeap.Available(biggestBlock);
 	
-	TRAPD(err, aRepository = CSharedRepository::NewL(aUid));
+	aRepository = CSharedRepository::NewL(aUid);
 #ifdef CACHE_OOM_TESTABILITY
-	if ((err!=KErrNone)&&!iTrapOOMOnOpen)	
+	if ((aRepository==NULL)&&!iTrapOOMOnOpen)	
 		{
-		User::Leave(err);
+		User::Leave(KErrNoMemory);
 		}
 #endif	
-	if ((err!=KErrNone)&&TServerResources::iCacheManager->Enabled())
+	if ((aRepository==NULL)&&TServerResources::iCacheManager->Enabled())
 		{
 		// If cache enabled, try recovery by releasing the cache
 		TServerResources::iCacheManager->FlushCache(EFalse);
 		// retry
 		aRepository = CSharedRepository::NewL(aUid);
-		err = KErrNone;
 		}
-	User::LeaveIfError(err);
-	CleanupStack::PushL(aRepository);
+	// If still no memory, return error
+	if (aRepository==NULL)
+		{
+		User::Leave(KErrNoMemory);
+		}
+	else // successfully created the object, so push it into the cleanup stack
+		{
+		CleanupStack::PushL(aRepository);
+		}
 		
 	// Now that we have enough memory for the object and constructed it properly
 	// we try to load it. We trap all errors, either from leaving functions or error code