browserutilities/downloadmgr/DownloadMgrServEng/Src/BuffStorage.cpp
branchRCL_3
changeset 92 e1bea15f9a39
parent 0 dd21522fd290
child 93 79859ed3eea9
--- a/browserutilities/downloadmgr/DownloadMgrServEng/Src/BuffStorage.cpp	Thu Jul 15 19:53:20 2010 +0300
+++ b/browserutilities/downloadmgr/DownloadMgrServEng/Src/BuffStorage.cpp	Thu Aug 19 10:58:56 2010 +0300
@@ -79,6 +79,7 @@
     {
     LOGGER_ENTERFN( "ConstructL" );
     CActiveScheduler::Add( this );
+    iWait = new (ELeave) CActiveSchedulerWait;
     }
 
 // -----------------------------------------------------------------------------
@@ -108,6 +109,11 @@
 	ResetBuffers();
 	
 	delete iWritePtr; iWritePtr = 0;
+	if(iWait)
+	    {
+	     delete iWait;
+	     iWait = NULL;
+	    }
     }
 
 
@@ -134,10 +140,10 @@
     	CLOG_WRITE_2( "(%08X) CBuffStorage::RunL DH-iStat: %d, ", this, iStatus.Int() );
     	}
     	
-    if(iWait.IsStarted())
+    if(iWait && iWait->IsStarted())
 		{
 		CLOG_WRITE_1 ( "(%08X) CBuffStorage::RunL() Stopping iWait", this );
-		iWait.AsyncStop();
+		iWait->AsyncStop();
 		}
     }
 
@@ -157,10 +163,10 @@
 	{	
 	CLOG_WRITE_1("(%08X) CBuffStorage::ResetBuffers >>", this);
 	
-	if(IsActive())
+	if(IsActive()&& iWait && !iWait->IsStarted())
 		{
 		// Make sure async writes are finished
-		iWait.Start();
+		iWait->Start();
 		}
 	
 	// Cleanup
@@ -225,10 +231,10 @@
 	CLOG_WRITE_1("(%08X) CBuffStorage::FlushBuffersL >>", this);
 	
 	// Make sure async writes are finished before doing anything
-	if(IsActive())
+	if(IsActive() && iWait && !iWait->IsStarted())
 		{
 		CLOG_WRITE_1("(%08X) CBuffStorage::FlushBuffersL: stalling >>", this);
-	 	iWait.Start();
+	 	iWait->Start();
 	 	CLOG_WRITE_1("(%08X) CBuffStorage::FlushBuffersL: stalling <<", this);
 		}
 	
@@ -335,10 +341,10 @@
 	    
 	    // Check if previous async write is still ongoing
 	    // Done here so if somebody switched on progressive download midway through we don't mix buffers
-		if(IsActive())
+		if(IsActive()&& iWait && !iWait->IsStarted())
 			{
 			CLOG_WRITE_1("(%08X) CBuffStorage::DoBufferingWriteL: stalling >>", this);
-		 	iWait.Start();
+		 	iWait->Start();
 		 	CLOG_WRITE_1("(%08X) CBuffStorage::DoBufferingWriteL: stalling <<", this);
 			}
 		
@@ -415,10 +421,10 @@
 	{
 	CLOG_WRITE_2("(%08X) CBuffStorage::DoNonbufferingWriteL: %d bytes", this, aBuf.Length());
 	
-	if(IsActive())
+	if(IsActive() && iWait && !iWait->IsStarted())
 		{
 		CLOG_WRITE_1("(%08X) CBuffStorage::DoNonbufferingWriteL: stalling >>", this);
-		iWait.Start();
+		iWait->Start();
 		CLOG_WRITE_1("(%08X) CBuffStorage::DoNonbufferingWriteL: stalling <<", this);
 		}