diff -r f4a778e096c2 -r 9da50d567e3c phonebookui/Phonebook2/MapExtension/src/cpmapcmd.cpp --- a/phonebookui/Phonebook2/MapExtension/src/cpmapcmd.cpp Wed Sep 01 12:29:52 2010 +0100 +++ b/phonebookui/Phonebook2/MapExtension/src/cpmapcmd.cpp Tue Sep 14 20:54:53 2010 +0300 @@ -25,18 +25,18 @@ #include #include #include -#include +#include #include #include #include #include -#include +#include #include #include #include -#include #include #include +#include // Virtual Phonebook #include @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include #include @@ -126,6 +126,11 @@ // CPmapCmd::~CPmapCmd() { + if ( iAddressSelectEliminator ) + { + iAddressSelectEliminator->ForceExit(); + } + Cancel(); if(iMapView) { @@ -139,6 +144,13 @@ iUiControl->RegisterCommand( NULL ); } delete iMapViewProvider; + + //Indication that the object has been deleted. + if ( iThisPtrDestroyed ) + { + *iThisPtrDestroyed = ETrue; + } + } // -------------------------------------------------------------------------- @@ -258,6 +270,9 @@ PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING ("CPmapCmd::ExecuteLD")); + TBool amIDestroyed( EFalse ); + iThisPtrDestroyed = &amIDestroyed; + iAddressUpdatePrompt = ETrue; TPbk2FieldGroupId groupId = EPbk2FieldGroupIdNone; if( !IsAddressInContact() ) @@ -309,6 +324,15 @@ { groupId = SelectAddressL(); } + + //This object could have been deleted because of some external activity + //Dont proceed if this object is destroyed + if ( amIDestroyed ) + { + return; + } + + iThisPtrDestroyed = NULL; if( groupId != EPbk2FieldGroupIdNone ) { @@ -506,6 +530,12 @@ CleanupStack::PopAndDestroy( appServices ); CPbk2AddressSelect* addressSelect = CPbk2AddressSelect::NewL( params ); + + // Execute + iAddressSelectEliminator = addressSelect; + iAddressSelectEliminator->ResetWhenDestroyed + ( &iAddressSelectEliminator ); + MVPbkStoreContactField* selectedField = addressSelect->ExecuteLD(); CleanupStack::PopAndDestroy(); // resReader