diff options
author | Shane Kearns <shane.kearns@sosco.com> | 2009-08-24 07:25:46 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@sosco.com> | 2009-08-24 07:32:10 (GMT) |
commit | 6dade01b24f3fd314cb6ec9c2979348e78740a52 (patch) | |
tree | 881a70495578a70deb1f4684e16340403015fc70 /src/corelib/kernel | |
parent | 0f42290719ebe6d930ba28fdf256e64d9c97be37 (diff) | |
download | Qt-6dade01b24f3fd314cb6ec9c2979348e78740a52.zip Qt-6dade01b24f3fd314cb6ec9c2979348e78740a52.tar.gz Qt-6dade01b24f3fd314cb6ec9c2979348e78740a52.tar.bz2 |
Make the singleton file server session independent of QCoreApplication
After review comments, changed the file server session
from a member of QCoreApplication to a Q_GLOBAL_STATIC, because some
applications will want to access files before constructing the
QApplication.
Reviewed-By: Janne Anttila
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qcore_symbian_p.cpp | 31 | ||||
-rw-r--r-- | src/corelib/kernel/qcore_symbian_p.h | 3 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 23 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreapplication_p.h | 7 |
4 files changed, 35 insertions, 29 deletions
diff --git a/src/corelib/kernel/qcore_symbian_p.cpp b/src/corelib/kernel/qcore_symbian_p.cpp index a7d2694..957b92c 100644 --- a/src/corelib/kernel/qcore_symbian_p.cpp +++ b/src/corelib/kernel/qcore_symbian_p.cpp @@ -175,5 +175,36 @@ Q_CORE_EXPORT TLibraryFunction qt_resolveS60PluginFunc(int ordinal) return qt_s60_plugin_resolver()->resolve(ordinal); } +/*! +\internal +Provides global access to a shared RFs. +*/ +class QS60RFsSession +{ +public: + QS60RFsSession() { + qt_symbian_throwIfError(iFs.Connect()); + qt_symbian_throwIfError(iFs.ShareProtected()); + } + + ~QS60RFsSession() { + iFs.Close(); + } + + RFs& GetRFs() { + return iFs; + } + +private: + + RFs iFs; +}; + +Q_GLOBAL_STATIC(QS60RFsSession, qt_s60_RFsSession); + +Q_CORE_EXPORT RFs& qt_s60GetRFs() +{ + return qt_s60_RFsSession()->GetRFs(); +} QT_END_NAMESPACE diff --git a/src/corelib/kernel/qcore_symbian_p.h b/src/corelib/kernel/qcore_symbian_p.h index 2a81b99..60bf95e 100644 --- a/src/corelib/kernel/qcore_symbian_p.h +++ b/src/corelib/kernel/qcore_symbian_p.h @@ -58,6 +58,7 @@ #include <qstring.h> #include <qrect.h> #include <qhash.h> +#include <f32file.h> QT_BEGIN_HEADER @@ -136,6 +137,8 @@ enum S60PluginFuncOrdinals Q_CORE_EXPORT TLibraryFunction qt_resolveS60PluginFunc(int ordinal); +Q_CORE_EXPORT RFs& qt_s60GetRFs(); + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 74b5140..dd3027b 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -271,12 +271,6 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv) qt_application_thread_id = QThread::currentThreadId(); #endif -#ifdef Q_OS_SYMBIAN - if(KErrNone != fileServerSession.Connect()) - qFatal("FATAL: QCoreApplicationPrivate can't connect to file server"); - fileServerSession.ShareProtected(); //makes the handle ok for multithreading and IPC -#endif - // note: this call to QThread::currentThread() may end up setting theMainThread! if (QThread::currentThread() != theMainThread) qWarning("WARNING: QApplication was not created in the main() thread."); @@ -284,9 +278,6 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv) QCoreApplicationPrivate::~QCoreApplicationPrivate() { -#ifdef Q_OS_SYMBIAN - fileServerSession.Close(); -#endif if (threadData) { #ifndef QT_NO_THREAD void *data = &threadData->tls; @@ -825,18 +816,6 @@ bool QCoreApplicationPrivate::notify_helper(QObject *receiver, QEvent * event) return receiver->event(event); } -#ifdef Q_OS_SYMBIAN -/*!\internal - - Accessor for shared global file server session - */ -RFs QCoreApplicationPrivate::fileServerSession; -RFs& QCoreApplicationPrivate::fsSession() -{ - return fileServerSession; -} -#endif - /*! Returns true if an application object has not been created yet; otherwise returns false. @@ -2193,7 +2172,7 @@ QStringList QCoreApplication::libraryPaths() if (tempPath.at(tempPath.length() - 1) != QChar('\\')) { tempPath += QChar('\\'); } - RFs& fs = QCoreApplicationPrivate::fsSession(); + RFs& fs = qt_s60GetRFs(); TPtrC tempPathPtr(reinterpret_cast<const TText*> (tempPath.constData())); TFindFile finder(fs); TInt err = finder.FindByDir(tempPathPtr, tempPathPtr); diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 1adb837..6c30ce8 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -90,10 +90,6 @@ public: static QString macMenuBarName(); #endif -#ifdef Q_OS_SYMBIAN - static RFs& fsSession(); -#endif - static QThread *theMainThread; static QThread *mainThread(); static bool checkInstance(const char *method); @@ -126,9 +122,6 @@ public: static uint attribs; static inline bool testAttribute(uint flag) { return attribs & (1 << flag); } -#ifdef Q_OS_SYMBIAN - static RFs fileServerSession; //this should be moved into a symbian file engine if/when one is written -#endif }; QT_END_NAMESPACE |