summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorSergio Ahumada <sergio.ahumada@nokia.com>2011-08-31 11:54:04 (GMT)
committerSergio Ahumada <sergio.ahumada@nokia.com>2011-08-31 11:54:04 (GMT)
commit9f51c31a0f492c20e6d882b2ae1e036b29c2755c (patch)
treecbb3beed71735514632b4f2788b63e72667cfc04 /src/corelib
parent0e10b8dbb7d84694cbdeb57bf42df52b12d79f47 (diff)
parent4f933036a0ecbc6e6174b312ec2fd6078cea5b70 (diff)
downloadQt-9f51c31a0f492c20e6d882b2ae1e036b29c2755c.zip
Qt-9f51c31a0f492c20e6d882b2ae1e036b29c2755c.tar.gz
Qt-9f51c31a0f492c20e6d882b2ae1e036b29c2755c.tar.bz2
Merge remote-tracking branch 'upstream/4.8' into qt-4.8-from-4.7
Conflicts: src/network/ssl/qsslcertificate.cpp
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/arch/qatomic_armv6.h2
-rw-r--r--src/corelib/io/qdir.cpp16
-rw-r--r--src/corelib/io/qfile.cpp10
-rw-r--r--src/corelib/io/qfileinfo.cpp6
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp7
-rw-r--r--src/corelib/io/qfsfileengine.cpp16
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp8
-rw-r--r--src/corelib/io/qnoncontiguousbytedevice.cpp2
-rw-r--r--src/corelib/io/qtemporaryfile.cpp230
-rw-r--r--src/corelib/io/qurl.cpp5
-rw-r--r--src/corelib/plugin/quuid.cpp20
-rw-r--r--src/corelib/tools/qdatetime.cpp7
-rw-r--r--src/corelib/tools/qlist.h31
-rw-r--r--src/corelib/tools/qlocale.qdoc4
-rw-r--r--src/corelib/tools/qlocale_symbian.cpp63
15 files changed, 301 insertions, 126 deletions
diff --git a/src/corelib/arch/qatomic_armv6.h b/src/corelib/arch/qatomic_armv6.h
index 96b561e..dd465db 100644
--- a/src/corelib/arch/qatomic_armv6.h
+++ b/src/corelib/arch/qatomic_armv6.h
@@ -152,6 +152,7 @@ inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
asm volatile("0:\n"
"ldrex %[result], [%[_q_value]]\n"
"eors %[result], %[result], %[expectedValue]\n"
+ "itt eq\n"
"strexeq %[result], %[newValue], [%[_q_value]]\n"
"teqeq %[result], #1\n"
"beq 0b\n"
@@ -210,6 +211,7 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValu
asm volatile("0:\n"
"ldrex %[result], [%[_q_value]]\n"
"eors %[result], %[result], %[expectedValue]\n"
+ "itt eq\n"
"strexeq %[result], %[newValue], [%[_q_value]]\n"
"teqeq %[result], #1\n"
"beq 0b\n"
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index f9196e0..d9086c1 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -1633,9 +1633,13 @@ bool QDir::operator==(const QDir &dir) const
if (d->filters == other->filters
&& d->sort == other->sort
&& d->nameFilters == other->nameFilters) {
- d->resolveAbsoluteEntry();
- other->resolveAbsoluteEntry();
- return d->absoluteDirEntry.filePath().compare(other->absoluteDirEntry.filePath(), sensitive) == 0;
+
+ // Assume directories are the same if path is the same
+ if (d->dirEntry.filePath() == other->dirEntry.filePath())
+ return true;
+
+ // Fallback to expensive canonical path computation
+ return canonicalPath().compare(dir.canonicalPath(), sensitive) == 0;
}
return false;
}
@@ -2004,7 +2008,7 @@ QString QDir::cleanPath(const QString &path)
const QChar *p = name.unicode();
for (int i = 0, last = -1, iwrite = 0; i < len; ++i) {
if (p[i] == QLatin1Char('/')) {
- while (i < len-1 && p[i+1] == QLatin1Char('/')) {
+ while (i+1 < len && p[i+1] == QLatin1Char('/')) {
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) //allow unc paths
if (!i)
break;
@@ -2012,9 +2016,9 @@ QString QDir::cleanPath(const QString &path)
i++;
}
bool eaten = false;
- if (i < len - 1 && p[i+1] == QLatin1Char('.')) {
+ if (i+1 < len && p[i+1] == QLatin1Char('.')) {
int dotcount = 1;
- if (i < len - 2 && p[i+2] == QLatin1Char('.'))
+ if (i+2 < len && p[i+2] == QLatin1Char('.'))
dotcount++;
if (i == len - dotcount - 1) {
if (dotcount == 1) {
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index 929b2f9..06c403a 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -366,9 +366,11 @@ QFilePrivate::setError(QFile::FileError err, int errNum)
\value AutoCloseHandle The file handle passed into open() should be
closed by close(), the default behaviour is that close just flushes
- the file and the app is responsible for closing the file handle. When
- opening a file by name, this flag is ignored as Qt always "owns" the
+ the file and the application is responsible for closing the file handle.
+ When opening a file by name, this flag is ignored as Qt always "owns" the
file handle and must close it.
+ \value DontCloseHandle The file handle passed into open() will not be
+ closed by Qt. The application must ensure that close() is called.
*/
#ifdef QT3_SUPPORT
@@ -1210,7 +1212,7 @@ bool QFile::open(int fd, OpenMode mode)
Returns true if successful; otherwise returns false.
When a QFile is opened using this function, behaviour of close() is
- controlled by the AutoCloseHandle flag.
+ controlled by the \a handleFlags argument.
If AutoCloseHandle is specified, and this function succeeds,
then calling close() closes the adopted handle.
Otherwise, close() does not actually close the file, but only flushes it.
@@ -1269,7 +1271,7 @@ bool QFile::open(int fd, OpenMode mode, FileHandleFlags handleFlags)
Returns true if successful; otherwise returns false.
When a QFile is opened using this function, behaviour of close() is
- controlled by the AutoCloseHandle flag.
+ controlled by the \a handleFlags argument.
If AutoCloseHandle is specified, and this function succeeds,
then calling close() closes the adopted handle.
Otherwise, close() does not actually close the file, but only flushes it.
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index ca42c87..ff328da 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -391,6 +391,11 @@ bool QFileInfo::operator==(const QFileInfo &fileinfo) const
return true;
if (d->isDefaultConstructed || fileinfo.d_ptr->isDefaultConstructed)
return false;
+
+ // Assume files are the same if path is the same
+ if (d->fileEntry.filePath() == fileinfo.d_ptr->fileEntry.filePath())
+ return true;
+
Qt::CaseSensitivity sensitive;
if (d->fileEngine == 0 || fileinfo.d_ptr->fileEngine == 0) {
if (d->fileEngine != fileinfo.d_ptr->fileEngine) // one is native, the other is a custom file-engine
@@ -406,6 +411,7 @@ bool QFileInfo::operator==(const QFileInfo &fileinfo) const
if (fileinfo.size() != size()) //if the size isn't the same...
return false;
+ // Fallback to expensive canonical path computation
return canonicalFilePath().compare(fileinfo.canonicalFilePath(), sensitive) == 0;
}
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index f704fc3..764ee6d 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -536,7 +536,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
// Force uppercase drive letters.
ret[0] = ret.at(0).toUpper();
}
- return QFileSystemEntry(ret);
+ return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
}
//static
@@ -1052,11 +1052,12 @@ QString QFileSystemEngine::tempPath()
}
if (ret.isEmpty()) {
#if !defined(Q_OS_WINCE)
- ret = QLatin1String("c:/tmp");
+ ret = QLatin1String("C:/tmp");
#else
ret = QLatin1String("/Temp");
#endif
- }
+ } else if (ret.length() >= 2 && ret[1] == QLatin1Char(':'))
+ ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters.
return ret;
}
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp
index 548f9cf..e1f3123 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -233,6 +233,14 @@ bool QFSFileEngine::open(QIODevice::OpenMode openMode, FILE *fh)
return open(openMode, fh, QFile::DontCloseHandle);
}
+/*!
+ Opens the file handle \a fh in \a openMode mode. Returns true
+ on success; otherwise returns false.
+
+ The \a handleFlags argument specifies whether the file handle will be
+ closed by Qt. See the QFile::FileHandleFlags documentation for more
+ information.
+*/
bool QFSFileEngine::open(QIODevice::OpenMode openMode, FILE *fh, QFile::FileHandleFlags handleFlags)
{
Q_D(QFSFileEngine);
@@ -294,6 +302,14 @@ bool QFSFileEngine::open(QIODevice::OpenMode openMode, int fd)
return open(openMode, fd, QFile::DontCloseHandle);
}
+/*!
+ Opens the file descriptor \a fd in \a openMode mode. Returns true
+ on success; otherwise returns false.
+
+ The \a handleFlags argument specifies whether the file handle will be
+ closed by Qt. See the QFile::FileHandleFlags documentation for more
+ information.
+*/
bool QFSFileEngine::open(QIODevice::OpenMode openMode, int fd, QFile::FileHandleFlags handleFlags)
{
Q_D(QFSFileEngine);
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 9de282a..4961722 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -252,6 +252,14 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode)
return true;
}
+/*!
+ Opens the file descriptor specified by \a file in the mode given by
+ \a openMode. Returns true on success; otherwise returns false.
+
+ The \a handleFlags argument specifies whether the file handle will be
+ closed by Qt. See the QFile::FileHandleFlags documentation for more
+ information.
+*/
bool QFSFileEngine::open(QIODevice::OpenMode openMode, const RFile &file, QFile::FileHandleFlags handleFlags)
{
Q_D(QFSFileEngine);
diff --git a/src/corelib/io/qnoncontiguousbytedevice.cpp b/src/corelib/io/qnoncontiguousbytedevice.cpp
index 5568920..d5ce56b 100644
--- a/src/corelib/io/qnoncontiguousbytedevice.cpp
+++ b/src/corelib/io/qnoncontiguousbytedevice.cpp
@@ -501,8 +501,6 @@ QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QIODevice *dev
}
/*!
- \fn static QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QRingBuffer *ringBuffer);
-
Create a QNonContiguousByteDevice out of a QRingBuffer.
\internal
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index d457601..e80a8b6 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -44,17 +44,18 @@
#ifndef QT_NO_TEMPORARYFILE
#include "qplatformdefs.h"
-#include "qabstractfileengine.h"
#include "private/qfile_p.h"
-#include "private/qabstractfileengine_p.h"
#include "private/qfsfileengine_p.h"
+#include "private/qsystemerror_p.h"
+#include "private/qfilesystemengine_p.h"
-#if !defined(Q_OS_WINCE)
-# include <errno.h>
+#if defined(Q_OS_SYMBIAN)
+#include "private/qcore_symbian_p.h"
#endif
-#if defined(Q_OS_UNIX)
-# include "private/qcore_unix_p.h" // overrides QT_OPEN
+#if !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN)
+#include "private/qcore_unix_p.h" // overrides QT_OPEN
+#include <errno.h>
#endif
#if defined(QT_BUILD_CORE_LIB)
@@ -63,6 +64,30 @@
QT_BEGIN_NAMESPACE
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+typedef ushort Char;
+
+static inline Char Latin1Char(char ch)
+{
+ return ushort(uchar(ch));
+}
+
+# ifdef Q_OS_WIN
+typedef HANDLE NativeFileHandle;
+# else // Q_OS_SYMBIAN
+# ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
+typedef RFile64 NativeFileHandle;
+# else
+typedef RFile NativeFileHandle;
+# endif
+# endif
+
+#else // POSIX
+typedef char Char;
+typedef char Latin1Char;
+typedef int NativeFileHandle;
+#endif
+
/*
* Copyright (c) 1987, 1993
* The Regents of the University of California. All rights reserved.
@@ -96,27 +121,33 @@ QT_BEGIN_NAMESPACE
\internal
Generates a unique file path and returns a native handle to the open file.
- \a path is used as a template when generating unique paths,
- \a placeholderStart and \a placeholderEnd delimit the sub-string that will
- be randomized.
+ \a path is used as a template when generating unique paths, \a pos
+ identifies the position of the first character that will be replaced in the
+ template and \a length the number of characters that may be substituted.
Returns an open handle to the newly created file if successful, an invalid
handle otherwise. In both cases, the string in \a path will be changed and
contain the generated path name.
*/
-static int createFileFromTemplate(char *const path,
- char *const placeholderStart, char *const placeholderEnd)
+static bool createFileFromTemplate(NativeFileHandle &file,
+ QFileSystemEntry::NativePath &path, size_t pos, size_t length,
+ QSystemError &error)
{
- Q_ASSERT(placeholderEnd > placeholderStart);
+ Q_ASSERT(length != 0);
+ Q_ASSERT(pos < size_t(path.length()));
+ Q_ASSERT(length <= size_t(path.length()) - pos);
+
+ Char *const placeholderStart = (Char *)path.data() + pos;
+ Char *const placeholderEnd = placeholderStart + length;
// Initialize placeholder with random chars + PID.
{
- char *rIter = placeholderEnd;
+ Char *rIter = placeholderEnd;
#if defined(QT_BUILD_CORE_LIB)
quint64 pid = quint64(QCoreApplication::applicationPid());
do {
- *--rIter = (pid % 10) + '0';
+ *--rIter = Latin1Char((pid % 10) + '0');
pid /= 10;
} while (rIter != placeholderStart && pid != 0);
#endif
@@ -124,48 +155,82 @@ static int createFileFromTemplate(char *const path,
while (rIter != placeholderStart) {
char ch = char((qrand() & 0xffff) % (26 + 26));
if (ch < 26)
- *--rIter = ch + 'A';
+ *--rIter = Latin1Char(ch + 'A');
else
- *--rIter = ch - 26 + 'a';
+ *--rIter = Latin1Char(ch - 26 + 'a');
}
}
+#ifdef Q_OS_SYMBIAN
+ RFs& fs = qt_s60GetRFs();
+#endif
+
for (;;) {
// Atomically create file and obtain handle
-#ifndef Q_OS_WIN
- {
- int fd = QT_OPEN(path, QT_OPEN_CREAT | O_EXCL | QT_OPEN_RDWR | QT_OPEN_LARGEFILE, 0600);
- if (fd != -1)
- return fd;
- if (errno != EEXIST)
- return -1;
+#if defined(Q_OS_WIN)
+ file = CreateFile((const wchar_t *)path.constData(),
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_NEW,
+ FILE_ATTRIBUTE_NORMAL, NULL);
+
+ if (file != INVALID_HANDLE_VALUE)
+ return true;
+
+ DWORD err = GetLastError();
+ if (err != ERROR_FILE_EXISTS) {
+ error = QSystemError(err, QSystemError::NativeError);
+ return false;
+ }
+#elif defined(Q_OS_SYMBIAN)
+ TInt err = file.Create(fs, qt_QString2TPtrC(path),
+ EFileRead | EFileWrite | EFileShareReadersOrWriters);
+
+ if (err == KErrNone)
+ return true;
+
+ if (err != KErrAlreadyExists) {
+ error = QSystemError(err, QSystemError::NativeError);
+ return false;
+ }
+#else // POSIX
+ file = QT_OPEN(path.constData(),
+ QT_OPEN_CREAT | O_EXCL | QT_OPEN_RDWR | QT_OPEN_LARGEFILE,
+ 0600);
+
+ if (file != -1)
+ return true;
+
+ int err = errno;
+ if (err != EEXIST) {
+ error = QSystemError(err, QSystemError::NativeError);
+ return false;
}
-#else
- if (!QFileInfo(QString::fromLocal8Bit(path)).exists())
- return 1;
#endif
/* tricky little algorwwithm for backward compatibility */
- for (char *iter = placeholderStart;;) {
+ for (Char *iter = placeholderStart;;) {
// Character progression: [0-9] => 'a' ... 'z' => 'A' .. 'Z'
// String progression: "ZZaiC" => "aabiC"
- switch (*iter) {
+ switch (char(*iter)) {
case 'Z':
// Rollover, advance next character
- *iter = 'a';
- if (++iter == placeholderEnd)
- return -1;
+ *iter = Latin1Char('a');
+ if (++iter == placeholderEnd) {
+ // Out of alternatives. Return file exists error, previously set.
+ error = QSystemError(err, QSystemError::NativeError);
+ return false;
+ }
continue;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
- *iter = 'a';
+ *iter = Latin1Char('a');
break;
case 'z':
// increment 'z' to 'A'
- *iter = 'A';
+ *iter = Latin1Char('A');
break;
default:
@@ -257,7 +322,7 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
QString qfilename = d->fileEntry.filePath();
- // Find placeholder string.
+ // Ensure there is a placeholder mask
uint phPos = qfilename.length();
uint phLength = 0;
@@ -269,70 +334,73 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
continue;
}
- if (qfilename[phPos] == QLatin1Char('/')
- || phLength >= 6) {
+ if (phLength >= 6
+ || qfilename[phPos] == QLatin1Char('/')) {
++phPos;
break;
}
+ // start over
phLength = 0;
}
- QStringRef prefix, suffix;
- if (phLength < 6) {
- qfilename += QLatin1Char('.');
- prefix = QStringRef(&qfilename);
- phLength = 6;
- } else {
- prefix = qfilename.leftRef(phPos);
- suffix = qfilename.midRef(phPos + phLength);
- }
+ if (phLength < 6)
+ qfilename.append(QLatin1String(".XXXXXX"));
+
+ // "Nativify" :-)
+ QFileSystemEntry::NativePath filename = QFileSystemEngine::absoluteName(
+ QFileSystemEntry(qfilename, QFileSystemEntry::FromInternalPath()))
+ .nativeFilePath();
- QByteArray filename = prefix.toLocal8Bit();
+ // Find mask in native path
phPos = filename.length();
- if (suffix.isEmpty())
- filename.resize(phPos + phLength);
- else
- filename.insert(phPos + phLength, suffix.toLocal8Bit());
-
- char *path = filename.data();
-
-#ifndef Q_OS_WIN
- int fd = createFileFromTemplate(path, path + phPos, path + phPos + phLength);
- if (fd != -1) {
- // First open the fd as an external file descriptor to
- // initialize the engine properly.
- if (QFSFileEngine::open(openMode, fd)) {
-
- // Allow the engine to close the handle even if it's "external".
- d->closeFileHandle = true;
-
- // Restore the file names (open() resets them).
- d->fileEntry = QFileSystemEntry(QString::fromLocal8Bit(path, filename.length())); //note that filename is NOT a native path
- filePathIsTemplate = false;
- return true;
+ phLength = 0;
+ while (phPos != 0) {
+ --phPos;
+
+ if (filename[phPos] == Latin1Char('X')) {
+ ++phLength;
+ continue;
}
- QT_CLOSE(fd);
- }
- setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError, qt_error_string(errno));
- return false;
-#else
- if (createFileFromTemplate(path, path + phPos, path + phPos + phLength) == -1) {
- return false;
+ if (phLength >= 6) {
+ ++phPos;
+ break;
+ }
+
+ // start over
+ phLength = 0;
}
- QString template_ = d->fileEntry.filePath();
- d->fileEntry = QFileSystemEntry(QString::fromLocal8Bit(path, filename.length()));
+ Q_ASSERT(phLength >= 6);
- if (QFSFileEngine::open(openMode)) {
- filePathIsTemplate = false;
- return true;
+ QSystemError error;
+#if defined(Q_OS_WIN)
+ NativeFileHandle &file = d->fileHandle;
+#elif defined(Q_OS_SYMBIAN)
+ NativeFileHandle &file = d->symbianFile;
+#else // POSIX
+ NativeFileHandle &file = d->fd;
+#endif
+
+ if (!createFileFromTemplate(file, filename, phPos, phLength, error)) {
+ setError(QFile::OpenError, error.toString());
+ return false;
}
- d->fileEntry = QFileSystemEntry(template_, QFileSystemEntry::FromInternalPath());
- return false;
+ d->fileEntry = QFileSystemEntry(filename, QFileSystemEntry::FromNativePath());
+
+#if !defined(Q_OS_WIN)
+ d->closeFileHandle = true;
#endif
+
+ filePathIsTemplate = false;
+
+ d->openMode = openMode;
+ d->lastFlushFailed = false;
+ d->tried_stat = 0;
+
+ return true;
}
bool QTemporaryFileEngine::remove()
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 4226f9e..60a4ce3 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -63,8 +63,9 @@
unencoded representation is suitable for showing to users, but
the encoded representation is typically what you would send to
a web server. For example, the unencoded URL
- "http://b\uuml\c{}hler.example.com" would be sent to the server as
- "http://xn--bhler-kva.example.com/List%20of%20applicants.xml".
+ "http://b\uuml\c{}hler.example.com/List of applicants.xml" would be sent to the server as
+ "http://xn--bhler-kva.example.com/List%20of%20applicants.xml",
+ and this can be verified by calling the toEncoded() function.
A URL can also be constructed piece by piece by calling
setScheme(), setUserName(), setPassword(), setHost(), setPort(),
diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp
index eb29e6e..83c6194 100644
--- a/src/corelib/plugin/quuid.cpp
+++ b/src/corelib/plugin/quuid.cpp
@@ -387,17 +387,17 @@ QUuid::QUuid(const QByteArray &text)
#endif
/*!
- Creates a QUuid object from the binary representation of the UUID, as
- specified by RFC 4122 section 4.1.2. See toRfc4122() for a further
- explanation of the order of bytes required.
+ \since 4.8
- The byte array accepted is NOT a human readable format.
+ Creates a QUuid object from the binary representation of the UUID given
+ by \a bytes, as specified by RFC 4122 section 4.1.2. See toRfc4122() for a
+ further explanation of the order of bytes required.
- If the conversion fails, a null UUID is created.
+ The byte array accepted is \e not a human readable format.
- \since 4.8
+ If the conversion fails, a null UUID is created.
- \sa toRfc4122(), QUuid()
+ \sa toRfc4122(), QUuid()
*/
QUuid QUuid::fromRfc4122(const QByteArray &bytes)
{
@@ -901,6 +901,12 @@ QUuid QUuid::createUuid()
uint randNumber = 0;
for (int filled = 0; filled < intbits; filled += randbits)
randNumber |= qrand()<<filled;
+#if defined(Q_OS_SYMBIAN)
+ // Symbian does not have /dev/urandom, so entropy is low.
+ // Add more entropy from the kernel tick count (1ms resolution).
+ // big multipler used to splatter the tick count bits over the whole 32 bits
+ randNumber ^= User::NTickCount() * 0x3b9aca07;
+#endif
*(data+chunks) = randNumber;
}
}
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index a6fee43..e33b7d5 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -2788,6 +2788,8 @@ int QDateTime::secsTo(const QDateTime &other) const
}
/*!
+ \since 4.7
+
Returns the number of milliseconds from this datetime to the \a other
datetime. If the \a other datetime is earlier than this datetime,
the value returned is negative.
@@ -4040,8 +4042,11 @@ static QDateTimePrivate::Spec utcToLocal(QDate &date, QTime &time)
RTz tz;
User::LeaveIfError(tz.Connect());
CleanupClosePushL(tz);
- res.tm_isdst = tz.IsDaylightSavingOnL(*tz.GetTimeZoneIdL(),utcTTime);
+ CTzId *tzId = tz.GetTimeZoneIdL();
+ CleanupStack::PushL(tzId);
+ res.tm_isdst = tz.IsDaylightSavingOnL(*tzId,utcTTime);
User::LeaveIfError(tz.ConvertToLocalTime(utcTTime));
+ CleanupStack::PopAndDestroy(tzId);
CleanupStack::PopAndDestroy(&tz));
if (KErrNone == err) {
TDateTime localDateTime = utcTTime.DateTime();
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 4eb05d6..9f7b23f 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -769,25 +769,32 @@ Q_OUTOFLINE_TEMPLATE void QList<T>::clear()
template <typename T>
Q_OUTOFLINE_TEMPLATE int QList<T>::removeAll(const T &_t)
{
- detachShared();
+ int index = indexOf(_t);
+ if (index == -1)
+ return 0;
+
const T t = _t;
- int removedCount=0, i=0;
- Node *n;
- while (i < p.size())
- if ((n = reinterpret_cast<Node *>(p.at(i)))->t() == t) {
- node_destruct(n);
- p.remove(i);
- ++removedCount;
- } else {
- ++i;
- }
+ detach();
+
+ Node *i = reinterpret_cast<Node *>(p.at(index));
+ Node *e = reinterpret_cast<Node *>(p.end());
+ Node *n = i;
+ node_destruct(i);
+ while (++i != e) {
+ if (i->t() == t)
+ node_destruct(i);
+ else
+ *n++ = *i;
+ }
+
+ int removedCount = e - n;
+ d->end -= removedCount;
return removedCount;
}
template <typename T>
Q_OUTOFLINE_TEMPLATE bool QList<T>::removeOne(const T &_t)
{
- detachShared();
int index = indexOf(_t);
if (index != -1) {
removeAt(index);
diff --git a/src/corelib/tools/qlocale.qdoc b/src/corelib/tools/qlocale.qdoc
index 5d4f305..95a7165 100644
--- a/src/corelib/tools/qlocale.qdoc
+++ b/src/corelib/tools/qlocale.qdoc
@@ -806,6 +806,10 @@
\internal
*/
/*!
+ \fn QSystemLocale::CurrencyToStringArgument::CurrencyToStringArgument(const QVariant &v, const QString &s)
+ \internal
+*/
+/*!
\variable QSystemLocale::CurrencyToStringArgument::value
An input value that should be converted to its string representation.
diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp
index cdf0ab1..1214e46 100644
--- a/src/corelib/tools/qlocale_symbian.cpp
+++ b/src/corelib/tools/qlocale_symbian.cpp
@@ -195,7 +195,9 @@ QByteArray qt_symbianLocaleName(int code)
return qt_resolveSymbianLocaleName(code, ISO);
}
-// order is: normal, abbr, nmode, nmode+abbr
+// Rows are: normal, abbr, nmode, nmode+abbr
+// First three values on a row are used for three component date,
+// while the last two are used for two component date (i.e. no year).
static const char *us_locale_dep[] = {
"MM", "dd", "yyyy", "MM", "dd",
"M", "d", "yy", "M", "d",
@@ -214,6 +216,13 @@ static const char *jp_locale_dep[] = {
"yyyy", "MMMM", "dd", "MMMM", "dd",
"yy", "MMM", "d", "MMM", "d" };
+// 0 = day, 1 = month, 2 = year
+static const int digit_map[] = {
+ 1, 0, 2, 1, 0, // American
+ 0, 1, 2, 0, 1, // European
+ 2, 1, 0, 1, 0 // Japanese
+};
+
/*!
Returns a Qt version of the given \a sys_fmt Symbian locale format string.
*/
@@ -229,6 +238,9 @@ static QString s60ToQtFormat(const QString &sys_fmt)
int i = 0;
bool open_escape = false;
bool abbrev_next = false;
+ bool abbrev_day = false;
+ bool abbrev_month = false;
+ bool abbrev_year = false;
bool locale_indep_ordering = false;
bool minus_mode = false;
bool plus_mode = false;
@@ -305,8 +317,11 @@ static QString s60ToQtFormat(const QString &sys_fmt)
case 'D':
{
- if (!locale_indep_ordering)
+ if (!locale_indep_ordering) {
+ if (abbrev_next)
+ abbrev_day = true;
break;
+ }
if (!abbrev_next)
result += QLatin1String("dd");
@@ -318,8 +333,11 @@ static QString s60ToQtFormat(const QString &sys_fmt)
case 'M':
{
- if (!locale_indep_ordering)
+ if (!locale_indep_ordering) {
+ if (abbrev_next)
+ abbrev_month = true;
break;
+ }
if (!n_mode) {
if (!abbrev_next)
@@ -340,8 +358,11 @@ static QString s60ToQtFormat(const QString &sys_fmt)
{
n_mode = true;
- if (!locale_indep_ordering)
+ if (!locale_indep_ordering) {
+ if (abbrev_next)
+ abbrev_month = true;
break;
+ }
if (!abbrev_next)
result += QLatin1String("MMMM");
@@ -353,8 +374,11 @@ static QString s60ToQtFormat(const QString &sys_fmt)
case 'Y':
{
- if (!locale_indep_ordering)
+ if (!locale_indep_ordering) {
+ if (abbrev_next)
+ abbrev_year = true;
break;
+ }
if (!abbrev_next)
result += QLatin1String("yyyy");
@@ -522,7 +546,9 @@ static QString s60ToQtFormat(const QString &sys_fmt)
const char **locale_dep;
switch (df) {
- default: // fallthru to american
+ default:
+ df = EDateAmerican;
+ // fallthru to american
case EDateAmerican:
locale_dep = us_locale_dep;
break;
@@ -534,12 +560,33 @@ static QString s60ToQtFormat(const QString &sys_fmt)
break;
}
int offset = 0;
- if (abbrev_next)
+ int adjustedDigit = c.digitValue() - 1;
+
+ bool abbrev_this = abbrev_next;
+ // If abbreviation specified for this digit, use that.
+ // Otherwise abbreviate according to %D, %M, and %Y specified previously.
+ if (!abbrev_this) {
+ switch (digit_map[adjustedDigit + (static_cast<int>(df) * 5)]) {
+ case 0:
+ abbrev_this = abbrev_day;
+ break;
+ case 1:
+ abbrev_this = abbrev_month;
+ break;
+ case 2:
+ abbrev_this = abbrev_year;
+ break;
+ default:
+ break; // never happens
+ }
+ }
+
+ if (abbrev_this)
offset += 5;
if (n_mode)
offset += 10;
- result += QLatin1String(locale_dep[offset + (c.digitValue()-1)]);
+ result += QLatin1String(locale_dep[offset + (adjustedDigit)]);
break;
}