locationmanager/locationtrail/src/locationremappingao.cpp
branchRCL_3
changeset 17 50de4d668bb6
parent 15 3cebc1a84278
child 47 b73252188534
--- a/locationmanager/locationtrail/src/locationremappingao.cpp	Mon Mar 15 12:42:24 2010 +0200
+++ b/locationmanager/locationtrail/src/locationremappingao.cpp	Wed Mar 31 22:19:07 2010 +0300
@@ -272,33 +272,38 @@
 	for (TInt i = 0; i < count; i++)
 		{
 		CMdEObject* location = iMdEClient->OpenObjectL(iObjectIds[i], *iObjLocationDef);
-		CleanupStack::PushL( location );
+		
+		if(location)
+		    {
+            CleanupStack::PushL( location );
 		
-		if (location->PropertyCount(*iPropLatDef) == 0)
-			{
-			location->AddReal64PropertyL(*iPropLatDef, iLocationData.iPosition.Latitude());
-			LOG( "CLocationRemappingAO::RemapObjects - wrote latitude" );
-			}
-		if (location->PropertyCount(*iPropLongDef) == 0)
-			{
-			location->AddReal64PropertyL(*iPropLongDef, iLocationData.iPosition.Longitude());
-			LOG( "CLocationRemappingAO::RemapObjects - wrote longitude" );
-			}
-		if (location->PropertyCount(*iPropAltDef) == 0)
-			{
-			location->AddReal64PropertyL(*iPropAltDef, iLocationData.iPosition.Altitude());
-			LOG( "CLocationRemappingAO::RemapObjects - wrote altitude" );
-			}
-		CMdEProperty* modProp = NULL;
-		location->Property( *iPropModifiedDef, modProp, 0 );
-		if ( modProp )
-			{
-			TTime timestamp( 0 );
-			timestamp.UniversalTime();
-			modProp->SetTimeValueL( timestamp );
-			}
-		iObjects.AppendL(location);
-		CleanupStack::Pop( location );
+            if (location->PropertyCount(*iPropLatDef) == 0)
+                {
+                location->AddReal64PropertyL(*iPropLatDef, iLocationData.iPosition.Latitude());
+                LOG( "CLocationRemappingAO::RemapObjects - wrote latitude" );
+                }
+            if (location->PropertyCount(*iPropLongDef) == 0)
+                {
+                location->AddReal64PropertyL(*iPropLongDef, iLocationData.iPosition.Longitude());
+                LOG( "CLocationRemappingAO::RemapObjects - wrote longitude" );
+                }
+            if (location->PropertyCount(*iPropAltDef) == 0)
+                {
+                location->AddReal64PropertyL(*iPropAltDef, iLocationData.iPosition.Altitude());
+                LOG( "CLocationRemappingAO::RemapObjects - wrote altitude" );
+                }
+            CMdEProperty* modProp = NULL;
+            location->Property( *iPropModifiedDef, modProp, 0 );
+            if ( modProp )
+                {
+                TTime timestamp( 0 );
+                timestamp.UniversalTime();
+                modProp->SetTimeValueL( timestamp );
+                }
+            iObjects.AppendL(location);
+            CleanupStack::Pop( location );
+            
+          }
 		}
 	count = iRemapItems.Count();
 	LOG1("CLocationRemappingAO::RemapObjectsL - updating relations, count:%d", count);
@@ -308,12 +313,16 @@
 		CMdERelation* relation = NULL;
 		relation = iMdEClient->GetRelationL( iRemapItems[i].iRelationId );
 		
-    	TTime timestamp( 0 );
-    	timestamp.UniversalTime();
-    	relation->SetLastModifiedDate( timestamp );
+		if(relation)
+		    {   
+            TTime timestamp( 0 );
+            timestamp.UniversalTime();
+            relation->SetLastModifiedDate( timestamp );
     	
-    	iMdEClient->UpdateRelationL( *relation );
+            iMdEClient->UpdateRelationL( *relation );
+		    }
 		}
+	
 	LOG("CLocationRemappingAO::RemapObjectsL - relations updated");
 	
 	iObjectIds.Reset();