windowing/windowserver/nga/SERVER/openwfc/WSTOP.CPP
branchRCL_3
changeset 20 25ffed67c7ef
parent 19 bbf46f59e123
equal deleted inserted replaced
19:bbf46f59e123 20:25ffed67c7ef
    30 #include "panics.h"
    30 #include "panics.h"
    31 #include "inifile.h"
    31 #include "inifile.h"
    32 #include "pointer.h"
    32 #include "pointer.h"
    33 #include "WSGRAPHICDRAWERFACTORY.H"
    33 #include "WSGRAPHICDRAWERFACTORY.H"
    34 #include "redrawmsgwindow.h"
    34 #include "redrawmsgwindow.h"
    35 #include <graphics/WSGRAPHICDRAWERINTERFACE.H>
    35 #include <Graphics/WSGRAPHICDRAWERINTERFACE.H>
    36 #include "WsMemMgr.h"
    36 #include "WsMemMgr.h"
    37 #include "backedupwindow.h"
    37 #include "backedupwindow.h"
    38 #include "wsfont.h"
    38 #include "wsfont.h"
    39 #include "registeredsurfacemap.h"
    39 #include "registeredsurfacemap.h"
    40 #include <EGL/egl.h>
    40 #include <EGL/egl.h>
    44 #endif
    44 #endif
    45 
    45 
    46 #include "registeredsurfacemap.h"
    46 #include "registeredsurfacemap.h"
    47 #include "windowelementset.h"
    47 #include "windowelementset.h"
    48 #include "wspluginmanager.h"
    48 #include "wspluginmanager.h"
    49 #include "renderorientationtracker.h"
       
    50 
    49 
    51 // IDs of p&s properties that optionally contain callbacks that may be used
    50 // IDs of p&s properties that optionally contain callbacks that may be used
    52 // to release singletons owned by libraries at shutdown in order to make 
    51 // to release singletons owned by libraries at shutdown in order to make 
    53 // the memory leak tests work.
    52 // the memory leak tests work.
    54 // By convention, the ID is the same as the UID3 of the libary.
    53 // By convention, the ID is the same as the UID3 of the libary.
   208 const CWsClient* CWsTop::iTriggerHeapCheckOnClientExit=NULL;
   207 const CWsClient* CWsTop::iTriggerHeapCheckOnClientExit=NULL;
   209 TWsCheckHeapOnDisconnectMode CWsTop::iHeapCheckMode=EWsCheckHeapOnDisconnectModeNone;
   208 TWsCheckHeapOnDisconnectMode CWsTop::iHeapCheckMode=EWsCheckHeapOnDisconnectModeNone;
   210 TInt CWsTop::iCheckHeapResult=KErrNotReady;
   209 TInt CWsTop::iCheckHeapResult=KErrNotReady;
   211 TBool CWsTop::iDoHeapCheckAndRestart=EFalse;
   210 TBool CWsTop::iDoHeapCheckAndRestart=EFalse;
   212 #define RFbsSession_SendCommand_ShutDownMessage 1	// A FBS message that is not published yet and probably never will be.
   211 #define RFbsSession_SendCommand_ShutDownMessage 1	// A FBS message that is not published yet and probably never will be.
   213 CWsRenderOrienationTracker* CWsTop::iRenderOrientationTracker=NULL;
       
   214 
   212 
   215 static void DefineSingletonKey(const TUid& aSingletonKey)
   213 static void DefineSingletonKey(const TUid& aSingletonKey)
   216 /**
   214 /**
   217  * Defines a new property for a singleton key. WServ must only process 
   215  * Defines a new property for a singleton key. WServ must only process 
   218  * singleton keys that it created to prevent a malicious process with the 
   216  * singleton keys that it created to prevent a malicious process with the 
   281     }
   279     }
   282 
   280 
   283 void CWsTop::DeleteStaticsL()
   281 void CWsTop::DeleteStaticsL()
   284 	{
   282 	{
   285 	iShuttingDown=ETrue;
   283 	iShuttingDown=ETrue;
   286 	delete iRenderOrientationTracker;	
       
   287 	
       
   288 	CClick::DeleteStatics();
   284 	CClick::DeleteStatics();
   289 	TWsPointer::Stop();
   285 	TWsPointer::Stop();
   290 	CWsClient::DeleteStatics();
   286 	CWsClient::DeleteStatics();
   291 //
   287 //
   292 	delete iShellStarter;
   288 	delete iShellStarter;
   555 	if(startShell)
   551 	if(startShell)
   556 		{
   552 		{
   557 		StartShell();
   553 		StartShell();
   558 		}
   554 		}
   559 	UserSvr::WsRegisterSwitchOnScreenHandling(ETrue);
   555 	UserSvr::WsRegisterSwitchOnScreenHandling(ETrue);
   560 	
       
   561 	iRenderOrientationTracker = CWsRenderOrienationTracker::NewL();	
       
   562 	}
   556 	}
   563 
   557 
   564 
   558 
   565 void CWsTop::InitScreenL( TInt aScreenNumber)  // static
   559 void CWsTop::InitScreenL( TInt aScreenNumber)  // static
   566 	{
   560 	{
   901 void CWsTop::SetCheckHeapOnDisconnectMode(TWsCheckHeapOnDisconnectMode aCheckHeapOnDisconnectMode)
   895 void CWsTop::SetCheckHeapOnDisconnectMode(TWsCheckHeapOnDisconnectMode aCheckHeapOnDisconnectMode)
   902 	{
   896 	{
   903 	iHeapCheckMode=aCheckHeapOnDisconnectMode;
   897 	iHeapCheckMode=aCheckHeapOnDisconnectMode;
   904 	}
   898 	}
   905 
   899 
       
   900 static void ReportAllCurrentLevelLeaks()
       
   901     {
       
   902     class RHeapWalk: public RHeap
       
   903         {
       
   904     public:
       
   905          static void WalkCheckCell(TAny* aPtr, TCellType aType, TAny* aCell, TInt aLen)
       
   906              {
       
   907              RHeapWalk* heap=(RHeapWalk*)aPtr;
       
   908              (void)aCell;
       
   909              switch(aType)
       
   910                  {
       
   911                  case EGoodAllocatedCell:
       
   912                      if ( ((SDebugCell*)aCell)->nestingLevel == heap->iNestingLevel )
       
   913                          {
       
   914                          RDebug::Printf("Leaked heap cell: level %i, serial %i @ %08x : len=%d", 
       
   915                                             heap->iNestingLevel, ((SDebugCell*)aCell)->allocCount, aCell, aLen);
       
   916                          }
       
   917                     break;
       
   918                  }
       
   919              }
       
   920         };
       
   921     
       
   922     User::Heap().DebugFunction(RHeap::EWalk, (TAny*)RHeapWalk::WalkCheckCell, &User::Heap());
       
   923     }
       
   924 
   906 TBool CWsTop::NeedsHeapCheckAndRestart(TInt aStartHeapCount)
   925 TBool CWsTop::NeedsHeapCheckAndRestart(TInt aStartHeapCount)
   907 	{
   926 	{
   908 	if (!iDoHeapCheckAndRestart)
   927 	if (!iDoHeapCheckAndRestart)
   909 		return(EFalse);
   928 		return(EFalse);
   910 	iDoHeapCheckAndRestart=EFalse;
   929 	iDoHeapCheckAndRestart=EFalse;
   911 	iCheckHeapResult=User::Heap().Count()-aStartHeapCount;
   930 	iCheckHeapResult=User::Heap().Count()-aStartHeapCount;
   912 	if(iCheckHeapResult > 0)
   931 	if(iCheckHeapResult > 0)
   913 	    {
   932 	    {
   914 	    const TUint32 orphanedCell = User::Heap().__DbgMarkEnd(aStartHeapCount);
   933 	    const TUint32 orphanedCell = User::Heap().__DbgMarkEnd(aStartHeapCount);
   915 	    RDebug::Printf("Memory leak detected in wserv. First orphaned cell: 0x%8x", orphanedCell);
   934 	    RDebug::Printf("Memory leak detected in wserv. First orphaned cell: 0x%8x", orphanedCell);
       
   935 	    ReportAllCurrentLevelLeaks();
   916 	    }
   936 	    }
   917 	return(ETrue);
   937 	return(ETrue);
   918 	}
   938 	}
   919 
   939 
   920 TInt CWsTop::FetchCheckHeapResult()
   940 TInt CWsTop::FetchCheckHeapResult()
   961 			return ETrue;
   981 			return ETrue;
   962 			}
   982 			}
   963 		}
   983 		}
   964 	return EFalse;
   984 	return EFalse;
   965 	}
   985 	}
   966 
       
   967 /**
       
   968 Checks to see if the render orientation has changed, and publishes any new orientaion
       
   969 via publish and subscribe
       
   970 
       
   971 @see KRenderOrientationCategory
       
   972 @see KRenderOrientationKey 
       
   973 */
       
   974 void CWsTop::CheckRenderOrientation()
       
   975     {
       
   976     iRenderOrientationTracker->CheckRenderOrientation();
       
   977     }
       
   978 
   986 
   979 typedef TInt (*ShellEntryPoint)(TAny *);
   987 typedef TInt (*ShellEntryPoint)(TAny *);
   980 
   988 
   981 #if defined(__WINS__)
   989 #if defined(__WINS__)
   982 LOCAL_D const TUint KHeapSize=0x10000;
   990 LOCAL_D const TUint KHeapSize=0x10000;