Re-merge fix for bug 2485 RCL_3 PDK_3.0.0 PDK_3.0.1
authorWilliam Roberts <williamr@symbian.org>
Fri, 28 May 2010 14:21:02 +0100
branchRCL_3
changeset 20 d2197ff6de2b
parent 19 bfa24657ff9f (diff)
parent 18 db335d346487 (current diff)
child 38 37fcac9e7ad8
Re-merge fix for bug 2485
--- a/usbmgmt/usbmgr/host/functiondrivers/ms/msmm/server/src/eventhandler.cpp	Tue May 18 17:01:48 2010 +0100
+++ b/usbmgmt/usbmgr/host/functiondrivers/ms/msmm/server/src/eventhandler.cpp	Fri May 28 14:21:02 2010 +0100
@@ -212,9 +212,12 @@
     LOG_FUNC
     // Complete client with KErrCancel
     CompleteClient(KErrCancel);
-    
+
     // Cancel current pending command
-    iSubCommandQueue.Head().CancelAsyncCmd();
+    if (iSubCommandQueue.Count())
+        {
+        iSubCommandQueue.Head().CancelAsyncCmd();
+        }
     }
 
 void CDeviceEventHandler::RunL( )
@@ -251,30 +254,33 @@
 TInt CDeviceEventHandler::RunError(TInt aError)
     {
     LOG_FUNC
-    // Retrieve sub-command related error notification data
-    iSubCommandQueue.Head().HandleError(*iErrNotiData, aError);
-        
-    // If current sub-command isn't a key one, the handler will continue to
-    // execute rest sub-command in the queue. But, if current sub-command
-    // is the last one in the queue, handler shall complete the client also. 
-    if (iSubCommandQueue.Head().IsKeyCommand() || 
-            (iSubCommandQueue.Count() == 1))
+
+    if (iSubCommandQueue.Count())
         {
-        CompleteClient(aError);
+        // Retrieve sub-command related error notification data
+        iSubCommandQueue.Head().HandleError(*iErrNotiData, aError);
+
+        // If current sub-command isn't a key one, the handler will continue to
+        // execute rest sub-command in the queue. But, if current sub-command
+        // is the last one in the queue, handler shall complete the client also. 
+        if (iSubCommandQueue.Head().IsKeyCommand() || 
+                (iSubCommandQueue.Count() == 1))
+            {
+            CompleteClient(aError);
+            }
+        iSubCommandQueue.Pop();
         }
 
-    //Restart the handler after error handling;
-    if (!IsActive())
+    if( IsActive() )
+        {
+        Complete(aError);
+        }
+    else if (iSubCommandQueue.Count())
         {
         Start();
+   	    Complete();
         }
-    Complete(aError);
-    
-    if (iSubCommandQueue.Count())
-        {
-        iSubCommandQueue.Pop();
-        }
-    
+
     return KErrNone;
     }