summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@sosco.com>2009-08-24 07:25:46 (GMT)
committerShane Kearns <shane.kearns@sosco.com>2009-08-24 07:32:10 (GMT)
commit6dade01b24f3fd314cb6ec9c2979348e78740a52 (patch)
tree881a70495578a70deb1f4684e16340403015fc70
parent0f42290719ebe6d930ba28fdf256e64d9c97be37 (diff)
downloadQt-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
-rw-r--r--src/corelib/io/qfilesystemwatcher_symbian.cpp3
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp7
-rw-r--r--src/corelib/kernel/qcore_symbian_p.cpp31
-rw-r--r--src/corelib/kernel/qcore_symbian_p.h3
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp23
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h7
-rw-r--r--src/gui/kernel/qclipboard_s60.cpp6
7 files changed, 42 insertions, 38 deletions
diff --git a/src/corelib/io/qfilesystemwatcher_symbian.cpp b/src/corelib/io/qfilesystemwatcher_symbian.cpp
index b920952..730786f 100644
--- a/src/corelib/io/qfilesystemwatcher_symbian.cpp
+++ b/src/corelib/io/qfilesystemwatcher_symbian.cpp
@@ -44,7 +44,6 @@
#include "qfileinfo.h"
#include "qdebug.h"
#include "private/qcore_symbian_p.h"
-#include "private/qcoreapplication_p.h"
#include <QDir>
#ifndef QT_NO_FILESYSTEMWATCHER
@@ -271,7 +270,7 @@ void QSymbianFileSystemWatcherEngine::addNativeListener(const QString &directory
QMutexLocker locker(&mutex);
QString nativeDir(QDir::toNativeSeparators(directoryPath));
TPtrC ptr(qt_QString2TPtrC(nativeDir));
- currentEvent = CNotifyChangeEvent::New(QCoreApplicationPrivate::fsSession(), ptr, this, directoryPath.endsWith(QChar(L'/'), Qt::CaseSensitive));
+ currentEvent = CNotifyChangeEvent::New(qt_s60GetRFs(), ptr, this, directoryPath.endsWith(QChar(L'/'), Qt::CaseSensitive));
syncCondition.wakeOne();
}
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 4ee5c68..62edb0e 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -61,7 +61,6 @@
# include <syslimits.h>
# include <f32file.h>
# include "private/qcore_symbian_p.h"
-# include "private/qcoreapplication_p.h"
#endif
#include <errno.h>
#if !defined(QWS) && defined(Q_OS_MAC)
@@ -401,7 +400,7 @@ bool QFSFileEngine::copy(const QString &newName)
{
#if defined(Q_OS_SYMBIAN)
Q_D(QFSFileEngine);
- RFs& rfs = QCoreApplicationPrivate::fsSession();
+ RFs rfs = qt_s60GetRFs();
CFileMan* fm = NULL;
QString oldNative(QDir::toNativeSeparators(d->filePath));
TPtrC oldPtr(qt_QString2TPtrC(oldNative));
@@ -608,7 +607,7 @@ QFileInfoList QFSFileEngine::drives()
QFileInfoList ret;
#if defined(Q_OS_SYMBIAN)
TDriveList driveList;
- RFs &rfs = QCoreApplicationPrivate::fsSession();
+ RFs rfs = qt_s60GetRFs();
TInt err = rfs.DriveList(driveList);
if (err == KErrNone) {
for (char i = 0; i < KMaxDrives; i++) {
@@ -660,7 +659,7 @@ bool QFSFileEnginePrivate::isSymlink() const
static bool _q_isSymbianHidden(const QString &path, bool isDir)
{
bool retval = false;
- RFs rfs = QCoreApplicationPrivate::fsSession();
+ RFs rfs = qt_s60GetRFs();
QFileInfo fi(path);
QString absPath = fi.absoluteFilePath();
if (isDir && absPath.at(absPath.size()-1) != QChar('/')) {
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
diff --git a/src/gui/kernel/qclipboard_s60.cpp b/src/gui/kernel/qclipboard_s60.cpp
index 26ea844..9a2629c 100644
--- a/src/gui/kernel/qclipboard_s60.cpp
+++ b/src/gui/kernel/qclipboard_s60.cpp
@@ -49,7 +49,7 @@
#include "qbuffer.h"
#include "qwidget.h"
#include "qevent.h"
-#include "private/qapplication_p.h"
+#include "private/qcore_symbian_p.h"
#include <QtDebug>
// Symbian's clipboard
@@ -194,7 +194,7 @@ const QMimeData* QClipboard::mimeData(Mode mode) const
if (d)
{
TRAPD(err,{
- RFs& fs = QCoreApplicationPrivate::fsSession();
+ RFs fs = qt_s60GetRFs();
CClipboard* cb = CClipboard::NewForReadingLC(fs);
Q_ASSERT(cb);
RStoreReadStream stream;
@@ -220,7 +220,7 @@ void QClipboard::setMimeData(QMimeData* src, Mode mode)
if (d)
{
TRAPD(err,{
- RFs& fs = QCoreApplicationPrivate::fsSession();
+ RFs fs = qt_s60GetRFs();
CClipboard* cb = CClipboard::NewForWritingLC(fs);
RStoreWriteStream stream;
TStreamId stid = stream.CreateLC(cb->Store());