bluetooth/btlogger/btsnoophcilogger/src/hciloggerbtsnoop.cpp
branchRCL_3
changeset 21 14e240312f6f
parent 0 29b1cd4cb562
--- a/bluetooth/btlogger/btsnoophcilogger/src/hciloggerbtsnoop.cpp	Wed Jun 09 10:55:02 2010 +0300
+++ b/bluetooth/btlogger/btsnoophcilogger/src/hciloggerbtsnoop.cpp	Thu Jul 15 19:55:36 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -66,14 +66,15 @@
 	for (TInt i = 0; i <= TInt(KHCILoggerControllerToHost | KHCILoggerCommandOrEvent); i++)
 		{
 		CHCILoggerBufferedFrame* temp = new(ELeave) CHCILoggerBufferedFrame;
-		iBuffers.Append(temp); // array now "owns" temp
+		CleanupStack::PushL(temp);
+		iBuffers.AppendL(temp); // array now "owns" temp
+		CleanupStack::Pop(temp);
 		}
 	}
 
 void CHCILoggerBtSnoop::DoInitialise(TInt aType)
 	{
 	iDatalinkType = aType;
-	iFs.Connect();
 	OpenFile(); // if it fails, just ignore it - try later when writing
 	}
 
@@ -149,7 +150,18 @@
 		break;
 		};
 
-	TInt err = iLogFile.Open(iFs, fileName, EFileWrite | EFileShareAny);
+	TInt err = KErrNone;
+
+	if (!iFs.Handle())
+	    {
+        err = iFs.Connect();
+        if (err)
+            {
+            return err;
+            }
+	    }
+
+	err = iLogFile.Open(iFs, fileName, EFileWrite | EFileShareAny);
 	if (err == KErrNotFound)
 		{ // if it doesn't already exist, create it
 		//Note that the potential KErrPathNotFound error is deliberately not handled,