summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-03-02 09:04:38 +0100
committerLiang Qi <liang.qi@qt.io>2017-03-02 09:04:38 +0100
commit71264bae08d81bdeceb96133fdb01c370504dfcc (patch)
treed5dadaac8209d5ef1857a4d65197b9ee12b39848 /src/corelib/tools
parent5e785c0b83c9908c665f253c131629ac325a21f5 (diff)
parent6d10f739cd750968d0dd0e9d8fa4b64353a86c6c (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qbytearray.h10
-rw-r--r--src/corelib/tools/qeasingcurve.h2
-rw-r--r--src/corelib/tools/qfreelist_p.h4
-rw-r--r--src/corelib/tools/qlocale.cpp1
-rw-r--r--src/corelib/tools/qrect.cpp6
-rw-r--r--src/corelib/tools/qtimezone.cpp14
-rw-r--r--src/corelib/tools/qtimezoneprivate_p.h2
-rw-r--r--src/corelib/tools/qvarlengtharray.h31
-rw-r--r--src/corelib/tools/qvarlengtharray.qdoc28
9 files changed, 68 insertions, 30 deletions
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index af85d278687..06a50e59906 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -140,8 +140,6 @@ struct QByteArrayDataPtr
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, sizeof(QByteArrayData)) \
/**/
-#if defined(Q_COMPILER_LAMBDA)
-
# define QByteArrayLiteral(str) \
([]() -> QByteArray { \
enum { Size = sizeof(str) - 1 }; \
@@ -154,14 +152,6 @@ struct QByteArrayDataPtr
}()) \
/**/
-#endif
-
-#ifndef QByteArrayLiteral
-// no lambdas, not GCC, just return a temporary QByteArray
-
-# define QByteArrayLiteral(str) QByteArray(str, sizeof(str) - 1)
-#endif
-
class Q_CORE_EXPORT QByteArray
{
private:
diff --git a/src/corelib/tools/qeasingcurve.h b/src/corelib/tools/qeasingcurve.h
index efed5d36ee7..ba06de8f9e6 100644
--- a/src/corelib/tools/qeasingcurve.h
+++ b/src/corelib/tools/qeasingcurve.h
@@ -125,7 +125,7 @@ private:
friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QEasingCurve &);
#endif
};
-Q_DECLARE_TYPEINFO(QEasingCurve, Q_MOVABLE_TYPE);
+Q_DECLARE_SHARED(QEasingCurve)
#ifndef QT_NO_DEBUG_STREAM
Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QEasingCurve &item);
diff --git a/src/corelib/tools/qfreelist_p.h b/src/corelib/tools/qfreelist_p.h
index c3efc41d62b..a8d1132d06d 100644
--- a/src/corelib/tools/qfreelist_p.h
+++ b/src/corelib/tools/qfreelist_p.h
@@ -237,7 +237,7 @@ inline int QFreeList<T, ConstantsType>::next()
int id, newid, at;
ElementType *v;
do {
- id = _next.load();
+ id = _next.loadAcquire();
at = id & ConstantsType::IndexMask;
const int block = blockfor(at);
@@ -254,7 +254,7 @@ inline int QFreeList<T, ConstantsType>::next()
}
newid = v[at].next.load() | (id & ~ConstantsType::IndexMask);
- } while (!_next.testAndSetRelaxed(id, newid));
+ } while (!_next.testAndSetRelease(id, newid));
// qDebug("QFreeList::next(): returning %d (_next now %d, serial %d)",
// id & ConstantsType::IndexMask,
// newid & ConstantsType::IndexMask,
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index cdda5292e70..ae4befcb9ce 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -594,7 +594,6 @@ static QLocalePrivate *c_private()
*/
QSystemLocale::QSystemLocale()
{
- delete _systemLocale;
_systemLocale = this;
if (system_data)
diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp
index 4b6183646b3..895b6b9701a 100644
--- a/src/corelib/tools/qrect.cpp
+++ b/src/corelib/tools/qrect.cpp
@@ -1323,8 +1323,8 @@ QDebug operator<<(QDebug dbg, const QRect &r)
rendering.
A QRectF can be constructed with a set of left, top, width and
- height integers, or from a QPoint and a QSize. The following code
- creates two identical rectangles.
+ height coordinates, or from a QPointF and a QSizeF. The following
+ code creates two identical rectangles.
\snippet code/src_corelib_tools_qrect.cpp 1
@@ -1344,7 +1344,7 @@ QDebug operator<<(QDebug dbg, const QRect &r)
translated copy of this rectangle.
The size() function returns the rectange's dimensions as a
- QSize. The dimensions can also be retrieved separately using the
+ QSizeF. The dimensions can also be retrieved separately using the
width() and height() functions. To manipulate the dimensions use
the setSize(), setWidth() or setHeight() functions. Alternatively,
the size can be changed by applying either of the functions
diff --git a/src/corelib/tools/qtimezone.cpp b/src/corelib/tools/qtimezone.cpp
index 359c2d0bdbd..ec2f7c4af69 100644
--- a/src/corelib/tools/qtimezone.cpp
+++ b/src/corelib/tools/qtimezone.cpp
@@ -674,9 +674,9 @@ bool QTimeZone::isDaylightTime(const QDateTime &atDateTime) const
QTimeZone::OffsetData QTimeZone::offsetData(const QDateTime &forDateTime) const
{
if (hasTransitions())
- return d->toOffsetData(d->data(forDateTime.toMSecsSinceEpoch()));
+ return QTimeZonePrivate::toOffsetData(d->data(forDateTime.toMSecsSinceEpoch()));
else
- return d->invalidOffsetData();
+ return QTimeZonePrivate::invalidOffsetData();
}
/*!
@@ -712,9 +712,9 @@ bool QTimeZone::hasTransitions() const
QTimeZone::OffsetData QTimeZone::nextTransition(const QDateTime &afterDateTime) const
{
if (hasTransitions())
- return d->toOffsetData(d->nextTransition(afterDateTime.toMSecsSinceEpoch()));
+ return QTimeZonePrivate::toOffsetData(d->nextTransition(afterDateTime.toMSecsSinceEpoch()));
else
- return d->invalidOffsetData();
+ return QTimeZonePrivate::invalidOffsetData();
}
/*!
@@ -733,9 +733,9 @@ QTimeZone::OffsetData QTimeZone::nextTransition(const QDateTime &afterDateTime)
QTimeZone::OffsetData QTimeZone::previousTransition(const QDateTime &beforeDateTime) const
{
if (hasTransitions())
- return d->toOffsetData(d->previousTransition(beforeDateTime.toMSecsSinceEpoch()));
+ return QTimeZonePrivate::toOffsetData(d->previousTransition(beforeDateTime.toMSecsSinceEpoch()));
else
- return d->invalidOffsetData();
+ return QTimeZonePrivate::invalidOffsetData();
}
/*!
@@ -755,7 +755,7 @@ QTimeZone::OffsetDataList QTimeZone::transitions(const QDateTime &fromDateTime,
toDateTime.toMSecsSinceEpoch());
list.reserve(plist.count());
for (const QTimeZonePrivate::Data &pdata : plist)
- list.append(d->toOffsetData(pdata));
+ list.append(QTimeZonePrivate::toOffsetData(pdata));
}
return list;
}
diff --git a/src/corelib/tools/qtimezoneprivate_p.h b/src/corelib/tools/qtimezoneprivate_p.h
index 9985d0672cb..00389081600 100644
--- a/src/corelib/tools/qtimezoneprivate_p.h
+++ b/src/corelib/tools/qtimezoneprivate_p.h
@@ -74,7 +74,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(NSTimeZone);
QT_BEGIN_NAMESPACE
-class Q_CORE_EXPORT QTimeZonePrivate : public QSharedData
+class Q_AUTOTEST_EXPORT QTimeZonePrivate : public QSharedData
{
public:
//Version of QTimeZone::OffsetData struct using msecs for efficiency
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index 25f5176c226..5d0231417b0 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -146,15 +146,35 @@ public:
T value(int i, const T &defaultValue) const;
inline void append(const T &t) {
- if (s == a) // i.e. s != 0
+ if (s == a) { // i.e. s != 0
+ T copy(t);
realloc(s, s<<1);
- const int idx = s++;
- if (QTypeInfo<T>::isComplex) {
- new (ptr + idx) T(t);
+ const int idx = s++;
+ if (QTypeInfo<T>::isComplex) {
+ new (ptr + idx) T(std::move(copy));
+ } else {
+ ptr[idx] = std::move(copy);
+ }
} else {
- ptr[idx] = t;
+ const int idx = s++;
+ if (QTypeInfo<T>::isComplex) {
+ new (ptr + idx) T(t);
+ } else {
+ ptr[idx] = t;
+ }
}
}
+
+ void append(T &&t) {
+ if (s == a)
+ realloc(s, s << 1);
+ const int idx = s++;
+ if (QTypeInfo<T>::isComplex)
+ new (ptr + idx) T(std::move(t));
+ else
+ ptr[idx] = std::move(t);
+ }
+
void append(const T *buf, int size);
inline QVarLengthArray<T, Prealloc> &operator<<(const T &t)
{ append(t); return *this; }
@@ -208,6 +228,7 @@ public:
// STL compatibility:
inline bool empty() const { return isEmpty(); }
inline void push_back(const T &t) { append(t); }
+ void push_back(T &&t) { append(std::move(t)); }
inline void pop_back() { removeLast(); }
inline T &front() { return first(); }
inline const T &front() const { return first(); }
diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc
index 5e53a969e8a..127afcd0699 100644
--- a/src/corelib/tools/qvarlengtharray.qdoc
+++ b/src/corelib/tools/qvarlengtharray.qdoc
@@ -303,6 +303,34 @@
*/
/*!
+ \fn void QVarLengthArray::append(T &&t)
+ \overload append
+ \since 5.9
+
+ \note Unlike the lvalue overload of append(), passing a reference to
+ an object that is already an element of \c *this leads to undefined
+ behavior:
+
+ \code
+ vla.append(std::move(vla[0])); // BUG: passing an object that is already in the container
+ \endcode
+*/
+
+/*!
+ \fn void QVarLengthArray::push_back(T &&t)
+ \overload push_back
+ \since 5.9
+
+ \note Unlike the lvalue overload of push_back(), passing a reference to
+ an object that is already an element of \c *this leads to undefined
+ behavior:
+
+ \code
+ vla.push_back(std::move(vla[0])); // BUG: passing an object that is already in the container
+ \endcode
+*/
+
+/*!
\fn inline void QVarLengthArray::removeLast()
\since 4.5