harvester/common/inc/harvestdata.inl
changeset 45 a93990e5815e
parent 20 6dfc5f825351
child 63 e538444823de
--- a/harvester/common/inc/harvestdata.inl	Tue Jul 06 14:44:37 2010 +0300
+++ b/harvester/common/inc/harvestdata.inl	Wed Aug 18 10:12:07 2010 +0300
@@ -80,9 +80,55 @@
 //
 void CObjectDataArray::Append( CMdEObject* aMdeObject, CLocationData* aLocationData, CMdEQuery* aQuery )
     {
-    iMdeObjectArray.Append( aMdeObject );
-    iLocationArray.Append( aLocationData );
-    iQueryArray.Append( aQuery );
+    TInt mdeObjectIndex(KErrNone);
+    TInt locationDataIndex(KErrNone);
+    
+    mdeObjectIndex = iMdeObjectArray.Append( aMdeObject );
+    
+    if( mdeObjectIndex != KErrNone )
+        {
+        delete aMdeObject;
+        aMdeObject = NULL;
+        
+        delete aLocationData;
+        aLocationData = NULL;
+        
+        delete aQuery;
+        aQuery = NULL;
+        }
+    else
+        {
+        locationDataIndex = iLocationArray.Append( aLocationData );
+        
+        if( locationDataIndex != KErrNone )
+            {
+            iMdeObjectArray.Remove( mdeObjectIndex );
+            delete aMdeObject;
+            aMdeObject = NULL;
+            
+            delete aLocationData;
+            aLocationData = NULL;
+            
+            delete aQuery;
+            aQuery = NULL;
+            }
+        else
+            {
+            if( iQueryArray.Append( aQuery ) != KErrNone )
+                {
+                iMdeObjectArray.Remove( mdeObjectIndex );
+                delete aMdeObject;
+                aMdeObject = NULL;
+                
+                iLocationArray.Remove( locationDataIndex );
+                delete aLocationData;
+                aLocationData = NULL;
+                
+                delete aQuery;
+                aQuery = NULL;
+                }
+            }
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -96,8 +142,14 @@
         return;
         }
     delete iMdeObjectArray[aIndex];
+    iMdeObjectArray[aIndex] = NULL;
+    
     delete iLocationArray[aIndex];
+    iLocationArray[aIndex] = NULL;
+    
     delete iQueryArray[aIndex];
+    iQueryArray[aIndex] = NULL;
+    
     iMdeObjectArray.Remove( aIndex );
     iLocationArray.Remove( aIndex );
     iQueryArray.Remove( aIndex );