mmappcomponents/collectionhelper/src/mpxcollectionuihelperimp.cpp
changeset 20 b1fb57be53fe
parent 2 7a9a8e73f54b
child 25 d881023c13eb
equal deleted inserted replaced
4:d45095c2f4f3 20:b1fb57be53fe
    80     iRemainder = 0;
    80     iRemainder = 0;
    81     iTotalChunkNumber = 0;
    81     iTotalChunkNumber = 0;
    82     iChunkNumber = 0;
    82     iChunkNumber = 0;
    83     iChunkSize = 0;
    83     iChunkSize = 0;
    84     iArrayIndex = 0;
    84     iArrayIndex = 0;
    85     iRefCount = 1;
       
    86 
       
    87     }
    85     }
    88 
    86 
    89 
    87 
    90 // ---------------------------------------------------------------------------
    88 // ---------------------------------------------------------------------------
    91 // Two-Phased Constructor
    89 // Two-Phased Constructor
   103 // Two-Phased Constructor
   101 // Two-Phased Constructor
   104 // ---------------------------------------------------------------------------
   102 // ---------------------------------------------------------------------------
   105 //
   103 //
   106 CMPXCollectionUiHelperImp* CMPXCollectionUiHelperImp::NewLC(const TUid& aModeId)
   104 CMPXCollectionUiHelperImp* CMPXCollectionUiHelperImp::NewLC(const TUid& aModeId)
   107     {
   105     {
   108 
   106     CMPXCollectionUiHelperImp* self = new( ELeave ) CMPXCollectionUiHelperImp();
   109 	CMPXCollectionUiHelperImp* self(NULL);
   107     CleanupStack::PushL( self );
   110 
   108     self->ConstructL(aModeId);
   111     if ( aModeId == KMcModeDefault )
   109     return self;
   112         {
       
   113     	self = reinterpret_cast<CMPXCollectionUiHelperImp*>(Dll::Tls());
       
   114     	if ( !self )
       
   115             {
       
   116             self = new( ELeave ) CMPXCollectionUiHelperImp();
       
   117             CleanupStack::PushL( self );
       
   118 			self->ConstructL(aModeId);
       
   119             Dll::SetTls( self );
       
   120             }
       
   121         else
       
   122             {
       
   123             self->iRefCount++;
       
   124             CleanupStack::PushL( self );
       
   125             }
       
   126 
       
   127 		return self;
       
   128         }
       
   129     else
       
   130 		{
       
   131 		self = new( ELeave ) CMPXCollectionUiHelperImp();
       
   132 		CleanupStack::PushL( self );
       
   133 		self->ConstructL(aModeId);
       
   134 		return self;
       
   135 		}
       
   136     }
   110     }
   137 
   111 
   138 // ---------------------------------------------------------------------------
   112 // ---------------------------------------------------------------------------
   139 // Virtual Destructor
   113 // Virtual Destructor
   140 // ---------------------------------------------------------------------------
   114 // ---------------------------------------------------------------------------
  1040 // Frees this object
  1014 // Frees this object
  1041 // ---------------------------------------------------------------------------
  1015 // ---------------------------------------------------------------------------
  1042 //
  1016 //
  1043 void CMPXCollectionUiHelperImp::Close()
  1017 void CMPXCollectionUiHelperImp::Close()
  1044     {
  1018     {
  1045 
  1019     delete this;
  1046     ASSERT( iRefCount > 0 );
       
  1047     if ( --iRefCount == 0 )
       
  1048         {
       
  1049         // last client released
       
  1050         CMPXCollectionUiHelperImp* s = reinterpret_cast<CMPXCollectionUiHelperImp*>( Dll::Tls() );
       
  1051         if ( s )
       
  1052             {
       
  1053             if ( s == this )
       
  1054                 {
       
  1055                 delete this;
       
  1056                 Dll::SetTls( NULL );
       
  1057                 }
       
  1058             }
       
  1059         }
       
  1060     }
  1020     }
  1061 
  1021 
  1062 // ---------------------------------------------------------------------------
  1022 // ---------------------------------------------------------------------------
  1063 // Test if the specified title already exists for the category
  1023 // Test if the specified title already exists for the category
  1064 // ---------------------------------------------------------------------------
  1024 // ---------------------------------------------------------------------------