summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-12-18 08:37:31 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2015-12-18 08:37:31 +0100
commitbeb65dcd79f8c354dab7bb4a8d08157bd9d69329 (patch)
tree4632a0ff0df8462f8913f347042cf8378de03268 /src/corelib/tools
parent3fc1002489d5861d4f7cc2e1e8800881d6593c9d (diff)
parente3288f246b44ba2b6d90b90eb99ab61f496d8d57 (diff)
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: src/gui/painting/painting.pri src/plugins/platforms/xcb/qxcbconnection.cpp tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro tests/auto/corelib/tools/qlocale/test/test.pro tests/auto/gui/kernel/qwindow/tst_qwindow.cpp tools/configure/environment.cpp Change-Id: I9c40f458b89b2c206de2d2c24e90b5f679c93495
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h2
-rw-r--r--src/corelib/tools/qstring.cpp24
-rw-r--r--src/corelib/tools/qstring.h7
-rw-r--r--src/corelib/tools/qtimezone.cpp5
4 files changed, 29 insertions, 9 deletions
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index ace6c5d093..6827483464 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -500,7 +500,7 @@ private:
template <class X>
inline void enableSharedFromThis(const QEnableSharedFromThis<X> *ptr)
{
- ptr->initializeFromSharedPointer(*this);
+ ptr->initializeFromSharedPointer(constCast<typename QtPrivate::remove_cv<T>::type>());
}
inline void enableSharedFromThis(...) {}
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index b582204d67..2f340477fc 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -1819,6 +1819,17 @@ QString &QString::operator=(const QString &other) Q_DECL_NOTHROW
Assigns the Latin-1 string \a str to this string.
*/
+QString &QString::operator=(QLatin1String other)
+{
+ if (isDetached() && other.size() <= capacity()) { // assumes d->alloc == 0 → !isDetached() (sharedNull)
+ d->size = other.size();
+ d->data()[other.size()] = 0;
+ qt_from_latin1(d->data(), other.latin1(), other.size());
+ } else {
+ *this = fromLatin1(other.latin1(), other.size());
+ }
+ return *this;
+}
/*! \fn QString &QString::operator=(const QByteArray &ba)
@@ -1869,7 +1880,16 @@ QString &QString::operator=(const QString &other) Q_DECL_NOTHROW
*/
QString &QString::operator=(QChar ch)
{
- return operator=(QString(ch));
+ if (isDetached() && capacity() >= 1) { // assumes d->alloc == 0 → !isDetached() (sharedNull)
+ // re-use existing capacity:
+ ushort *dat = d->data();
+ dat[0] = ch.unicode();
+ dat[1] = 0;
+ d->size = 1;
+ } else {
+ operator=(QString(ch));
+ }
+ return *this;
}
/*!
@@ -5667,7 +5687,7 @@ QString QString::rightJustified(int width, QChar fill, bool truncate) const
*/
namespace QUnicodeTables {
-/*!
+/*
\internal
Converts the \a str string starting from the position pointed to by the \a
it iterator, using the Unicode case traits \c Traits, and returns the
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 4ae81f9269..75f94d7f93 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -221,7 +221,7 @@ public:
inline ~QString();
QString &operator=(QChar c);
QString &operator=(const QString &) Q_DECL_NOTHROW;
- inline QString &operator=(QLatin1String latin1);
+ QString &operator=(QLatin1String latin1);
#ifdef Q_COMPILER_RVALUE_REFS
inline QString(QString && other) Q_DECL_NOTHROW : d(other.d) { other.d = Data::sharedNull(); }
inline QString &operator=(QString &&other) Q_DECL_NOTHROW
@@ -885,11 +885,6 @@ inline void QString::detach()
{ if (d->ref.isShared() || (d->offset != sizeof(QStringData))) reallocData(uint(d->size) + 1u); }
inline bool QString::isDetached() const
{ return !d->ref.isShared(); }
-inline QString &QString::operator=(QLatin1String s)
-{
- *this = fromLatin1(s.latin1(), s.size());
- return *this;
-}
inline void QString::clear()
{ if (!isNull()) *this = QString(); }
inline QString::QString(const QString &other) Q_DECL_NOTHROW : d(other.d)
diff --git a/src/corelib/tools/qtimezone.cpp b/src/corelib/tools/qtimezone.cpp
index 57c1838b76..333a5c3471 100644
--- a/src/corelib/tools/qtimezone.cpp
+++ b/src/corelib/tools/qtimezone.cpp
@@ -695,6 +695,11 @@ QTimeZone::OffsetData QTimeZone::offsetData(const QDateTime &forDateTime) const
/*!
Returns \c true if the system backend supports obtaining transitions.
+
+ Transitions are changes in the time-zone: these happen when DST turns on or
+ off and when authorities alter the offsets for the time-zone.
+
+ \sa nextTransition(), previousTransition(), transitions()
*/
bool QTimeZone::hasTransitions() const