summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/itemmodels/qtransposeproxymodel.cpp2
-rw-r--r--src/corelib/kernel/qmetatype_p.h2
-rw-r--r--src/corelib/kernel/qtranslator.cpp7
-rw-r--r--src/corelib/serialization/qcborstream.h4
-rw-r--r--src/corelib/serialization/qjsonwriter.cpp6
-rw-r--r--src/corelib/tools/qbytearray.cpp17
-rw-r--r--src/corelib/tools/qiterator.h4
-rw-r--r--src/corelib/tools/qstring.cpp18
-rw-r--r--src/corelib/tools/qvector.qdoc18
9 files changed, 66 insertions, 12 deletions
diff --git a/src/corelib/itemmodels/qtransposeproxymodel.cpp b/src/corelib/itemmodels/qtransposeproxymodel.cpp
index d4f379bc64..4853f90632 100644
--- a/src/corelib/itemmodels/qtransposeproxymodel.cpp
+++ b/src/corelib/itemmodels/qtransposeproxymodel.cpp
@@ -445,3 +445,5 @@ void QTransposeProxyModel::sort(int column, Qt::SortOrder order)
}
QT_END_NAMESPACE
+
+#include "moc_qtransposeproxymodel.cpp"
diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h
index 97d6001937..fa7208369a 100644
--- a/src/corelib/kernel/qmetatype_p.h
+++ b/src/corelib/kernel/qmetatype_p.h
@@ -74,7 +74,7 @@ template <typename T>
class QTypeModuleInfo
{
public:
- enum Module {
+ enum Module : bool {
IsCore = false,
IsWidget = false,
IsGui = false,
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index dc0ab9f08a..637ef84d21 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -948,11 +948,8 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
end:
if (!tn)
return QString();
- QString str = QString((const QChar *)tn, tn_length/2);
- if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
- QChar *data = str.data();
- qbswap<sizeof(QChar)>(data, str.length(), data);
- }
+ QString str(tn_length / 2, Qt::Uninitialized);
+ qFromBigEndian<ushort>(tn, str.length(), str.data());
return str;
}
diff --git a/src/corelib/serialization/qcborstream.h b/src/corelib/serialization/qcborstream.h
index 3b13a309ab..7a451e63ac 100644
--- a/src/corelib/serialization/qcborstream.h
+++ b/src/corelib/serialization/qcborstream.h
@@ -242,8 +242,8 @@ private:
template <typename FP> FP _toFloatingPoint() const noexcept
{
- using UInt = typename QIntegerForSizeof<FP>::Unsigned;
- UInt u = UInt(value64);
+ using UIntFP = typename QIntegerForSizeof<FP>::Unsigned;
+ UIntFP u = UIntFP(value64);
FP f;
memcpy(static_cast<void *>(&f), &u, sizeof(f));
return f;
diff --git a/src/corelib/serialization/qjsonwriter.cpp b/src/corelib/serialization/qjsonwriter.cpp
index 5b246837d2..012d3bea86 100644
--- a/src/corelib/serialization/qjsonwriter.cpp
+++ b/src/corelib/serialization/qjsonwriter.cpp
@@ -43,6 +43,7 @@
#include "qjsonwriter_p.h"
#include "qjson_p.h"
#include "private/qutfcodec_p.h"
+#include <private/qnumeric_p.h>
QT_BEGIN_NAMESPACE
@@ -135,8 +136,9 @@ static void valueToJson(const QJsonPrivate::Base *b, const QJsonPrivate::Value &
case QJsonValue::Double: {
const double d = v.toDouble(b);
if (qIsFinite(d)) { // +2 to format to ensure the expected precision
- const double abs = std::abs(d);
- json += QByteArray::number(d, abs == static_cast<quint64>(abs) ? 'f' : 'g', QLocale::FloatingPointShortest);
+ quint64 absInt;
+ json += QByteArray::number(d, convertDoubleTo(std::abs(d), &absInt) ? 'f' : 'g',
+ QLocale::FloatingPointShortest);
} else {
json += "null"; // +INF || -INF || NaN (see RFC4627#section2.4)
}
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index c25d39461f..ecbb4743af 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -943,6 +943,23 @@ QByteArray qUncompress(const uchar* data, int nbytes)
and QByteArray() compares equal to QByteArray(""). We recommend
that you always use isEmpty() and avoid isNull().
+ \section1 Maximum size and out-of-memory conditions
+
+ The current version of QByteArray is limited to just under 2 GB (2^31
+ bytes) in size. The exact value is architecture-dependent, since it depends
+ on the overhead required for managing the data block, but is no more than
+ 32 bytes. Raw data blocks are also limited by the use of \c int type in the
+ current version to 2 GB minus 1 byte.
+
+ In case memory allocation fails, QByteArray will throw a \c std::bad_alloc
+ exception. Out of memory conditions in the Qt containers are the only case
+ where Qt will throw exceptions.
+
+ Note that the operating system may impose further limits on applications
+ holding a lot of allocated memory, especially large, contiguous blocks.
+ Such considerations, the configuration of such behavior or any mitigation
+ are outside the scope of the QByteArray API.
+
\section1 Notes on Locale
\section2 Number-String Conversions
diff --git a/src/corelib/tools/qiterator.h b/src/corelib/tools/qiterator.h
index 82212c3eb5..449d1049a0 100644
--- a/src/corelib/tools/qiterator.h
+++ b/src/corelib/tools/qiterator.h
@@ -115,11 +115,11 @@ template <class Key, class T> \
class Q##C##Iterator \
{ \
typedef typename Q##C<Key,T>::const_iterator const_iterator; \
- typedef const_iterator Item; \
Q##C<Key,T> c; \
const_iterator i, n; \
inline bool item_exists() const { return n != c.constEnd(); } \
public: \
+ typedef const_iterator Item; \
inline Q##C##Iterator(const Q##C<Key,T> &container) \
: c(container), i(c.constBegin()), n(c.constEnd()) {} \
inline Q##C##Iterator &operator=(const Q##C<Key,T> &container) \
@@ -148,11 +148,11 @@ class QMutable##C##Iterator \
{ \
typedef typename Q##C<Key,T>::iterator iterator; \
typedef typename Q##C<Key,T>::const_iterator const_iterator; \
- typedef iterator Item; \
Q##C<Key,T> *c; \
iterator i, n; \
inline bool item_exists() const { return const_iterator(n) != c->constEnd(); } \
public: \
+ typedef iterator Item; \
inline QMutable##C##Iterator(Q##C<Key,T> &container) \
: c(&container) \
{ i = c->begin(); n = c->end(); } \
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 319f82af53..47db97cdfc 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -1739,6 +1739,24 @@ const QString::Null QString::null = { };
and the \c{'+'} will automatically be performed as the
\c{QStringBuilder} \c{'%'} everywhere.
+ \section1 Maximum size and out-of-memory conditions
+
+ The current version of QString is limited to just under 2 GB (2^31 bytes)
+ in size. The exact value is architecture-dependent, since it depends on the
+ overhead required for managing the data block, but is no more than 32
+ bytes. Raw data blocks are also limited by the use of \c int type in the
+ current version to 2 GB minus 1 byte. Since QString uses two bytes per
+ character, that translates to just under 2^30 characters in one QString.
+
+ In case memory allocation fails, QString will throw a \c std::bad_alloc
+ exception. Out of memory conditions in the Qt containers are the only case
+ where Qt will throw exceptions.
+
+ Note that the operating system may impose further limits on applications
+ holding a lot of allocated memory, especially large, contiguous blocks.
+ Such considerations, the configuration of such behavior or any mitigation
+ are outside the scope of the Qt API.
+
\sa fromRawData(), QChar, QLatin1String, QByteArray, QStringRef
*/
diff --git a/src/corelib/tools/qvector.qdoc b/src/corelib/tools/qvector.qdoc
index 4c442511ea..8765b7fbd6 100644
--- a/src/corelib/tools/qvector.qdoc
+++ b/src/corelib/tools/qvector.qdoc
@@ -173,6 +173,24 @@
For a detailed discussion comparing Qt containers with each other and
with STL containers, see \l {Understand the Qt Containers}.
+ \section1 Maximum size and out-of-memory conditions
+
+ The current version of QVector is limited to just under 2 GB (2^31 bytes)
+ in size. The exact value is architecture-dependent, since it depends on the
+ overhead required for managing the data block, but is no more than 32
+ bytes. The number of elements that can be stored in a QVector is that size
+ divided by the size of each element.
+
+ In case memory allocation fails, QVector will use the \l Q_CHECK_PTR macro,
+ which will throw a \c std::bad_alloc exception if the application is being
+ compiled with exception support. If exceptions are disabled, then running
+ out of memory is undefined behavior.
+
+ Note that the operating system may impose further limits on applications
+ holding a lot of allocated memory, especially large, contiguous blocks.
+ Such considerations, the configuration of such behavior or any mitigation
+ are outside the scope of the Qt API.
+
\sa QVectorIterator, QMutableVectorIterator, QList, QLinkedList
*/