@@ -109,26 +109,38 @@ struct SStdEpocThreadCreateInfo : public SThreadCreateInfo
109
109
* startup. On return, there is some kind of heap allocator installed on the
110
110
* thread.
111
111
*/
112
+ typedef int (*TSetupThreadHeapFunc)(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo);
113
+ // keep the SetupThreadHeap() pointer so that we don't reload QtCore.dll after the first time
114
+ static TSetupThreadHeapFunc gp_qt_symbian_SetupThreadHeap = 0 ;
115
+ static bool gp_qt_symbian_SetupThreadHeap_set = false ;
116
+
112
117
TInt UserHeap::SetupThreadHeap (TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo)
113
118
{
114
119
TInt r = KErrNone;
115
120
116
121
#ifndef __WINS__
117
- // attempt to create the fast allocator through a known export ordinal in qtcore.dll
118
- RLibrary qtcore;
119
- if (qtcore.Load (QtCoreLibName) == KErrNone)
120
- {
121
- const int qt_symbian_SetupThreadHeap_eabi_ordinal = 3713 ;
122
- TLibraryFunction libFunc = qtcore.Lookup (qt_symbian_SetupThreadHeap_eabi_ordinal);
123
- if (libFunc)
124
- {
125
- typedef int (*TSetupThreadHeapFunc)(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo);
126
- TSetupThreadHeapFunc p_qt_symbian_SetupThreadHeap = TSetupThreadHeapFunc (libFunc);
127
- r = (*p_qt_symbian_SetupThreadHeap)(aNotFirst, aInfo);
122
+ // on first call, aNotFirst will be false.
123
+ // on second call, gp_qt_symbian_SetupThreadHeap_set will be false(!) because WSD is zeroed after the first call
124
+ // on subsequent calls, both will be true and we can use the stored SetupThreadHeap() pointer
125
+ if (aNotFirst && gp_qt_symbian_SetupThreadHeap_set) {
126
+ if (gp_qt_symbian_SetupThreadHeap)
127
+ return (*gp_qt_symbian_SetupThreadHeap)(aNotFirst, aInfo);
128
+ } else {
129
+ // attempt to create the fast allocator through a known export ordinal in qtcore.dll
130
+ RLibrary qtcore;
131
+ gp_qt_symbian_SetupThreadHeap_set = true ;
132
+ if (qtcore.Load (QtCoreLibName) == KErrNone) {
133
+ const int qt_symbian_SetupThreadHeap_eabi_ordinal = 3713 ;
134
+ TLibraryFunction libFunc = qtcore.Lookup (qt_symbian_SetupThreadHeap_eabi_ordinal);
135
+ if (libFunc) {
136
+ TSetupThreadHeapFunc p_qt_symbian_SetupThreadHeap = TSetupThreadHeapFunc (libFunc);
137
+ gp_qt_symbian_SetupThreadHeap = p_qt_symbian_SetupThreadHeap;
138
+ r = (*p_qt_symbian_SetupThreadHeap)(aNotFirst, aInfo);
139
+ }
140
+ qtcore.Close ();
141
+ if (libFunc)
142
+ return r;
128
143
}
129
- qtcore.Close ();
130
- if (libFunc)
131
- return r;
132
144
}
133
145
#endif
134
146
0 commit comments