summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@sosco.com>2009-08-20 14:09:00 (GMT)
committerShane Kearns <shane.kearns@sosco.com>2009-08-20 14:09:00 (GMT)
commitd4c0be3b5758b37ef9da6fcbce4c5a6d84f3a52b (patch)
tree9557e933bc640009f587c7b58062d57f8ada9f34 /src/corelib
parent06524f769fec76fa7ebcc39ac88ac9e08c720677 (diff)
downloadQt-d4c0be3b5758b37ef9da6fcbce4c5a6d84f3a52b.zip
Qt-d4c0be3b5758b37ef9da6fcbce4c5a6d84f3a52b.tar.gz
Qt-d4c0be3b5758b37ef9da6fcbce4c5a6d84f3a52b.tar.bz2
performance: refactored use of RFs so corelib and gui share one session
Opening and closing sessions has a performance impact on Symbian, so all users of RFs now share a single session. If a native file engine is written for Symbian (instead of the posix one currently in use) then that could own the global data instead of QCoreApplication. Task-number: 247617 Reviewed-by: jbarron
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qfilesystemwatcher_symbian.cpp6
-rw-r--r--src/corelib/io/qfilesystemwatcher_symbian_p.h1
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp88
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp49
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h11
5 files changed, 84 insertions, 71 deletions
diff --git a/src/corelib/io/qfilesystemwatcher_symbian.cpp b/src/corelib/io/qfilesystemwatcher_symbian.cpp
index 412372a..3320e18 100644
--- a/src/corelib/io/qfilesystemwatcher_symbian.cpp
+++ b/src/corelib/io/qfilesystemwatcher_symbian.cpp
@@ -44,6 +44,7 @@
#include "qfileinfo.h"
#include "qdebug.h"
#include "private/qcore_symbian_p.h"
+#include "private/qcoreapplication_p.h"
#include <QDir>
#ifndef QT_NO_FILESYSTEMWATCHER
@@ -248,8 +249,6 @@ void QSymbianFileSystemWatcherEngine::run()
{
// Initialize file session
- errorCode = fsSession.Connect();
-
mutex.lock();
syncCondition.wakeOne();
mutex.unlock();
@@ -263,7 +262,6 @@ void QSymbianFileSystemWatcherEngine::run()
}
activeObjectToPath.clear();
- fsSession.Close();
watcherStarted = false;
}
}
@@ -273,7 +271,7 @@ void QSymbianFileSystemWatcherEngine::addNativeListener(const QString &directory
QMutexLocker locker(&mutex);
QString nativeDir(QDir::toNativeSeparators(directoryPath));
TPtrC ptr(qt_QString2TPtrC(nativeDir));
- currentEvent = CNotifyChangeEvent::New(fsSession, ptr, this, directoryPath.endsWith(QChar(L'/'), Qt::CaseSensitive));
+ currentEvent = CNotifyChangeEvent::New(QCoreApplicationPrivate::fsSession(), ptr, this, directoryPath.endsWith(QChar(L'/'), Qt::CaseSensitive));
syncCondition.wakeOne();
}
diff --git a/src/corelib/io/qfilesystemwatcher_symbian_p.h b/src/corelib/io/qfilesystemwatcher_symbian_p.h
index 846541b..b0e3baa 100644
--- a/src/corelib/io/qfilesystemwatcher_symbian_p.h
+++ b/src/corelib/io/qfilesystemwatcher_symbian_p.h
@@ -115,7 +115,6 @@ private:
bool startWatcher();
- RFs fsSession;
QHash<CNotifyChangeEvent*, QString> activeObjectToPath;
QMutex mutex;
QWaitCondition syncCondition;
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 620d82f..4ee5c68 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -61,6 +61,7 @@
# 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)
@@ -400,28 +401,24 @@ bool QFSFileEngine::copy(const QString &newName)
{
#if defined(Q_OS_SYMBIAN)
Q_D(QFSFileEngine);
- RFs rfs;
- TInt err = rfs.Connect();
- if (err == KErrNone) {
- CFileMan* fm = NULL;
- QString oldNative(QDir::toNativeSeparators(d->filePath));
- TPtrC oldPtr(qt_QString2TPtrC(oldNative));
- QFileInfo fi(newName);
- QString absoluteNewName = fi.absolutePath() + QDir::separator() + fi.fileName();
- QString newNative(QDir::toNativeSeparators(absoluteNewName));
- TPtrC newPtr(qt_QString2TPtrC(newNative));
- TRAP (err,
- fm = CFileMan::NewL(rfs);
- RFile rfile;
- err = rfile.Open(rfs, oldPtr, EFileShareReadersOrWriters);
- if (err == KErrNone) {
- err = fm->Copy(rfile, newPtr);
- rfile.Close();
- }
- ) // End TRAP
- delete fm;
- rfs.Close();
- }
+ RFs& rfs = QCoreApplicationPrivate::fsSession();
+ CFileMan* fm = NULL;
+ QString oldNative(QDir::toNativeSeparators(d->filePath));
+ TPtrC oldPtr(qt_QString2TPtrC(oldNative));
+ QFileInfo fi(newName);
+ QString absoluteNewName = fi.absolutePath() + QDir::separator() + fi.fileName();
+ QString newNative(QDir::toNativeSeparators(absoluteNewName));
+ TPtrC newPtr(qt_QString2TPtrC(newNative));
+ TRAPD (err,
+ fm = CFileMan::NewL(rfs);
+ RFile rfile;
+ err = rfile.Open(rfs, oldPtr, EFileShareReadersOrWriters);
+ if (err == KErrNone) {
+ err = fm->Copy(rfile, newPtr);
+ rfile.Close();
+ }
+ ) // End TRAP
+ delete fm;
return (err == KErrNone);
#else
// ### Add copy code for Unix here
@@ -611,20 +608,17 @@ QFileInfoList QFSFileEngine::drives()
QFileInfoList ret;
#if defined(Q_OS_SYMBIAN)
TDriveList driveList;
- RFs rfs;
- TInt err = rfs.Connect();
+ RFs &rfs = QCoreApplicationPrivate::fsSession();
+ TInt err = rfs.DriveList(driveList);
if (err == KErrNone) {
- err = rfs.DriveList(driveList);
- if (err == KErrNone) {
- for(char i=0; i < KMaxDrives; i++) {
- if (driveList[i]) {
- ret.append(QString("%1:/").arg(QChar('A'+i)));
- }
+ for (char i = 0; i < KMaxDrives; i++) {
+ if (driveList[i]) {
+ ret.append(QString("%1:/").arg(QChar('A' + i)));
}
- } else {
- qWarning("QDir::drives: Getting drives failed");
}
- rfs.Close();
+ }
+ else {
+ qWarning("QDir::drives: Getting drives failed");
}
#else
ret.append(rootPath());
@@ -666,22 +660,18 @@ bool QFSFileEnginePrivate::isSymlink() const
static bool _q_isSymbianHidden(const QString &path, bool isDir)
{
bool retval = false;
- RFs rfs;
- TInt err = rfs.Connect();
- if (err == KErrNone) {
- QFileInfo fi(path);
- QString absPath = fi.absoluteFilePath();
- if (isDir && absPath.at(absPath.size()-1) != QChar('/')) {
- absPath += QChar('/');
- }
- QString native(QDir::toNativeSeparators(absPath));
- TPtrC ptr(qt_QString2TPtrC(native));
- TUint attributes;
- err = rfs.Att(ptr, attributes);
- rfs.Close();
- if (err == KErrNone && (attributes & KEntryAttHidden)) {
- retval = true;
- }
+ RFs rfs = QCoreApplicationPrivate::fsSession();
+ QFileInfo fi(path);
+ QString absPath = fi.absoluteFilePath();
+ if (isDir && absPath.at(absPath.size()-1) != QChar('/')) {
+ absPath += QChar('/');
+ }
+ QString native(QDir::toNativeSeparators(absPath));
+ TPtrC ptr(qt_QString2TPtrC(native));
+ TUint attributes;
+ TInt err = rfs.Att(ptr, attributes);
+ if (err == KErrNone && (attributes & KEntryAttHidden)) {
+ retval = true;
}
return retval;
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 875c3cc..88df7ac 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -271,6 +271,12 @@ 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.");
@@ -278,6 +284,7 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv)
QCoreApplicationPrivate::~QCoreApplicationPrivate()
{
+ fileServerSession.Close();
if (threadData) {
#ifndef QT_NO_THREAD
void *data = &threadData->tls;
@@ -816,6 +823,18 @@ 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.
@@ -1117,7 +1136,7 @@ void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority)
event->d = reinterpret_cast<QEventPrivate *>(quintptr(data->loopLevel));
}
- // delete the event on exceptions to protect against memory leaks till the event is
+ // delete the event on exceptions to protect against memory leaks till the event is
// properly owned in the postEventList
QScopedPointer<QEvent> eventDeleter(event);
if (data->postEventList.isEmpty() || data->postEventList.last().priority >= priority) {
@@ -2169,23 +2188,19 @@ QStringList QCoreApplication::libraryPaths()
// Add existing path on all drives for relative PluginsPath in Symbian
if (installPathPlugins.at(1) != QChar(':')) {
QString tempPath = installPathPlugins;
- if (tempPath.at(tempPath.length()-1) != QChar('\\')) {
+ if (tempPath.at(tempPath.length() - 1) != QChar('\\')) {
tempPath += QChar('\\');
}
- RFs fs;
- TInt err = fs.Connect();
- if (err == KErrNone) {
- TPtrC tempPathPtr(reinterpret_cast<const TText*>(tempPath.constData()));
- TFindFile finder(fs);
- err = finder.FindByDir(tempPathPtr, tempPathPtr);
- while (err == KErrNone) {
- QString foundDir = QString::fromUtf16(finder.File().Ptr(), finder.File().Length());
- foundDir = QDir(foundDir).canonicalPath();
- if (!app_libpaths->contains(foundDir))
- app_libpaths->append(foundDir);
- err = finder.Find();
- }
- fs.Close();
+ RFs& fs = QCoreApplicationPrivate::fsSession();
+ TPtrC tempPathPtr(reinterpret_cast<const TText*> (tempPath.constData()));
+ TFindFile finder(fs);
+ TInt err = finder.FindByDir(tempPathPtr, tempPathPtr);
+ while (err == KErrNone) {
+ QString foundDir = QString::fromUtf16(finder.File().Ptr(), finder.File().Length());
+ foundDir = QDir(foundDir).canonicalPath();
+ if (!app_libpaths->contains(foundDir))
+ app_libpaths->append(foundDir);
+ err = finder.Find();
}
}
#else
@@ -2329,7 +2344,7 @@ void QCoreApplication::removeLibraryPath(const QString &path)
By default, no event filter function is set (i.e., this function
returns a null EventFilter the first time it is called).
-
+
\note The filter function set here receives native messages,
i.e. MSG or XEvent structs, that are going to Qt objects. It is
called by QCoreApplication::filterEvent(). If the filter function
diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h
index 169835f..1adb837 100644
--- a/src/corelib/kernel/qcoreapplication_p.h
+++ b/src/corelib/kernel/qcoreapplication_p.h
@@ -57,6 +57,10 @@
#include "QtCore/qtranslator.h"
#include "private/qobject_p.h"
+#ifdef Q_OS_SYMBIAN
+#include <f32file.h>
+#endif
+
QT_BEGIN_NAMESPACE
typedef QList<QTranslator*> QTranslatorList;
@@ -86,6 +90,10 @@ 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);
@@ -118,6 +126,9 @@ 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