diff options
author | David Boddie <david.boddie@nokia.com> | 2011-08-08 13:26:30 (GMT) |
---|---|---|
committer | David Boddie <david.boddie@nokia.com> | 2011-08-08 13:26:30 (GMT) |
commit | e28e1f919cdc2b82c45b2a5ceee7a9261e70433d (patch) | |
tree | 31e2cf533867b86545b509dd7ee472182a4527f3 /src/corelib | |
parent | 74b7d4c2c4036e9f2c0da7f0eaad06cef954b923 (diff) | |
parent | 82a18deee74bef3e545bf6426164dbe12548e5d9 (diff) | |
download | Qt-e28e1f919cdc2b82c45b2a5ceee7a9261e70433d.zip Qt-e28e1f919cdc2b82c45b2a5ceee7a9261e70433d.tar.gz Qt-e28e1f919cdc2b82c45b2a5ceee7a9261e70433d.tar.bz2 |
Merge branch '4.8' of scm.dev.nokia.troll.no:qt/qt
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qfsfileengine.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/qfsfileengine_p.h | 10 | ||||
-rw-r--r-- | src/corelib/io/qfsfileengine_unix.cpp | 56 | ||||
-rw-r--r-- | src/corelib/kernel/qcore_symbian_p.h | 24 | ||||
-rw-r--r-- | src/corelib/plugin/qlibrary.cpp | 7 | ||||
-rw-r--r-- | src/corelib/thread/qmutex_unix.cpp | 4 | ||||
-rw-r--r-- | src/corelib/tools/qlocale.cpp | 38 | ||||
-rw-r--r-- | src/corelib/tools/qlocale.h | 3 | ||||
-rw-r--r-- | src/corelib/tools/qstring.cpp | 30 |
9 files changed, 149 insertions, 29 deletions
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 0d23a27..548f9cf 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -120,7 +120,7 @@ void QFSFileEnginePrivate::init() openMode = QIODevice::NotOpen; fd = -1; fh = 0; -#ifdef Q_OS_SYMBIAN +#if defined (Q_OS_SYMBIAN) && !defined(QT_SYMBIAN_USE_NATIVE_FILEMAP) fileHandleForMaps = -1; #endif lastIOCommand = IOFlushCommand; @@ -368,8 +368,10 @@ bool QFSFileEnginePrivate::closeFdFh() if (fd == -1 && !fh #ifdef Q_OS_SYMBIAN && !symbianFile.SubSessionHandle() +#ifndef QT_SYMBIAN_USE_NATIVE_FILEMAP && fileHandleForMaps == -1 #endif +#endif ) return false; @@ -378,7 +380,7 @@ bool QFSFileEnginePrivate::closeFdFh() bool closed = true; tried_stat = 0; -#ifdef Q_OS_SYMBIAN +#if defined(Q_OS_SYMBIAN) && !defined(QT_SYMBIAN_USE_NATIVE_FILEMAP) // Map handle is always owned by us so always close it if (fileHandleForMaps >= 0) { QT_CLOSE(fileHandleForMaps); diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index 79dda1b..f93250e 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -62,6 +62,12 @@ #ifdef Q_OS_SYMBIAN #include <f32file.h> +//This macro will be defined if the OS supports memory mapped files +#if defined (SYMBIAN_FILE_MAPPING_SUPPORTED) && !defined (WINS) +//simpler define to check in sources +#define QT_SYMBIAN_USE_NATIVE_FILEMAP +#include <f32filemap.h> +#endif #endif #ifndef QT_NO_FSFILEENGINE @@ -139,9 +145,11 @@ public: */ TInt symbianFilePos; #endif +#ifndef QT_SYMBIAN_USE_NATIVE_FILEMAP mutable int fileHandleForMaps; int getMapHandle(); #endif +#endif #ifdef Q_WS_WIN HANDLE fileHandle; @@ -153,6 +161,8 @@ public: #endif mutable DWORD fileAttrib; +#elif defined (QT_SYMBIAN_USE_NATIVE_FILEMAP) + QHash<uchar *, RFileMap> maps; #else QHash<uchar *, QPair<int /*offset % PageSize*/, size_t /*length + offset % PageSize*/> > maps; #endif diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 681e55d..9de282a 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -602,7 +602,7 @@ int QFSFileEnginePrivate::nativeHandle() const return fh ? fileno(fh) : fd; } -#ifdef Q_OS_SYMBIAN +#if defined(Q_OS_SYMBIAN) && !defined(QT_SYMBIAN_USE_NATIVE_FILEMAP) int QFSFileEnginePrivate::getMapHandle() { if (symbianFile.SubSessionHandle()) { @@ -925,6 +925,7 @@ QString QFSFileEngine::owner(FileOwner own) const return QFileSystemEngine::resolveUserName(ownerId(own)); return QFileSystemEngine::resolveGroupName(ownerId(own)); #else + Q_UNUSED(own) return QString(); #endif } @@ -1045,9 +1046,47 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla QT_OFF_T realOffset = QT_OFF_T(offset); realOffset &= ~(QT_OFF_T(pageSize - 1)); +#ifdef QT_SYMBIAN_USE_NATIVE_FILEMAP + TInt nativeMapError = KErrNone; + RFileMap mapping; + TUint mode(EFileMapRemovableMedia); + //If the file was opened for write or read/write, then open the map for read/write + if (openMode & QIODevice::WriteOnly) + mode |= EFileMapWrite; + if (symbianFile.SubSessionHandle()) { + nativeMapError = mapping.Open(symbianFile, offset, size, mode); + } else { + //map file by name if we don't have a native handle + QString fn = QFileSystemEngine::absoluteName(fileEntry).nativeFilePath(); + TUint filemode = EFileShareReadersOrWriters | EFileRead; + if (openMode & QIODevice::WriteOnly) + filemode |= EFileWrite; + nativeMapError = mapping.Open(qt_s60GetRFs(), qt_QString2TPtrC(fn), filemode, offset, size, mode); + } + if (nativeMapError == KErrNone) { + QScopedResource<RFileMap> ptr(mapping); //will call Close if adding to mapping throws an exception + uchar *address = mapping.Base(); + maps[address] = mapping; + ptr.take(); + return address; + } + QFile::FileError reportedError = QFile::UnspecifiedError; + switch (nativeMapError) { + case KErrAccessDenied: + case KErrPermissionDenied: + reportedError = QFile::PermissionsError; + break; + case KErrNoMemory: + reportedError = QFile::ResourceError; + break; + } + q->setError(reportedError, QSystemError(nativeMapError, QSystemError::NativeError).toString()); + return 0; +#else #ifdef Q_OS_SYMBIAN + //older phones & emulator don't support native mapping, so need to keep the open C way around for those. void *mapAddress; - TRAPD(err, mapAddress = QT_MMAP((void*)0, realSize, + TRAPD(err, mapAddress = QT_MMAP((void*)0, realSize, access, MAP_SHARED, getMapHandle(), realOffset)); if (err != KErrNone) { qWarning("OpenC bug: leave from mmap %d", err); @@ -1079,6 +1118,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla break; } return 0; +#endif } bool QFSFileEnginePrivate::unmap(uchar *ptr) @@ -1090,6 +1130,17 @@ bool QFSFileEnginePrivate::unmap(uchar *ptr) return false; } +#ifdef QT_SYMBIAN_USE_NATIVE_FILEMAP + RFileMap mapping = maps.value(ptr); + TInt err = mapping.Flush(); + mapping.Close(); + maps.remove(ptr); + if (err) { + q->setError(QFile::WriteError, QSystemError(err, QSystemError::NativeError).toString()); + return false; + } + return true; +#else uchar *start = ptr - maps[ptr].first; size_t len = maps[ptr].second; if (-1 == munmap(start, len)) { @@ -1098,6 +1149,7 @@ bool QFSFileEnginePrivate::unmap(uchar *ptr) } maps.remove(ptr); return true; +#endif #else return false; #endif diff --git a/src/corelib/kernel/qcore_symbian_p.h b/src/corelib/kernel/qcore_symbian_p.h index 3019e05..a8f576d 100644 --- a/src/corelib/kernel/qcore_symbian_p.h +++ b/src/corelib/kernel/qcore_symbian_p.h @@ -59,6 +59,7 @@ #include <qstring.h> #include <qrect.h> #include <qhash.h> +#include <qscopedpointer.h> #include <f32file.h> #include <es_sock.h> @@ -262,6 +263,29 @@ private: RConnection *iDefaultConnection; }; +template <typename T> class QScopedPointerResourceCloser +{ +public: + static inline void cleanup(T* pointer) + { + if (pointer) + pointer->Close(); + } +}; + +/*typical use: + RFile file; + file.Open(...); + QScopedResource<RFile> ptr(file); + container.append(file); //this may throw std::bad_alloc, in which case file.Close() is called by destructor + ptr.take(); //if we reach this line, ownership is transferred to the container + */ +template <typename T> class QScopedResource : public QScopedPointer<T, QScopedPointerResourceCloser<T> > +{ +public: + inline QScopedResource(T& resource) : QScopedPointer<T, QScopedPointerResourceCloser<T> >(&resource) {} +}; + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index 314ccd7..f1ed8e4 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -649,7 +649,12 @@ bool qt_get_verificationdata(QtPluginQueryVerificationDataFunction pfn, uint *qt #else szData = pfn(); #endif - return qt_parse_pattern(szData, qt_version, debug, key); + +#ifdef QT_NO_PLUGIN_CHECK + return true; +#else + return qt_parse_pattern(szData, qt_version, debug, key); +#endif } bool QLibraryPrivate::isPlugin(QSettings *settings) diff --git a/src/corelib/thread/qmutex_unix.cpp b/src/corelib/thread/qmutex_unix.cpp index e692e19..2a9d23c 100644 --- a/src/corelib/thread/qmutex_unix.cpp +++ b/src/corelib/thread/qmutex_unix.cpp @@ -161,8 +161,8 @@ bool QMutexPrivate::wait(int timeout) return false; } - ts.tv_sec = timeout / Q_INT64_C(1000) / 1000 / 1000; - ts.tv_nsec = timeout % (Q_INT64_C(1000) * 1000 * 1000); + ts.tv_sec = xtimeout / Q_INT64_C(1000) / 1000 / 1000; + ts.tv_nsec = xtimeout % (Q_INT64_C(1000) * 1000 * 1000); } } return true; diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index d791529..8640c8b 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -88,6 +88,8 @@ Q_GLOBAL_STATIC(QLocalePrivate, globalLocalePrivate) #ifdef QT_USE_ICU extern bool qt_initIcu(const QString &localeName); +extern bool qt_u_strToUpper(const QString &str, QString *out, const QLocale &locale); +extern bool qt_u_strToLower(const QString &str, QString *out, const QLocale &locale); #endif /****************************************************************************** @@ -2180,6 +2182,42 @@ Qt::LayoutDirection QLocale::textDirection() const return Qt::LeftToRight; } +/*! + \since 4.8 + + Returns an uppercase copy of \a str. +*/ +QString QLocale::toUpper(const QString &str) const +{ +#ifdef QT_USE_ICU + { + QString result; + if (qt_u_strToUpper(str, &result, *this)) + return result; + // else fall through and use Qt's toUpper + } +#endif + return str.toUpper(); +} + +/*! + \since 4.8 + + Returns a lowercase copy of \a str. +*/ +QString QLocale::toLower(const QString &str) const +{ +#ifdef QT_USE_ICU + { + QString result; + if (qt_u_strToLower(str, &result, *this)) + return result; + // else fall through and use Qt's toUpper + } +#endif + return str.toLower(); +} + /*! \since 4.5 diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index 8a5d526..55dd55b 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -724,6 +724,9 @@ public: Qt::LayoutDirection textDirection() const; + QString toUpper(const QString &str) const; + QString toLower(const QString &str) const; + QString currencySymbol(CurrencySymbolFormat = CurrencySymbol) const; QString toCurrencyString(qlonglong, const QString &symbol = QString()) const; QString toCurrencyString(qulonglong, const QString &symbol = QString()) const; diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 791bfff..f5efe55 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -109,8 +109,6 @@ static QHash<void *, QByteArray> *asciiCache = 0; #ifdef QT_USE_ICU // qlocale_icu.cpp extern bool qt_ucol_strcoll(const QChar *source, int sourceLength, const QChar *target, int targetLength, int *result); -extern bool qt_u_strToUpper(const QString &str, QString *out, const QLocale &locale); -extern bool qt_u_strToLower(const QString &str, QString *out, const QLocale &locale); #endif @@ -5015,7 +5013,10 @@ QString QString::rightJustified(int width, QChar fill, bool truncate) const \snippet doc/src/snippets/qstring/main.cpp 75 - \sa toUpper() + The case conversion will always happen in the 'C' locale. For locale dependent + case folding use QLocale::toLower() + + \sa toUpper(), QLocale::toLower() */ QString QString::toLower() const @@ -5026,15 +5027,6 @@ QString QString::toLower() const if (!d->size) return *this; -#ifdef QT_USE_ICU - { - QString result; - if (qt_u_strToLower(*this, &result, QLocale())) - return result; - // else fall through and use Qt's toUpper - } -#endif - const ushort *e = d->data + d->size; // this avoids one out of bounds check in the loop @@ -5115,7 +5107,10 @@ QString QString::toCaseFolded() const \snippet doc/src/snippets/qstring/main.cpp 81 - \sa toLower() + The case conversion will always happen in the 'C' locale. For locale dependent + case folding use QLocale::toUpper() + + \sa toLower(), QLocale::toLower() */ QString QString::toUpper() const @@ -5126,15 +5121,6 @@ QString QString::toUpper() const if (!d->size) return *this; -#ifdef QT_USE_ICU - { - QString result; - if (qt_u_strToUpper(*this, &result, QLocale())) - return result; - // else fall through and use Qt's toUpper - } -#endif - const ushort *e = d->data + d->size; // this avoids one out of bounds check in the loop |