Skip to content

Commit c2146b3

Browse files
author
Qt Continuous Integration System
committed
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-s60-public into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-s60-public: Reduce unnecessary QtCore DLL loads during Symbian app thread creation
2 parents f86ca84 + 04ae67d commit c2146b3

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

src/s60main/newallocator_hook.cpp

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,26 +109,38 @@ struct SStdEpocThreadCreateInfo : public SThreadCreateInfo
109109
* startup. On return, there is some kind of heap allocator installed on the
110110
* thread.
111111
*/
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+
112117
TInt UserHeap::SetupThreadHeap(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo)
113118
{
114119
TInt r = KErrNone;
115120

116121
#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;
128143
}
129-
qtcore.Close();
130-
if (libFunc)
131-
return r;
132144
}
133145
#endif
134146

0 commit comments

Comments
 (0)