uiacceltk/hitchcock/ServerCore/Src/alfstaticfactory.cpp
branchRCL_3
changeset 19 e5af45d51884
parent 18 1801340c26a2
child 20 31fccae4f8a7
equal deleted inserted replaced
18:1801340c26a2 19:e5af45d51884
    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     
       
    78     TBool OfferEventL(const THuiEvent& aEvent)
    73     TBool OfferEventL(const THuiEvent& aEvent)
    79         {
    74         {
    80         if ( aEvent.IsPointerEvent() )
    75         if ( aEvent.IsPointerEvent() )
    81             {
    76             {
    82             // Update event coordinates to match the "client rect" of the application
    77             // Update event coordinates to match the "client rect" of the application
   119         return EFalse; // let env offer event to all ctrls it hits
   114         return EFalse; // let env offer event to all ctrls it hits
   120         }
   115         }
   121     
   116     
   122     ~CAlfControl2()
   117     ~CAlfControl2()
   123         {
   118         {
   124 		// iPtr might have been cleared previously
   119         *iPtr = 0;
   125         if (iPtr != NULL)
       
   126             {
       
   127             *iPtr = 0;
       
   128             }
       
   129         
   120         
   130         // Remove possible pointer observers
   121         // Remove possbile pointer observers
   131         if ( Env().DisplayCount() )
   122         if ( Env().DisplayCount() )
   132             {
   123             {
   133             CHuiDisplay& disp = Env().PrimaryDisplay(); // assume one display
   124             CHuiDisplay& disp = Env().PrimaryDisplay(); // assume one display
   134             disp.Roster().Observers(EHuiInputPointerDrag).RemoveIfFound(*this);
   125             disp.Roster().Observers(EHuiInputPointerDrag).RemoveIfFound(*this);
   135             disp.Roster().Observers(EHuiInputPointerLongTap).RemoveIfFound(*this);
   126             disp.Roster().Observers(EHuiInputPointerLongTap).RemoveIfFound(*this);
   151     void Release();
   142     void Release();
   152     TAny* GetInterface(const THuiInterfaceSupport& aInterface);
   143     TAny* GetInterface(const THuiInterfaceSupport& aInterface);
   153     void HandleCmdL(TInt aCommandId, const TDesC8& aInputBuffer, TDes8& aResponse);    
   144     void HandleCmdL(TInt aCommandId, const TDesC8& aInputBuffer, TDes8& aResponse);    
   154     CAlfControl2* iControl;
   145     CAlfControl2* iControl;
   155     ~CAlfControlHandler() 
   146     ~CAlfControlHandler() 
   156         {
   147         { 
   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         
       
   164         if (iControl && !iControl->ControlGroup())
   148         if (iControl && !iControl->ControlGroup())
   165             {
   149             {
   166             delete iControl; 
   150             delete iControl; 
   167             }
   151             }
   168         }
   152         }