13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "WidgetUiApp.h" |
18 |
19 #include "WidgetUiDocument.h" |
19 #include "WidgetUiApp.h" |
20 #include <MemoryManager.h> |
20 #include "WidgetUiDocument.h" |
21 #include "widgetappdefs.rh" |
21 #include "MemoryManager.h" |
22 #include <eikstart.h> |
22 #include "widgetappdefs.rh" |
23 #include <u32std.h> |
23 #include <eikstart.h> |
24 |
24 |
25 // EXTERNAL DATA STRUCTURES |
25 // EXTERNAL DATA STRUCTURES |
26 |
26 |
27 // EXTERNAL FUNCTION PROTOTYPES |
27 // EXTERNAL FUNCTION PROTOTYPES |
28 |
28 |
86 { |
86 { |
87 return new CWidgetUiApp; |
87 return new CWidgetUiApp; |
88 } |
88 } |
89 |
89 |
90 // ----------------------------------------------------------------------------- |
90 // ----------------------------------------------------------------------------- |
91 // SetupThreadHeap - Called for heap creation of thread in this process. |
|
92 // This approach used to keep correct heap for pointers held in static data objects |
|
93 // when they are destructed after E32Main() by OS. |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 EXPORT_C TInt UserHeap::SetupThreadHeap(TBool aSubThread, SStdEpocThreadCreateInfo& aInfo) |
|
97 { |
|
98 TInt r = KErrNone; |
|
99 if (!aInfo.iAllocator && aInfo.iHeapInitialSize>0) |
|
100 { |
|
101 // new heap required |
|
102 RHeap* pH = NULL; |
|
103 r = CreateThreadHeap(aInfo, pH); |
|
104 if (r == KErrNone && !aSubThread) |
|
105 { |
|
106 // main thread - new allocator created and set as default heap |
|
107 MemoryManager::CreateFastAllocator(); |
|
108 } |
|
109 } |
|
110 else if (aInfo.iAllocator) |
|
111 { |
|
112 // sharing a heap |
|
113 RAllocator* pA = aInfo.iAllocator; |
|
114 pA->Open(); |
|
115 User::SwitchAllocator(pA); |
|
116 } |
|
117 |
|
118 return r; |
|
119 } |
|
120 |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // E32Main |
91 // E32Main |
124 // |
92 // |
125 // ----------------------------------------------------------------------------- |
93 // ----------------------------------------------------------------------------- |
126 // |
94 // |
127 GLDEF_C TInt E32Main() |
95 GLDEF_C TInt E32Main() |
128 { |
96 { |
129 // initialize MemmoryManager |
97 RAllocator* oldAllocator = MemoryManager::SwitchToFastAllocator(); |
130 MemoryManager::InitFastAllocator(); |
98 __UHEAP_MARK; |
131 |
99 TInt result = EikStart::RunApplication( NewApplication ); |
132 return EikStart::RunApplication(NewApplication); |
100 __UHEAP_MARKEND; |
|
101 MemoryManager::CloseFastAllocator(oldAllocator); |
|
102 return result; |
133 } |
103 } |
134 |
104 |
135 // End of File |
105 // End of File |