summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-03-01 08:23:47 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2016-03-01 08:23:55 +0100
commit24cd4a71905a481d937cbd5c4cb9fb8bb91532c9 (patch)
tree67195b6b5fd1a1ddabc0f622082383ad65c94dfb /src/corelib/tools
parentaeb169a48869f4f50237e384e57ccb406228f620 (diff)
parent1dd0c4bf1af1c90fde1449a81d41acbc62cf1934 (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qregexp.cpp2
-rw-r--r--src/corelib/tools/qvector.cpp15
-rw-r--r--src/corelib/tools/qvector.h2
3 files changed, 15 insertions, 4 deletions
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index fd67193302..f8f3347786 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -2335,7 +2335,7 @@ QRegExpCharClass::QRegExpCharClass()
void QRegExpCharClass::clear()
{
c = 0;
- r.resize(0);
+ r.clear();
n = false;
}
diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp
index b3247b8af5..ef1c9c17b0 100644
--- a/src/corelib/tools/qvector.cpp
+++ b/src/corelib/tools/qvector.cpp
@@ -502,8 +502,19 @@
/*! \fn void QVector::clear()
- Removes all the elements from the vector and releases the memory used by
- the vector.
+ Removes all the elements from the vector.
+
+ \note Until Qt 5.6, this also released the memory used by
+ the vector. From Qt 5.7, the capacity is preserved. To shed
+ all capacity, swap with a default-constructed vector:
+ \code
+ QVector<T> v ...;
+ QVector<T>().swap(v);
+ Q_ASSERT(v.capacity() == 0);
+ \endcode
+ or call squeeze().
+
+ \sa squeeze()
*/
/*! \fn const T &QVector::at(int i) const
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index d60be78ade..13ae121450 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -419,7 +419,7 @@ void QVector<T>::resize(int asize)
}
template <typename T>
inline void QVector<T>::clear()
-{ *this = QVector<T>(); }
+{ resize(0); }
template <typename T>
inline const T &QVector<T>::at(int i) const
{ Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::at", "index out of range");