summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
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/io
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/io')
-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
3 files changed, 41 insertions, 54 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;