mtpfws/mtpfw/src/cmtpobjectstore.cpp
changeset 51 64200268cac2
parent 49 c20dd21d1eb4
child 52 866b4af7ffbe
--- a/mtpfws/mtpfw/src/cmtpobjectstore.cpp	Thu Sep 09 18:17:36 2010 +0800
+++ b/mtpfws/mtpfw/src/cmtpobjectstore.cpp	Fri Sep 17 11:40:03 2010 +0800
@@ -140,8 +140,11 @@
 	delete iPkgIDStore;
 	delete iSentinal;
 	delete iSnapshotWorker;
-	TRAP_IGNORE(CommitTransactionL());
-	iDatabase.Compact();
+	if (iDbOpened)
+	    {
+	    TRAP_IGNORE(CommitTransactionL());
+	    iDatabase.Compact();
+	    }
 	iBatched.Close();
 	iBatched_SuidHashID.Close();
 	CloseDb();
@@ -1004,9 +1007,19 @@
 	{
 	BaflUtils::EnsurePathExistsL(iSingletons.Fs(), aFileName);
 
-	LEAVEIFERROR(iDatabase.Replace(iSingletons.Fs(), aFileName, KMTPFormat),
-	        OstTrace0( TRACE_ERROR, CMTPOBJECTSTORE_CREATEDBL, " a new non-secure database create error!" ));
-	        
+	iDbOpened = EFalse;
+	TInt err = iDatabase.Replace(iSingletons.Fs(), aFileName, KMTPFormat);
+	if ( KErrNone == err )
+	    {
+	    iDbOpened = ETrue;
+	    }
+	else
+	    {
+        OstTrace0( TRACE_ERROR, CMTPOBJECTSTORE_CREATEDBL, 
+                    " a new non-secure database create error!" );
+	    User::Leave(err);
+	    }
+	
 	// Create table and index
 	CreateHandleTableL();
 	CreateHandleIndexL();