diff -r fcdfafb36fe7 -r aecbbf00d063 uifw/AvKon/src/aknmessagequerydialog.cpp --- a/uifw/AvKon/src/aknmessagequerydialog.cpp Thu Aug 19 10:11:06 2010 +0300 +++ b/uifw/AvKon/src/aknmessagequerydialog.cpp Tue Aug 31 15:28:30 2010 +0300 @@ -41,7 +41,7 @@ #include // for testability hooks #include "AknHeadingPaneTouchObserver.h" -#include "akntrace.h" + // CONSTANTS const TInt KMaxLinks = 64; @@ -51,24 +51,6 @@ const TInt KBoldStartTagLength = 22; const TInt KBoldEndTagLength = 23; -NONSHARABLE_CLASS(CAknAsynCallbackRunner) : public CActive - { -public: - CAknAsynCallbackRunner( CAknMessageQueryDialogExtension* aMsgQueryExtension ); - ~CAknAsynCallbackRunner(); - -public: -// new functions - void AsyncCallbackRunL( TInt aCurLink ); - -// from CActive - void DoCancel(); - void RunL(); - -private: - CAknMessageQueryDialogExtension* iMsgQueryExtension; - TInt iCurLink; - }; class CAknMessageQueryDialogExtension : public CBase, public CAknExtendedInputCapabilities::MAknEventObserver, public MAknHeadingPaneTouchObserver @@ -78,7 +60,6 @@ iControlRegisted( EFalse ) {} ~CAknMessageQueryDialogExtension() { - delete iAsyncCallbackRunner; TInt count = iFormatTextArray.Count(); for ( TInt i = 0; i < count; i++ ) { @@ -88,6 +69,13 @@ iFormatTextLocationArray.Close(); iFormatTextArray.Close(); iFormatTypeArray.Close(); + + if ( iDestroyedPtr ) + { + // Mark the object as destroyed. + *iDestroyedPtr = ETrue; + iDestroyedPtr = NULL; + } } /** From CAknExtendedInputCapabilities::MAknEventObserver @@ -111,15 +99,6 @@ iCtrl->DehighlightLink(); } } - - void ExecuteLinkCallbackL( TInt aCurLink ) - { - if ( !iAsyncCallbackRunner ) - { - iAsyncCallbackRunner = new( ELeave ) CAknAsynCallbackRunner( this ); - } - iAsyncCallbackRunner->AsyncCallbackRunL( aCurLink ); - } public: @@ -135,60 +114,25 @@ TInt iButtonGroupPreviouslyChanged; CAknMessageQueryDialog* iParent; TBool iControlRegisted; - CAknMessageQueryControl* iCtrl; + CAknMessageQueryControl* iCtrl; + /** + * @c iDestroyedPtr is used for the object destruction check. + * If it has non-null value, the destruction check is turned on, and + * the value points to a local boolean variable that keeps the destroyed state. + */ + TBool* iDestroyedPtr; TBool iIsInEditor; - - CAknAsynCallbackRunner* iAsyncCallbackRunner; }; - -CAknAsynCallbackRunner::CAknAsynCallbackRunner( - CAknMessageQueryDialogExtension* aMsgQueryExtension ) : - CActive( EPriorityStandard ), iMsgQueryExtension( aMsgQueryExtension ) - { - CActiveScheduler::Add( this ); - } - -CAknAsynCallbackRunner::~CAknAsynCallbackRunner() - { - Cancel(); - } - -void CAknAsynCallbackRunner::AsyncCallbackRunL( TInt aCurLink ) - { - iCurLink = aCurLink; - if ( !IsActive() ) - { - iStatus = KRequestPending; - TRequestStatus* status = &iStatus; - User::RequestComplete( status, KErrNone ); - SetActive(); - } - } - -void CAknAsynCallbackRunner::DoCancel() - { - } - -void CAknAsynCallbackRunner::RunL() - { - if ( iMsgQueryExtension && iCurLink >= 0 && - iCurLink < iMsgQueryExtension->iCallBackArray.Count() ) - { - iMsgQueryExtension->iCallBackArray[iCurLink].CallBack(); - } - } EXPORT_C CAknMessageQueryDialog* CAknMessageQueryDialog::NewL( TDesC& aMessage, const TTone& aTone ) { - _AKNTRACE_FUNC_ENTER; CAknMessageQueryDialog* self = new ( ELeave ) CAknMessageQueryDialog( aTone ); CleanupStack::PushL( self ); self->SetMessageTextL( aMessage ); CleanupStack::Pop(); //self AKNTASHOOK_ADDL( self, "CAknMessageQueryDialog" ); - _AKNTRACE_FUNC_EXIT; return self; } @@ -204,13 +148,11 @@ EXPORT_C CAknMessageQueryDialog::CAknMessageQueryDialog( const TTone aTone ) : CAknQueryDialog( aTone ) { - _AKNTRACE_FUNC_ENTER; #ifndef RD_NO_DIALOG_BORDERS iBorder = AknBorderId::EAknBorderNotePopup; #else iBorder = TGulBorder::ENone; #endif - _AKNTRACE_FUNC_EXIT; } //@deprecated @@ -259,14 +201,12 @@ EXPORT_C CAknMessageQueryDialog::~CAknMessageQueryDialog() { - _AKNTRACE( "[%s][%s] Enter", "CAknMessageQueryDialog", "~CAknMessageQueryDialog" ); AKNTASHOOK_REMOVE(); delete iMessage; delete iHeader; delete iHeaderImage; RegisterPointerEventObserver( EFalse ); delete iMsgQueryExtension; - _AKNTRACE( "[%s][%s] Exit", "CAknMessageQueryDialog", "~CAknMessageQueryDialog" ); } EXPORT_C void CAknMessageQueryDialog::SetMessageTextL( const TDesC& aMessage ) @@ -302,11 +242,8 @@ else { // SetLinkTextL creates new callback in the callback array for the new link - HBufC* linkText = aLinkText.AllocL(); - CleanupStack::PushL( linkText ); - iMsgQueryExtension->iFormatTextArray.AppendL( linkText ); - CleanupStack::Pop( linkText ); - iMsgQueryExtension->iFormatTypeArray.AppendL( EMsgQueryLink ); + iMsgQueryExtension->iFormatTextArray.Append( aLinkText.AllocL() ); + iMsgQueryExtension->iFormatTypeArray.Append( EMsgQueryLink ); // If the other method SetLink has been already called // the new link is finished by adding the link count @@ -349,10 +286,7 @@ if ( iMsgQueryExtension->iCallBackArray.Count() < iMsgQueryExtension->iLinkCount ) { // SetLink creates new callback in the callback array for the new link - if ( KErrNone != iMsgQueryExtension->iCallBackArray.Append( aCallBack ) ) - { - return; - } + iMsgQueryExtension->iCallBackArray.Append( aCallBack ); } } else if ( iMsgQueryExtension->iLinkCount < KMaxLinks ) @@ -365,10 +299,7 @@ else { // SetLink creates new callback in the callback array for the new link - if ( KErrNone != iMsgQueryExtension->iCallBackArray.Append( aCallBack ) ) - { - return; - } + iMsgQueryExtension->iCallBackArray.Append( aCallBack ); // If the other method SetLinkText has been already called // the new link is finished by adding the link count @@ -424,7 +355,6 @@ EXPORT_C void CAknMessageQueryDialog::PreLayoutDynInitL() { - _AKNTRACE_FUNC_ENTER; if ( !iMsgQueryExtension ) { CreateExtensionL(); @@ -495,7 +425,6 @@ headingPane->SetLayout(CAknPopupHeadingPane::EMessageQueryHeadingPane); // Use message query heading layout. headingPane->SetTouchObserver( iMsgQueryExtension ); } - _AKNTRACE_FUNC_EXIT; } @@ -697,7 +626,7 @@ } delete messageBuf; } - iMsgQueryExtension->iFormatTextLocationArray.AppendL( linkTextLocation ); + iMsgQueryExtension->iFormatTextLocationArray.Append( linkTextLocation ); return ETrue; } @@ -1057,22 +986,31 @@ TBool CAknMessageQueryDialog::ExecuteLinkL() { - _AKNTRACE_FUNC_ENTER; - CAknMessageQueryControl* control = STATIC_CAST( CAknMessageQueryControl*, Control( EAknMessageQueryContentId ) ); + CAknMessageQueryControl* control = STATIC_CAST( CAknMessageQueryControl*, Control( EAknMessageQueryContentId ) ); if( !control ) { - _AKNTRACE_FUNC_EXIT; return EFalse; } if( !control->LinkHighLighted() ) { - _AKNTRACE_FUNC_EXIT; return EFalse; } TInt curLink = control->CurrentLink(); - TRAP_IGNORE( iMsgQueryExtension->ExecuteLinkCallbackL( curLink ) ); - control->DehighlightLink(); - _AKNTRACE_FUNC_EXIT; + /** + * The local @c destroyed variable keeps track of the object destroyed state. + */ + TBool destroyed = EFalse; + iMsgQueryExtension->iDestroyedPtr = &destroyed; + TRAPD( err, iMsgQueryExtension->iCallBackArray[curLink].CallBack() ); + if ( !destroyed ) + { + iMsgQueryExtension->iDestroyedPtr = NULL; + } + User::LeaveIfError( err ); + if ( !destroyed ) + { + control->DehighlightLink(); + } return ETrue; }