uifw/AvKon/src/AknPreviewPopUp.cpp
branchRCL_3
changeset 25 941195f2d488
parent 23 3d340a0166ff
child 50 a1caeb42b3a3
--- a/uifw/AvKon/src/AknPreviewPopUp.cpp	Tue May 11 16:27:42 2010 +0300
+++ b/uifw/AvKon/src/AknPreviewPopUp.cpp	Tue May 25 12:58:19 2010 +0300
@@ -78,6 +78,11 @@
 //
 CAknPreviewPopUp::~CAknPreviewPopUp()
     {
+    if( iIsDeleted )
+        {
+    	*iIsDeleted = ETrue ;
+        iIsDeleted = 0 ;
+        }
 
     if ( IsVisible() )
         {
@@ -519,7 +524,10 @@
 // -----------------------------------------------------------------------------
 //
 void CAknPreviewPopUp::HandlePointerEventL( const TPointerEvent& aPointerEvent )
-    {
+    {   
+	TBool isDelete = EFalse; 
+	iIsDeleted = &isDelete;
+	
     if ( AknLayoutUtils::PenEnabled() )
         {
         iCloseMenu = EFalse;
@@ -531,8 +539,14 @@
         // redirect pointer event to content
         if ( Rect().Contains( aPointerEvent.iPosition ) && IsVisible() )
             {
-            iAllowUpEvent = ETrue;
+            iAllowUpEvent = ETrue;         
+            CleanupStack::PushL( TCleanupItem( CleanLocalRef, this ) );
             CCoeControl::HandlePointerEventL( aPointerEvent );
+            CleanupStack::Pop();
+            if( isDelete )
+            	{
+            	return;
+            	}
             if ( !( iFlags & CAknPreviewPopUpController::EPermanentMode ) && aPointerEvent.iType == TPointerEvent::EButton1Up && IsVisible() )
                 {
             	  // if pointer up is already redirected to the content, but the popup is still visible,
@@ -603,7 +617,13 @@
                     aPointerEvent.iType == TPointerEvent::EButtonRepeat ||
                     (aPointerEvent.iType == TPointerEvent::EButton1Up && iAllowUpEvent ) )
                     {
+                    CleanupStack::PushL( TCleanupItem( CleanLocalRef, this ) );
                     CCoeControl::HandlePointerEventL( aPointerEvent );
+                    CleanupStack::Pop();
+                    if( isDelete )
+                    	{
+                    	return;
+                    	}
                     }
                 }
             else
@@ -611,7 +631,13 @@
                 if ( aPointerEvent.iType == TPointerEvent::EDrag || 
                     aPointerEvent.iType == TPointerEvent::EButtonRepeat )
                     {
+                    CleanupStack::PushL( TCleanupItem( CleanLocalRef, this ) );
                     CCoeControl::HandlePointerEventL( aPointerEvent );
+                    CleanupStack::Pop();
+                    if( isDelete )
+                    	{
+                    	return;
+                    	}
                     }
                 }
                 
@@ -621,6 +647,8 @@
             iAllowUpEvent = EFalse;
             }
         }
+       
+    iIsDeleted = NULL;
     }
     
 // -----------------------------------------------------------------------------
@@ -807,5 +835,14 @@
         }   
     }
 
+// -----------------------------------------------------------------------------
+// CAknPreviewPopUp::CleanLocalRef
+// -----------------------------------------------------------------------------
+//
+void CAknPreviewPopUp::CleanLocalRef( TAny* any )
+    {
+    static_cast<CAknPreviewPopUp*>( any )->iIsDeleted = NULL;
+    }
+
 //  End of File