diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2010-06-11 11:11:05 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@accenture.com> | 2010-06-11 15:14:19 (GMT) |
commit | 5471f3cc5f3b1ec9fbe15ba35ab23dfd9fcc42c9 (patch) | |
tree | 5207081b3e4dbab15ae3a2b14b622569549d384d /src/gui/kernel/qapplication_s60.cpp | |
parent | da424a2e8a8570e24eac6272bb410a51381fcad7 (diff) | |
download | Qt-5471f3cc5f3b1ec9fbe15ba35ab23dfd9fcc42c9.zip Qt-5471f3cc5f3b1ec9fbe15ba35ab23dfd9fcc42c9.tar.gz Qt-5471f3cc5f3b1ec9fbe15ba35ab23dfd9fcc42c9.tar.bz2 |
Thread safety for QFontEngineS60
On symbian, creating fonts requires a connection to the window server.
Window server sessions are not sharable across threads.
To avoid QFont crashing when used outside the GUI thread, we construct a
private session to the window server when the shared CONE session is not
available.
(CCoeEnv::Static() uses TLS, so it returns null outside of GUI thread)
The private session and screen device are stored in QThreadStorage, so
they are automatically deleted when the QThread exits.
Task-number: QTBUG-8874
Reviewed-by: mread
Diffstat (limited to 'src/gui/kernel/qapplication_s60.cpp')
-rw-r--r-- | src/gui/kernel/qapplication_s60.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 78027b2..f39b462 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -2046,4 +2046,29 @@ void QApplication::restoreOverrideCursor() #endif // QT_NO_CURSOR +QS60ThreadLocalData::QS60ThreadLocalData() +{ + CCoeEnv *env = CCoeEnv::Static(); + if (env) { + //if this is the UI thread, share objects owned by CONE + usingCONEinstances = true; + wsSession = env->WsSession(); + screenDevice = env->ScreenDevice(); + } + else { + usingCONEinstances = false; + qt_symbian_throwIfError(wsSession.Connect(qt_s60GetRFs())); + screenDevice = new CWsScreenDevice(wsSession); + screenDevice->Construct(); + } +} + +QS60ThreadLocalData::~QS60ThreadLocalData() +{ + if (!usingCONEinstances) { + delete screenDevice; + wsSession.Close(); + } +} + QT_END_NAMESPACE |