summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-04-29 14:17:08 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-04-29 14:17:09 +0200
commit85e3c53e5c5e2de993c90ece324a68d0ff62f417 (patch)
tree6f078576f01f18afcdae773e48664640ce795abe /src/corelib
parent2e749c089f6fd93909e7cd4cc8129f2969b35185 (diff)
parent7f943968ade6a65321d4a00822f5b3a034a19e0c (diff)
Merge remote-tracking branch 'origin/stable' into dev
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/Qt5CTestMacros.cmake4
-rw-r--r--src/corelib/global/qflags.h2
-rw-r--r--src/corelib/global/qnamespace.h4
-rw-r--r--src/corelib/io/qdatastream.cpp16
-rw-r--r--src/corelib/io/qfileinfo.cpp2
-rw-r--r--src/corelib/io/qfileinfo_p.h8
-rw-r--r--src/corelib/io/qprocess.cpp37
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.h2
-rw-r--r--src/corelib/thread/qorderedmutexlocker_p.h4
-rw-r--r--src/corelib/thread/qwaitcondition.qdoc4
-rw-r--r--src/corelib/tools/qdatetime.h4
-rw-r--r--src/corelib/tools/qlocale.cpp60
-rw-r--r--src/corelib/tools/qlocale_p.h8
13 files changed, 81 insertions, 74 deletions
diff --git a/src/corelib/Qt5CTestMacros.cmake b/src/corelib/Qt5CTestMacros.cmake
index 126a348b47..51537a3904 100644
--- a/src/corelib/Qt5CTestMacros.cmake
+++ b/src/corelib/Qt5CTestMacros.cmake
@@ -38,6 +38,10 @@ foreach(module ${CMAKE_MODULES_UNDER_TEST})
)
endforeach()
+if(CMAKE_CROSSCOMPILING AND CMAKE_FIND_ROOT_PATH)
+ list(APPEND BUILD_OPTIONS_LIST "-DCMAKE_CXX_LINK_FLAGS=--sysroot=\"${CMAKE_FIND_ROOT_PATH}\"")
+endif()
+
macro(expect_pass _dir)
string(REPLACE "(" "_" testname "${_dir}")
string(REPLACE ")" "_" testname "${testname}")
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h
index 4722fe2282..6332e2d761 100644
--- a/src/corelib/global/qflags.h
+++ b/src/corelib/global/qflags.h
@@ -79,7 +79,7 @@ class QFlags
{
Q_STATIC_ASSERT_X((sizeof(Enum) <= sizeof(int)),
"QFlags uses an int as storage, so an enum with underlying "
- "long long would overflow. Qt 5.1 will have support for 64bit enums.");
+ "long long will overflow.");
struct Private;
typedef int (Private::*Zero);
public:
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index f130288a24..95d9baafd5 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -138,6 +138,10 @@ public:
Q_DECLARE_FLAGS(KeyboardModifiers, KeyboardModifier)
//shorter names for shortcuts
+ // The use of all-caps identifiers has the potential for clashing with
+ // user-defined or third-party macros. More so when the identifiers are not
+ // "namespace"-prefixed. This is considered bad practice and is why
+ // KeypadModifier was not added to the Modifier enum.
enum Modifier {
META = Qt::MetaModifier,
SHIFT = Qt::ShiftModifier,
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index 484dcbf22e..da38f8ae21 100644
--- a/src/corelib/io/qdatastream.cpp
+++ b/src/corelib/io/qdatastream.cpp
@@ -817,8 +817,12 @@ QDataStream &QDataStream::operator>>(double &f)
Reads the '\\0'-terminated string \a s from the stream and returns
a reference to the stream.
- Space for the string is allocated using \c new -- the caller must
- destroy it with \c{delete[]}.
+ The string is deserialized using \c{readBytes()}.
+
+ Space for the string is allocated using \c{new []} -- the caller must
+ destroy it with \c{delete []}.
+
+ \sa readBytes(), readRawData()
*/
QDataStream &QDataStream::operator>>(char *&s)
@@ -832,8 +836,8 @@ QDataStream &QDataStream::operator>>(char *&s)
Reads the buffer \a s from the stream and returns a reference to
the stream.
- The buffer \a s is allocated using \c new. Destroy it with the \c
- delete[] operator.
+ The buffer \a s is allocated using \c{new []}. Destroy it with the
+ \c{delete []} operator.
The \a l parameter is set to the length of the buffer. If the
string read is empty, \a l is set to 0 and \a s is set to
@@ -1102,7 +1106,9 @@ QDataStream &QDataStream::operator<<(double f)
Writes the '\\0'-terminated string \a s to the stream and returns a
reference to the stream.
- The string is serialized using writeBytes().
+ The string is serialized using \c{writeBytes()}.
+
+ \sa writeBytes(), writeRawData()
*/
QDataStream &QDataStream::operator<<(const char *s)
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index 7fcb4154f2..addcd772ab 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -187,6 +187,8 @@ uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) cons
QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) const
{
Q_ASSERT(fileEngine); // should never be called when using the native FS
+ if (fileTimes.size() != 3)
+ fileTimes.resize(3);
if (!cache_enabled)
clearFlags();
uint cf;
diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h
index 1b254f6e85..442e6b5ef0 100644
--- a/src/corelib/io/qfileinfo_p.h
+++ b/src/corelib/io/qfileinfo_p.h
@@ -58,6 +58,7 @@
#include "qatomic.h"
#include "qshareddata.h"
#include "qfilesystemengine_p.h"
+#include "qvector.h"
#include <QtCore/private/qabstractfileengine_p.h>
#include <QtCore/private/qfilesystementry_p.h>
@@ -152,7 +153,12 @@ public:
bool cache_enabled : 1;
mutable uint fileFlags;
mutable qint64 fileSize;
- mutable QDateTime fileTimes[3];
+ // ### Qt6: FIXME: This vector is essentially a plain array
+ // mutable QDateTime fileTimes[3], but the array is slower
+ // to initialize than the QVector as QDateTime has a pimpl.
+ // In Qt 6, QDateTime should inline its data members,
+ // and this here can be an array again.
+ mutable QVector<QDateTime> fileTimes;
inline bool getCachedFlag(uint c) const
{ return cache_enabled ? (cachedFlags & c) : 0; }
inline void setCachedFlag(uint c) const
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 3993cf5002..59b6db7c79 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -125,16 +125,15 @@ QT_BEGIN_NAMESPACE
The environment of the calling process can be obtained using
QProcessEnvironment::systemEnvironment().
- On Unix systems, the variable names are case-sensitive. For that reason,
- this class will not touch the names of the variables. Note as well that
+ On Unix systems, the variable names are case-sensitive. Note that the
Unix environment allows both variable names and contents to contain arbitrary
- binary data (except for the NUL character), but this is not supported by
- QProcessEnvironment. This class only supports names and values that are
- encodable by the current locale settings (see QTextCodec::codecForLocale).
+ binary data (except for the NUL character). QProcessEnvironment will preserve
+ such variables, but does not support manipulating variables whose names or
+ values are not encodable by the current locale settings (see
+ QTextCodec::codecForLocale).
- On Windows, the variable names are case-insensitive. Therefore,
- QProcessEnvironment will always uppercase the names and do case-insensitive
- comparisons.
+ On Windows, the variable names are case-insensitive, but case-preserving.
+ QProcessEnvironment behaves accordingly.
On Windows CE, the concept of environment does not exist. This class will
keep the values set for compatibility with other platforms, but the values
@@ -298,9 +297,6 @@ void QProcessEnvironment::clear()
Returns true if the environment variable of name \a name is found in
this QProcessEnvironment object.
- On Windows, variable names are case-insensitive, so the key is converted
- to uppercase before searching. On other systems, names are case-sensitive
- so no trasformation is applied.
\sa insert(), value()
*/
@@ -314,10 +310,6 @@ bool QProcessEnvironment::contains(const QString &name) const
into this QProcessEnvironment object. If that variable already existed,
it is replaced by the new value.
- On Windows, variable names are case-insensitive, so this function always
- uppercases the variable name before inserting. On other systems, names
- are case-sensitive, so no transformation is applied.
-
On most systems, inserting a variable with no contents will have the
same effect for applications as if the variable had not been set at all.
However, to guarantee that there are no incompatibilities, to remove a
@@ -336,9 +328,6 @@ void QProcessEnvironment::insert(const QString &name, const QString &value)
QProcessEnvironment object. If that variable did not exist before,
nothing happens.
- On Windows, variable names are case-insensitive, so the key is converted
- to uppercase before searching. On other systems, names are case-sensitive
- so no trasformation is applied.
\sa contains(), insert(), value()
*/
@@ -353,10 +342,6 @@ void QProcessEnvironment::remove(const QString &name)
\a name and returns its value. If the variable is not found in this object,
then \a defaultValue is returned instead.
- On Windows, variable names are case-insensitive, so the key is converted
- to uppercase before searching. On other systems, names are case-sensitive
- so no trasformation is applied.
-
\sa contains(), insert(), remove()
*/
QString QProcessEnvironment::value(const QString &name, const QString &defaultValue) const
@@ -376,10 +361,10 @@ QString QProcessEnvironment::value(const QString &name, const QString &defaultVa
each environment variable that is set. The environment variable's name
and its value are separated by an equal character ('=').
- The QStringList contents returned by this function are suitable for use
- with the QProcess::setEnvironment function. However, it is recommended
- to use QProcess::setProcessEnvironment instead since that will avoid
- unnecessary copying of the data.
+ The QStringList contents returned by this function are suitable for
+ presentation.
+ Use with the QProcess::setEnvironment function is not recommended due to
+ potential encoding problems under Unix, and worse performance.
\sa systemEnvironment(), QProcess::systemEnvironment(), QProcess::environment(),
QProcess::setEnvironment()
diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h
index a0ac33e8a8..16f30fffd6 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.h
+++ b/src/corelib/itemmodels/qabstractitemmodel.h
@@ -410,7 +410,7 @@ inline bool QAbstractItemModel::moveRow(const QModelIndex &sourceParent, int sou
{ return moveRows(sourceParent, sourceRow, 1, destinationParent, destinationChild); }
inline bool QAbstractItemModel::moveColumn(const QModelIndex &sourceParent, int sourceColumn,
const QModelIndex &destinationParent, int destinationChild)
-{ return moveRows(sourceParent, sourceColumn, 1, destinationParent, destinationChild); }
+{ return moveColumns(sourceParent, sourceColumn, 1, destinationParent, destinationChild); }
inline QModelIndex QAbstractItemModel::createIndex(int arow, int acolumn, void *adata) const
{ return QModelIndex(arow, acolumn, adata, this); }
inline QModelIndex QAbstractItemModel::createIndex(int arow, int acolumn, quintptr aid) const
diff --git a/src/corelib/thread/qorderedmutexlocker_p.h b/src/corelib/thread/qorderedmutexlocker_p.h
index ec9c6fd91b..0492886cfd 100644
--- a/src/corelib/thread/qorderedmutexlocker_p.h
+++ b/src/corelib/thread/qorderedmutexlocker_p.h
@@ -53,10 +53,10 @@
// We mean it.
//
-QT_BEGIN_NAMESPACE
-
#include <QtCore/qmutex.h>
+QT_BEGIN_NAMESPACE
+
/*
Locks 2 mutexes in a defined order, avoiding a recursive lock if
we're trying to lock the same mutex twice.
diff --git a/src/corelib/thread/qwaitcondition.qdoc b/src/corelib/thread/qwaitcondition.qdoc
index 68788e0b3f..9aa633a210 100644
--- a/src/corelib/thread/qwaitcondition.qdoc
+++ b/src/corelib/thread/qwaitcondition.qdoc
@@ -124,8 +124,8 @@
Releases the \a lockedMutex and waits on the wait condition. The
\a lockedMutex must be initially locked by the calling thread. If \a
- lockedMutex is not in a locked state, this function returns
- immediately. If \a lockedMutex is a recursive mutex, this function
+ lockedMutex is not in a locked state, the behavior is undefined. If
+ \a lockedMutex is a recursive mutex, this function
returns immediately. The \a lockedMutex will be unlocked, and the
calling thread will block until either of these conditions is met:
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index d1cc10c877..5c1668033c 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -262,6 +262,10 @@ public:
private:
friend class QDateTimePrivate;
void detach();
+
+ // ### Qt6: Using a private here has high impact on runtime
+ // on users such as QFileInfo. In Qt 6, the data members
+ // should be inlined.
QExplicitlySharedDataPointer<QDateTimePrivate> d;
#ifndef QT_NO_DATASTREAM
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 4aaa1af688..b5f983899a 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -284,51 +284,51 @@ QLocaleId QLocaleId::withLikelySubtagsRemoved() const
return max;
}
-QString QLocaleId::bcp47Name() const
+QByteArray QLocaleId::name(char separator) const
{
if (language_id == QLocale::AnyLanguage)
- return QString();
+ return QByteArray();
if (language_id == QLocale::C)
- return QStringLiteral("C");
+ return QByteArrayLiteral("C");
- const unsigned char *lang = language_code_list + 3*uint(language_id);
+ const unsigned char *lang = language_code_list + 3 * language_id;
const unsigned char *script =
- (script_id != QLocale::AnyScript ? script_code_list + 4*uint(script_id) : 0);
+ (script_id != QLocale::AnyScript ? script_code_list + 4 * script_id : 0);
const unsigned char *country =
- (country_id != QLocale::AnyCountry ? country_code_list + 3*uint(country_id) : 0);
+ (country_id != QLocale::AnyCountry ? country_code_list + 3 * country_id : 0);
char len = (lang[2] != 0 ? 3 : 2) + (script ? 4+1 : 0) + (country ? (country[2] != 0 ? 3 : 2)+1 : 0);
- QString name(len, Qt::Uninitialized);
- QChar *uc = name.data();
- *uc++ = ushort(lang[0]);
- *uc++ = ushort(lang[1]);
+ QByteArray name(len, Qt::Uninitialized);
+ char *uc = name.data();
+ *uc++ = lang[0];
+ *uc++ = lang[1];
if (lang[2] != 0)
- *uc++ = ushort(lang[2]);
+ *uc++ = lang[2];
if (script) {
- *uc++ = QLatin1Char('-');
- *uc++ = ushort(script[0]);
- *uc++ = ushort(script[1]);
- *uc++ = ushort(script[2]);
- *uc++ = ushort(script[3]);
+ *uc++ = separator;
+ *uc++ = script[0];
+ *uc++ = script[1];
+ *uc++ = script[2];
+ *uc++ = script[3];
}
if (country) {
- *uc++ = QLatin1Char('-');
- *uc++ = ushort(country[0]);
- *uc++ = ushort(country[1]);
+ *uc++ = separator;
+ *uc++ = country[0];
+ *uc++ = country[1];
if (country[2] != 0)
- *uc++ = ushort(country[2]);
+ *uc++ = country[2];
}
return name;
}
-QString QLocalePrivate::bcp47Name() const
+QByteArray QLocalePrivate::bcp47Name(char separator) const
{
if (m_data->m_language_id == QLocale::AnyLanguage)
- return QString();
+ return QByteArray();
if (m_data->m_language_id == QLocale::C)
- return QStringLiteral("C");
+ return QByteArrayLiteral("C");
QLocaleId localeId = QLocaleId::fromIds(m_data->m_language_id, m_data->m_script_id, m_data->m_country_id);
- return localeId.withLikelySubtagsRemoved().bcp47Name();
+ return localeId.withLikelySubtagsRemoved().name(separator);
}
const QLocaleData *QLocaleData::findLocaleData(QLocale::Language language, QLocale::Script script, QLocale::Country country)
@@ -1080,7 +1080,7 @@ QString QLocale::name() const
*/
QString QLocale::bcp47Name() const
{
- return d->bcp47Name();
+ return QString::fromLatin1(d->bcp47Name());
}
/*!
@@ -2494,7 +2494,7 @@ QString QLocale::toUpper(const QString &str) const
{
#ifdef QT_USE_ICU
bool ok = true;
- QString result = QIcu::toUpper(d->m_localeID, str, &ok);
+ QString result = QIcu::toUpper(d->bcp47Name('_'), str, &ok);
if (ok)
return result;
// else fall through and use Qt's toUpper
@@ -2511,7 +2511,7 @@ QString QLocale::toLower(const QString &str) const
{
#ifdef QT_USE_ICU
bool ok = true;
- QString result = QIcu::toLower(d->m_localeID, str, &ok);
+ const QString result = QIcu::toLower(d->bcp47Name('_'), str, &ok);
if (ok)
return result;
// else fall through and use Qt's toUpper
@@ -3662,14 +3662,14 @@ QStringList QLocale::uiLanguages() const
const QLocaleId min = max.withLikelySubtagsRemoved();
QStringList uiLanguages;
- uiLanguages.append(min.bcp47Name());
+ uiLanguages.append(QString::fromLatin1(min.name()));
if (id.script_id) {
id.script_id = 0;
if (id != min && id.withLikelySubtagsAdded() == max)
- uiLanguages.append(id.bcp47Name());
+ uiLanguages.append(QString::fromLatin1(id.name()));
}
if (max != min && max != id)
- uiLanguages.append(max.bcp47Name());
+ uiLanguages.append(QString::fromLatin1(max.name()));
return uiLanguages;
}
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h
index 4c0432bba7..9674342307 100644
--- a/src/corelib/tools/qlocale_p.h
+++ b/src/corelib/tools/qlocale_p.h
@@ -151,7 +151,7 @@ struct QLocaleId
QLocaleId withLikelySubtagsAdded() const;
QLocaleId withLikelySubtagsRemoved() const;
- QString bcp47Name() const;
+ QByteArray name(char separator = '-') const;
ushort language_id, script_id, country_id;
};
@@ -212,8 +212,6 @@ public:
: m_index(index), m_numberOptions(numberOptions)
{
m_data = dataPointerForIndex(index);
- m_localeID = bcp47Name().toLatin1();
- m_localeID.replace('-','_');
}
~QLocalePrivate()
@@ -232,7 +230,7 @@ public:
quint16 languageId() const { return m_data->m_language_id; }
quint16 countryId() const { return m_data->m_country_id; }
- QString bcp47Name() const;
+ QByteArray bcp47Name(char separator = '-') const;
// ### QByteArray::fromRawData would be more optimal
inline QString languageCode() const { return QLocalePrivate::languageToCode(QLocale::Language(m_data->m_language_id)); }
@@ -334,11 +332,9 @@ public:
QString dateTimeToString(const QString &format, const QDate *date, const QTime *time,
const QLocale *q) const;
- friend class QLocale;
quint16 m_index;
quint16 m_numberOptions;
const QLocaleData *m_data;
- QByteArray m_localeID;
};
inline char QLocalePrivate::digitToCLocale(QChar in) const