photosgallery/collectionframework/datasource/plugins/glxdatasourcemde2.5/src/glxdatasourcetaskmds.cpp
branchRCL_3
changeset 9 6b87b143d312
parent 1 9ba538e329bd
child 14 ce1c7ad1f18b
--- a/photosgallery/collectionframework/datasource/plugins/glxdatasourcemde2.5/src/glxdatasourcetaskmds.cpp	Tue Feb 02 10:12:14 2010 +0200
+++ b/photosgallery/collectionframework/datasource/plugins/glxdatasourcemde2.5/src/glxdatasourcetaskmds.cpp	Fri Feb 19 22:51:01 2010 +0200
@@ -119,8 +119,8 @@
 void CGlxDataSourceTaskMde::CancelRequest()
     {
     TRACER("CGlxDataSourceTaskMde::CancelRequest()");
-    DestroyQueries();
     iCancelled = ETrue;
+    DestroyQueries();    
     }
 
 // ----------------------------------------------------------------------------
@@ -165,7 +165,7 @@
         TRAP(err, HandleQueryCompletedL(aQuery));
         }
 
-    if (err != KErrNone)
+    if (err != KErrNone && !iCancelled)
         {
         HandleRequestComplete(err);
         }
@@ -443,7 +443,10 @@
             }
          case EGlxFilterSortOrderItemCount:
             {            
-            //Order rule is not necessary for item count query
+            //Order rule is needed for tags popularity            
+            TMdEOrderRule orderRule(EOrderRuleTypeUsageCount, aFilterProperties.iSortDirection ==
+            EGlxFilterSortDirectionAscending);
+            aQuery.AppendOrderRuleL(orderRule);            
             break;
             }
         case EGlxFilterSortOrderCaptureDate:
@@ -672,7 +675,20 @@
     {
     TRACER("CGlxDataSourceTaskMde::HandleQueryCompletedL()");
     DoHandleQueryCompletedL(aQuery);
-    RemoveQuery();
+    
+    // Both the function calls should be executed if any
+    // request is not cancelled before completion.
+    // All the pending Queries are already destroyed in CancelRequest.
+    // Hence we do not have to call RemoveQuery here. That will lead to
+    // User 130 crash. 
+    // DoNextQuery tries to get iQueries.Count(). Since iQueries is destroyed
+    // in CancelRequest 
+    if (iCancelled)
+    	{ 
+    	GLX_LOG_INFO("***Query already Removed. Hence Return***");
+    	return;  	
+    	}  
+    RemoveQuery();  
     DoNextQueryL();
     }