uiacceltk/hitchcock/ServerCore/Src/alfstaticfactory.cpp
branchRCL_3
changeset 52 31fccae4f8a7
parent 51 e5af45d51884
equal deleted inserted replaced
51:e5af45d51884 52:31fccae4f8a7
    67     CAlfControl2(CHuiEnv& aSharedEnv, CAlfControl2** ptr, CAlfAppSrvSessionBase* aSession):
    67     CAlfControl2(CHuiEnv& aSharedEnv, CAlfControl2** ptr, CAlfAppSrvSessionBase* aSession):
    68         CHuiControl(aSharedEnv),
    68         CHuiControl(aSharedEnv),
    69         iPtr(ptr),
    69         iPtr(ptr),
    70         iSession(aSession)
    70         iSession(aSession)
    71         {}
    71         {}
    72         
    72 
       
    73     void ClearPtr()
       
    74         {
       
    75         iPtr = NULL;
       
    76         }
       
    77     
    73     TBool OfferEventL(const THuiEvent& aEvent)
    78     TBool OfferEventL(const THuiEvent& aEvent)
    74         {
    79         {
    75         if ( aEvent.IsPointerEvent() )
    80         if ( aEvent.IsPointerEvent() )
    76             {
    81             {
    77             // Update event coordinates to match the "client rect" of the application
    82             // Update event coordinates to match the "client rect" of the application
   114         return EFalse; // let env offer event to all ctrls it hits
   119         return EFalse; // let env offer event to all ctrls it hits
   115         }
   120         }
   116     
   121     
   117     ~CAlfControl2()
   122     ~CAlfControl2()
   118         {
   123         {
   119         *iPtr = 0;
   124 		// iPtr might have been cleared previously
       
   125         if (iPtr != NULL)
       
   126             {
       
   127             *iPtr = 0;
       
   128             }
   120         
   129         
   121         // Remove possbile pointer observers
   130         // Remove possible pointer observers
   122         if ( Env().DisplayCount() )
   131         if ( Env().DisplayCount() )
   123             {
   132             {
   124             CHuiDisplay& disp = Env().PrimaryDisplay(); // assume one display
   133             CHuiDisplay& disp = Env().PrimaryDisplay(); // assume one display
   125             disp.Roster().Observers(EHuiInputPointerDrag).RemoveIfFound(*this);
   134             disp.Roster().Observers(EHuiInputPointerDrag).RemoveIfFound(*this);
   126             disp.Roster().Observers(EHuiInputPointerLongTap).RemoveIfFound(*this);
   135             disp.Roster().Observers(EHuiInputPointerLongTap).RemoveIfFound(*this);
   142     void Release();
   151     void Release();
   143     TAny* GetInterface(const THuiInterfaceSupport& aInterface);
   152     TAny* GetInterface(const THuiInterfaceSupport& aInterface);
   144     void HandleCmdL(TInt aCommandId, const TDesC8& aInputBuffer, TDes8& aResponse);    
   153     void HandleCmdL(TInt aCommandId, const TDesC8& aInputBuffer, TDes8& aResponse);    
   145     CAlfControl2* iControl;
   154     CAlfControl2* iControl;
   146     ~CAlfControlHandler() 
   155     ~CAlfControlHandler() 
   147         { 
   156         {
       
   157 		// Clear the control's iPtr so that it wouldn't be left as dangling pointer
       
   158 		// and cause potential memory corruption
       
   159         if (iControl != NULL)
       
   160             {
       
   161             iControl->ClearPtr();
       
   162             }
       
   163         
   148         if (iControl && !iControl->ControlGroup())
   164         if (iControl && !iControl->ControlGroup())
   149             {
   165             {
   150             delete iControl; 
   166             delete iControl; 
   151             }
   167             }
   152         }
   168         }