Revision: 201018 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 25 May 2010 14:39:45 +0300
branchRCL_3
changeset 11 bfa24657ff9f
parent 9 6ba7b7d87ab3
child 14 d3e8e7d462dd
Revision: 201018 Kit: 2010121
usbmgmt/usbmgr/host/functiondrivers/ms/msmm/server/src/eventhandler.cpp
--- a/usbmgmt/usbmgr/host/functiondrivers/ms/msmm/server/src/eventhandler.cpp	Tue May 11 17:53:46 2010 +0300
+++ b/usbmgmt/usbmgr/host/functiondrivers/ms/msmm/server/src/eventhandler.cpp	Tue May 25 14:39:45 2010 +0300
@@ -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;
     }