summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorSami Lempinen <sami.lempinen@nokia.com>2011-08-23 11:33:16 (GMT)
committerSami Lempinen <sami.lempinen@nokia.com>2011-08-23 11:33:16 (GMT)
commita28832bb61e7e60ac0fb856daf27b78ff1728520 (patch)
treed8ecd2387568814a68bf8b8713f3abed9ff9f275 /src/corelib
parent59f33898919391d3aa4baa6849556965ae7d08ce (diff)
parent2f5855e8d891a7e93bdb721243f1c0b10fcb5ad9 (diff)
downloadQt-a28832bb61e7e60ac0fb856daf27b78ff1728520.zip
Qt-a28832bb61e7e60ac0fb856daf27b78ff1728520.tar.gz
Qt-a28832bb61e7e60ac0fb856daf27b78ff1728520.tar.bz2
Merge remote-tracking branch 'qt/4.8'
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/arch/qatomic_armv6.h2
-rw-r--r--src/corelib/codecs/qtextcodec.cpp9
-rw-r--r--src/corelib/global/qglobal.h37
-rw-r--r--src/corelib/io/qdir.cpp38
-rw-r--r--src/corelib/io/qfile.cpp10
-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.cpp43
-rw-r--r--src/corelib/io/qurl.cpp5
-rw-r--r--src/corelib/plugin/quuid.cpp14
-rw-r--r--src/corelib/tools/qbytearray.cpp4
-rw-r--r--src/corelib/tools/qlocale.qdoc4
13 files changed, 125 insertions, 67 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/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 985f515..dd06a2a 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -213,12 +213,13 @@ QTextCodecCleanup::~QTextCodecCleanup()
destroying_is_ok = true;
#endif
- for (QList<QTextCodec *>::const_iterator it = all->constBegin()
- ; it != all->constEnd(); ++it) {
+ QList<QTextCodec *> *myAll = all;
+ all = 0; // Otherwise the d'tor destroys the iterator
+ for (QList<QTextCodec *>::const_iterator it = myAll->constBegin()
+ ; it != myAll->constEnd(); ++it) {
delete *it;
}
- delete all;
- all = 0;
+ delete myAll;
localeMapper = 0;
#ifdef Q_DEBUG_TEXTCODEC
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 9c7f1c6..cfe5eea 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1924,50 +1924,51 @@ public:
}
};
+#define Q_GLOBAL_STATIC_INIT(TYPE, NAME) \
+ static QGlobalStatic<TYPE > this_ ## NAME \
+ = { Q_BASIC_ATOMIC_INITIALIZER(0), false }
+
#define Q_GLOBAL_STATIC(TYPE, NAME) \
static TYPE *NAME() \
{ \
- static QGlobalStatic<TYPE > thisGlobalStatic \
- = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \
- if (!thisGlobalStatic.pointer && !thisGlobalStatic.destroyed) { \
+ Q_GLOBAL_STATIC_INIT(TYPE, _StaticVar_); \
+ if (!this__StaticVar_.pointer && !this__StaticVar_.destroyed) { \
TYPE *x = new TYPE; \
- if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) \
+ if (!this__StaticVar_.pointer.testAndSetOrdered(0, x)) \
delete x; \
else \
- static QGlobalStaticDeleter<TYPE > cleanup(thisGlobalStatic); \
+ static QGlobalStaticDeleter<TYPE > cleanup(this__StaticVar_); \
} \
- return thisGlobalStatic.pointer; \
+ return this__StaticVar_.pointer; \
}
#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \
static TYPE *NAME() \
{ \
- static QGlobalStatic<TYPE > thisGlobalStatic \
- = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \
- if (!thisGlobalStatic.pointer && !thisGlobalStatic.destroyed) { \
+ Q_GLOBAL_STATIC_INIT(TYPE, _StaticVar_); \
+ if (!this__StaticVar_.pointer && !this__StaticVar_.destroyed) { \
TYPE *x = new TYPE ARGS; \
- if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) \
+ if (!this__StaticVar_.pointer.testAndSetOrdered(0, x)) \
delete x; \
else \
- static QGlobalStaticDeleter<TYPE > cleanup(thisGlobalStatic); \
+ static QGlobalStaticDeleter<TYPE > cleanup(this__StaticVar_); \
} \
- return thisGlobalStatic.pointer; \
+ return this__StaticVar_.pointer; \
}
#define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \
static TYPE *NAME() \
{ \
- static QGlobalStatic<TYPE > thisGlobalStatic \
- = { Q_BASIC_ATOMIC_INITIALIZER(0), false }; \
- if (!thisGlobalStatic.pointer && !thisGlobalStatic.destroyed) { \
+ Q_GLOBAL_STATIC_INIT(TYPE, _StaticVar_); \
+ if (!this__StaticVar_.pointer && !this__StaticVar_.destroyed) { \
QScopedPointer<TYPE > x(new TYPE); \
INITIALIZER; \
- if (thisGlobalStatic.pointer.testAndSetOrdered(0, x.data())) { \
- static QGlobalStaticDeleter<TYPE > cleanup(thisGlobalStatic); \
+ if (this__StaticVar_.pointer.testAndSetOrdered(0, x.data())) { \
+ static QGlobalStaticDeleter<TYPE > cleanup(this__StaticVar_); \
x.take(); \
} \
} \
- return thisGlobalStatic.pointer; \
+ return this__StaticVar_.pointer; \
}
#endif
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index b31cf69..f9196e0 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -802,14 +802,23 @@ QString QDir::convertSeparators(const QString &pathName)
*/
QString QDir::toNativeSeparators(const QString &pathName)
{
- QString n(pathName);
#if defined(Q_FS_FAT) || defined(Q_OS_OS2EMX) || defined(Q_OS_SYMBIAN)
- for (int i = 0; i < (int)n.length(); ++i) {
- if (n[i] == QLatin1Char('/'))
- n[i] = QLatin1Char('\\');
+ int i = pathName.indexOf(QLatin1Char('/'));
+ if (i != -1) {
+ QString n(pathName);
+
+ QChar * const data = n.data();
+ data[i++] = QLatin1Char('\\');
+
+ for (; i < n.length(); ++i) {
+ if (data[i] == QLatin1Char('/'))
+ data[i] = QLatin1Char('\\');
+ }
+
+ return n;
}
#endif
- return n;
+ return pathName;
}
/*!
@@ -826,14 +835,23 @@ QString QDir::toNativeSeparators(const QString &pathName)
*/
QString QDir::fromNativeSeparators(const QString &pathName)
{
- QString n(pathName);
#if defined(Q_FS_FAT) || defined(Q_OS_OS2EMX) || defined(Q_OS_SYMBIAN)
- for (int i = 0; i < (int)n.length(); ++i) {
- if (n[i] == QLatin1Char('\\'))
- n[i] = QLatin1Char('/');
+ int i = pathName.indexOf(QLatin1Char('\\'));
+ if (i != -1) {
+ QString n(pathName);
+
+ QChar * const data = n.data();
+ data[i++] = QLatin1Char('/');
+
+ for (; i < n.length(); ++i) {
+ if (data[i] == QLatin1Char('\\'))
+ data[i] = QLatin1Char('/');
+ }
+
+ return n;
}
#endif
- return n;
+ return pathName;
}
/*!
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/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 0855d93..d457601 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -53,10 +53,6 @@
# include <errno.h>
#endif
-#include <stdlib.h>
-#include <time.h>
-#include <ctype.h>
-
#if defined(Q_OS_UNIX)
# include "private/qcore_unix_p.h" // overrides QT_OPEN
#endif
@@ -118,7 +114,7 @@ static int createFileFromTemplate(char *const path,
char *rIter = placeholderEnd;
#if defined(QT_BUILD_CORE_LIB)
- qint64 pid = QCoreApplication::applicationPid();
+ quint64 pid = quint64(QCoreApplication::applicationPid());
do {
*--rIter = (pid % 10) + '0';
pid /= 10;
@@ -145,7 +141,7 @@ static int createFileFromTemplate(char *const path,
return -1;
}
#else
- if (!QFileInfo(QLatin1String(path)).exists())
+ if (!QFileInfo(QString::fromLocal8Bit(path)).exists())
return 1;
#endif
@@ -153,23 +149,34 @@ static int createFileFromTemplate(char *const path,
for (char *iter = placeholderStart;;) {
// Character progression: [0-9] => 'a' ... 'z' => 'A' .. 'Z'
// String progression: "ZZaiC" => "aabiC"
- if (*iter == 'Z') {
- *iter++ = 'a';
- if (iter == placeholderEnd)
- return -1;
- } else {
- if (isdigit(*iter))
+ switch (*iter) {
+ case 'Z':
+ // Rollover, advance next character
*iter = 'a';
- else if (*iter == 'z') /* inc from z to A */
+ if (++iter == placeholderEnd)
+ return -1;
+
+ continue;
+
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ *iter = 'a';
+ break;
+
+ case 'z':
+ // increment 'z' to 'A'
*iter = 'A';
- else {
+ break;
+
+ default:
++*iter;
- }
- break;
+ break;
}
+ break;
}
}
- /*NOTREACHED*/
+
+ Q_ASSERT(false);
}
//************* QTemporaryFileEngine
@@ -323,7 +330,7 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
return true;
}
- d->fileEntry = QFileSystemEntry(template_);
+ d->fileEntry = QFileSystemEntry(template_, QFileSystemEntry::FromInternalPath());
return false;
#endif
}
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..af63b79 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)
{
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 767b713..a8edea4 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -541,7 +541,7 @@ QByteArray qUncompress(const uchar* data, int nbytes)
forever {
ulong alloc = len;
- if (len >= (1 << 31) - sizeof(QByteArray::Data)) {
+ if (len >= ulong(1 << 31) - sizeof(QByteArray::Data)) {
//QByteArray does not support that huge size anyway.
qWarning("qUncompress: Input data is corrupted");
return QByteArray();
@@ -561,7 +561,7 @@ QByteArray qUncompress(const uchar* data, int nbytes)
switch (res) {
case Z_OK:
if (len != alloc) {
- if (len >= (1 << 31) - sizeof(QByteArray::Data)) {
+ if (len >= ulong(1 << 31) - sizeof(QByteArray::Data)) {
//QByteArray does not support that huge size anyway.
qWarning("qUncompress: Input data is corrupted");
return QByteArray();
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.