summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-07-17 01:00:21 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2018-07-17 10:19:22 +0200
commit1783fca89768a9d503d886673643dc4542ec467f (patch)
tree5055f39393017219e448ade71b3842896c4679c5 /src/corelib
parentb82648bd59256abb8e7084e0424a1f8a6a034c34 (diff)
parent435d1d53bd61491010dbb2130a27e35cd9798965 (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts: src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/xcb/qxcbintegration.cpp Conflicts git missed: src/plugins/platforms/qnx/qqnxglcontext.cpp Change-Id: I0582cdc9e66e43efe79038b9c43d4f9572ac88fc
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qnamespace.qdoc5
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp20
-rw-r--r--src/corelib/io/qloggingcategory.cpp4
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp7
-rw-r--r--src/corelib/plugin/qelfparser_p.cpp4
-rw-r--r--src/corelib/plugin/qelfparser_p.h2
-rw-r--r--src/corelib/plugin/qlibrary.cpp46
-rw-r--r--src/corelib/plugin/qmachparser.cpp2
-rw-r--r--src/corelib/plugin/qmachparser_p.h2
-rw-r--r--src/corelib/tools/qcollator_icu.cpp6
-rw-r--r--src/corelib/tools/qpoint.h5
-rw-r--r--src/corelib/tools/qstring.cpp2
-rw-r--r--src/corelib/tools/qtimezoneprivate_android.cpp3
13 files changed, 52 insertions, 56 deletions
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index de0c6feeb6..6bd72ff059 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -1366,7 +1366,10 @@
\value Key_Pause The Pause/Break key (\b Note: Not related to pausing media)
\value Key_Print
\value Key_SysReq
- \value Key_Clear
+ \value Key_Clear Corresponds to the \b Clear key on selected Apple
+ keyboard models. On other systems it is commonly mapped
+ to the numeric keypad key \b 5, when \b {Num Lock} is
+ \c off.
\value Key_Home
\value Key_End
\value Key_Left
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 0ffc4ca634..7975ac1d96 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -1113,7 +1113,6 @@ bool QFileSystemEngine::cloneFile(int srcfd, int dstfd, const QFileSystemMetaDat
QT_STATBUF statBuffer;
if (knownData.hasFlags(QFileSystemMetaData::PosixStatFlags) &&
knownData.isFile()) {
- statBuffer.st_size = knownData.size();
statBuffer.st_mode = S_IFREG;
} else if (knownData.hasFlags(QFileSystemMetaData::PosixStatFlags) &&
knownData.isDirectory()) {
@@ -1126,29 +1125,23 @@ bool QFileSystemEngine::cloneFile(int srcfd, int dstfd, const QFileSystemMetaDat
}
#if defined(Q_OS_LINUX)
- if (statBuffer.st_size == 0) {
- // empty file? we're done.
- return true;
- }
-
// first, try FICLONE (only works on regular files and only on certain fs)
if (::ioctl(dstfd, FICLONE, srcfd) == 0)
return true;
// Second, try sendfile (it can send to some special types too).
// sendfile(2) is limited in the kernel to 2G - 4k
- auto sendfileSize = [](QT_OFF_T size) { return size_t(qMin<qint64>(0x7ffff000, size)); };
+ const size_t SendfileSize = 0x7ffff000;
- ssize_t n = ::sendfile(dstfd, srcfd, NULL, sendfileSize(statBuffer.st_size));
+ ssize_t n = ::sendfile(dstfd, srcfd, NULL, SendfileSize);
if (n == -1) {
// if we got an error here, give up and try at an upper layer
return false;
}
- statBuffer.st_size -= n;
- while (statBuffer.st_size) {
- n = ::sendfile(dstfd, srcfd, NULL, sendfileSize(statBuffer.st_size));
- if (n == 0) {
+ while (n) {
+ n = ::sendfile(dstfd, srcfd, NULL, SendfileSize);
+ if (n == -1) {
// uh oh, this is probably a real error (like ENOSPC), but we have
// no way to notify QFile of partial success, so just erase any work
// done (hopefully we won't get any errors, because there's nothing
@@ -1158,9 +1151,6 @@ bool QFileSystemEngine::cloneFile(int srcfd, int dstfd, const QFileSystemMetaDat
n = lseek(dstfd, 0, SEEK_SET);
return false;
}
- if (n == 0)
- return true;
- statBuffer.st_size -= n;
}
return true;
diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp
index a6c27d19c0..d8402c4eb6 100644
--- a/src/corelib/io/qloggingcategory.cpp
+++ b/src/corelib/io/qloggingcategory.cpp
@@ -221,6 +221,8 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift)
All message types for this category are enabled by default.
If \a category is \c{0}, the category name is changed to \c "default".
+
+ Note that \a category must be kept valid during the lifetime of this object.
*/
QLoggingCategory::QLoggingCategory(const char *category)
: d(0),
@@ -235,6 +237,8 @@ QLoggingCategory::QLoggingCategory(const char *category)
If \a category is \c{0}, the category name is changed to \c "default".
+ Note that \a category must be kept valid during the lifetime of this object.
+
\since 5.4
*/
QLoggingCategory::QLoggingCategory(const char *category, QtMsgType enableForLevel)
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp
index 7664b77d81..b7621b5d2f 100644
--- a/src/corelib/io/qstorageinfo_unix.cpp
+++ b/src/corelib/io/qstorageinfo_unix.cpp
@@ -342,13 +342,14 @@ inline bool QStorageIterator::isValid() const
inline bool QStorageIterator::next()
{
QList<QByteArray> data;
+ // If file is virtual, file.readLine() may succeed even when file.atEnd().
do {
const QByteArray line = file.readLine();
+ if (line.isEmpty() && file.atEnd())
+ return false;
data = line.split(' ');
- } while (data.count() < 3 && !file.atEnd());
+ } while (data.count() < 4);
- if (file.atEnd())
- return false;
m_device = data.at(0);
m_rootPath = data.at(1);
m_fileSystemType = data.at(2);
diff --git a/src/corelib/plugin/qelfparser_p.cpp b/src/corelib/plugin/qelfparser_p.cpp
index 7a42b0d023..159a324c6b 100644
--- a/src/corelib/plugin/qelfparser_p.cpp
+++ b/src/corelib/plugin/qelfparser_p.cpp
@@ -63,7 +63,7 @@ const char *QElfParser::parseSectionHeader(const char *data, ElfSectionHeader *s
return data;
}
-int QElfParser::parse(const char *dataStart, ulong fdlen, const QString &library, QLibraryPrivate *lib, long *pos, ulong *sectionlen)
+int QElfParser::parse(const char *dataStart, ulong fdlen, const QString &library, QLibraryPrivate *lib, qsizetype *pos, qsizetype *sectionlen)
{
#if defined(QELFPARSER_DEBUG)
qDebug() << "QElfParser::parse " << library;
@@ -224,7 +224,7 @@ int QElfParser::parse(const char *dataStart, ulong fdlen, const QString &library
return Corrupt;
}
*pos = sh.offset;
- *sectionlen = sh.size - 1;
+ *sectionlen = sh.size;
if (shnam[1] == 'q')
return QtMetaDataSection;
}
diff --git a/src/corelib/plugin/qelfparser_p.h b/src/corelib/plugin/qelfparser_p.h
index 3e73c5d149..1d3578255f 100644
--- a/src/corelib/plugin/qelfparser_p.h
+++ b/src/corelib/plugin/qelfparser_p.h
@@ -96,7 +96,7 @@ public:
}
const char *parseSectionHeader(const char* s, ElfSectionHeader *sh);
- int parse(const char *m_s, ulong fdlen, const QString &library, QLibraryPrivate *lib, long *pos, ulong *sectionlen);
+ int parse(const char *m_s, ulong fdlen, const QString &library, QLibraryPrivate *lib, qsizetype *pos, qsizetype *sectionlen);
};
QT_END_NAMESPACE
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index c2b401af6e..4b55ead668 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
+** Copyright (C) 2018 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -186,7 +186,7 @@ QT_BEGIN_NAMESPACE
*/
-static long qt_find_pattern(const char *s, ulong s_len,
+static qsizetype qt_find_pattern(const char *s, qsizetype s_len,
const char *pattern, ulong p_len)
{
/*
@@ -201,8 +201,10 @@ static long qt_find_pattern(const char *s, ulong s_len,
because we have to skip over all the debugging symbols first
*/
- if (! s || ! pattern || p_len > s_len) return -1;
- ulong i, hs = 0, hp = 0, delta = s_len - p_len;
+ if (!s || !pattern || qsizetype(p_len) > s_len)
+ return -1;
+
+ size_t i, hs = 0, hp = 0, delta = s_len - p_len;
for (i = 0; i < p_len; ++i) {
hs += s[delta + i];
@@ -211,7 +213,7 @@ static long qt_find_pattern(const char *s, ulong s_len,
i = delta;
for (;;) {
if (hs == hp && qstrncmp(s + i, pattern, p_len) == 0)
- return i;
+ return i; // can't overflow, by construction
if (i == 0)
break;
--i;
@@ -245,35 +247,27 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib)
return false;
}
+ // Files can be bigger than the virtual memory size on 32-bit systems, so
+ // we limit to 512 MB there. For 64-bit, we allow up to 2^40 bytes.
+ constexpr qint64 MaxMemoryMapSize =
+ Q_INT64_C(1) << (sizeof(qsizetype) > 4 ? 40 : 29);
+
QByteArray data;
- ulong fdlen = file.size();
+ qsizetype fdlen = qMin(file.size(), MaxMemoryMapSize);
const char *filedata = reinterpret_cast<char *>(file.map(0, fdlen));
if (filedata == 0) {
- if (uchar *mapdata = file.map(0, 1)) {
- file.unmap(mapdata);
- // Mapping is supported, but failed for the entire file, likely due to OOM.
- // Return false, as readAll() would cause a bad_alloc and terminate the process.
- if (lib)
- lib->errorString = QLibrary::tr("Out of memory while loading plugin '%1'.").arg(library);
- if (qt_debug_component()) {
- qWarning("%s: %s", QFile::encodeName(library).constData(),
- qPrintable(QSystemError::stdString(ENOMEM)));
- }
- return false;
- } else {
- // Try reading the data into memory instead.
- data = file.readAll();
- filedata = data.constData();
- fdlen = data.size();
- }
+ // Try reading the data into memory instead (up to 64 MB).
+ data = file.read(64 * 1024 * 1024);
+ filedata = data.constData();
+ fdlen = data.size();
}
/*
ELF and Mach-O binaries with GCC have .qplugin sections.
*/
bool hasMetaData = false;
- long pos = 0;
+ qsizetype pos = 0;
char pattern[] = "qTMETADATA ";
pattern[0] = 'Q'; // Ensure the pattern "QTMETADATA" is not found in this library should QPluginLoader ever encounter it.
const ulong plen = qstrlen(pattern);
@@ -285,7 +279,7 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib)
}
return false;
} else if (r == QElfParser::QtMetaDataSection) {
- long rel = qt_find_pattern(filedata + pos, fdlen, pattern, plen);
+ qsizetype rel = qt_find_pattern(filedata + pos, fdlen, pattern, plen);
if (rel < 0)
pos = -1;
else
@@ -305,7 +299,7 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib)
}
// even if the metadata section was not found, the Mach-O parser will
// at least return the boundaries of the right architecture
- long rel = qt_find_pattern(filedata + pos, fdlen, pattern, plen);
+ qsizetype rel = qt_find_pattern(filedata + pos, fdlen, pattern, plen);
if (rel < 0)
pos = -1;
else
diff --git a/src/corelib/plugin/qmachparser.cpp b/src/corelib/plugin/qmachparser.cpp
index f506a6a6b1..11670cafe9 100644
--- a/src/corelib/plugin/qmachparser.cpp
+++ b/src/corelib/plugin/qmachparser.cpp
@@ -89,7 +89,7 @@ static int ns(const QString &reason, const QString &library, QString *errorStrin
return QMachOParser::NotSuitable;
}
-int QMachOParser::parse(const char *m_s, ulong fdlen, const QString &library, QString *errorString, long *pos, ulong *sectionlen)
+int QMachOParser::parse(const char *m_s, ulong fdlen, const QString &library, QString *errorString, qsizetype *pos, qsizetype *sectionlen)
{
// The minimum size of a Mach-O binary we're interested in.
// It must have a full Mach header, at least one segment and at least one
diff --git a/src/corelib/plugin/qmachparser_p.h b/src/corelib/plugin/qmachparser_p.h
index 3884c92797..290b68876f 100644
--- a/src/corelib/plugin/qmachparser_p.h
+++ b/src/corelib/plugin/qmachparser_p.h
@@ -67,7 +67,7 @@ class Q_AUTOTEST_EXPORT QMachOParser
{
public:
enum { QtMetaDataSection, NoQtSection, NotSuitable };
- static int parse(const char *m_s, ulong fdlen, const QString &library, QString *errorString, long *pos, ulong *sectionlen);
+ static int parse(const char *m_s, ulong fdlen, const QString &library, QString *errorString, qsizetype *pos, qsizetype *sectionlen);
};
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qcollator_icu.cpp b/src/corelib/tools/qcollator_icu.cpp
index ad98a187c5..43bbe0ea79 100644
--- a/src/corelib/tools/qcollator_icu.cpp
+++ b/src/corelib/tools/qcollator_icu.cpp
@@ -116,6 +116,9 @@ int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) con
int QCollator::compare(const QString &s1, const QString &s2) const
{
+ if (d->dirty)
+ d->init();
+
if (d->collator)
return compare(s1.constData(), s1.size(), s2.constData(), s2.size());
@@ -124,6 +127,9 @@ int QCollator::compare(const QString &s1, const QString &s2) const
int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const
{
+ if (d->dirty)
+ d->init();
+
if (d->collator)
return compare(s1.constData(), s1.size(), s2.constData(), s2.size());
diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h
index ae46f0d39f..d7323f7707 100644
--- a/src/corelib/tools/qpoint.h
+++ b/src/corelib/tools/qpoint.h
@@ -351,9 +351,8 @@ QT_WARNING_DISABLE_GCC("-Wfloat-equal")
Q_DECL_CONSTEXPR inline bool operator==(const QPointF &p1, const QPointF &p2)
{
- return ((!p1.xp && !p1.yp) || (!p2.xp && !p2.yp))
- ? (qFuzzyIsNull(p1.xp - p2.xp) && qFuzzyIsNull(p1.yp - p2.yp))
- : (qFuzzyCompare(p1.xp, p2.xp) && qFuzzyCompare(p1.yp, p2.yp));
+ return ((!p1.xp || !p2.xp) ? qFuzzyIsNull(p1.xp - p2.xp) : qFuzzyCompare(p1.xp, p2.xp))
+ && ((!p1.yp || !p2.yp) ? qFuzzyIsNull(p1.yp - p2.yp) : qFuzzyCompare(p1.yp, p2.yp));
}
Q_DECL_CONSTEXPR inline bool operator!=(const QPointF &p1, const QPointF &p2)
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 0cca0823ec..b25e63e115 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -1359,7 +1359,7 @@ const QString::Null QString::null = { };
\ingroup string-processing
QString stores a string of 16-bit \l{QChar}s, where each QChar
- corresponds one Unicode 4.0 character. (Unicode characters
+ corresponds to one UTF-16 code unit. (Unicode characters
with code values above 65535 are stored using surrogate pairs,
i.e., two consecutive \l{QChar}s.)
diff --git a/src/corelib/tools/qtimezoneprivate_android.cpp b/src/corelib/tools/qtimezoneprivate_android.cpp
index b60093617f..be4f374fdd 100644
--- a/src/corelib/tools/qtimezoneprivate_android.cpp
+++ b/src/corelib/tools/qtimezoneprivate_android.cpp
@@ -85,10 +85,9 @@ void QAndroidTimeZonePrivate::init(const QByteArray &ianaId)
// Painfully, JNI gives us back a default zone object if it doesn't
// recognize the name; so check for whether ianaId is a recognized name of
// the zone object we got and ignore the zone if not.
- bool found = false;
// Try checking ianaId against getID(), getDisplayName():
QJNIObjectPrivate jname = androidTimeZone.callObjectMethod("getID", "()Ljava/lang/String;");
- found = (jname.toString().toUtf8() == ianaId);
+ bool found = (jname.toString().toUtf8() == ianaId);
for (int style = 1; !found && style-- > 0;) {
for (int dst = 1; !found && dst-- > 0;) {
jname = androidTimeZone.callObjectMethod("getDisplayName", "(ZI;)Ljava/lang/String;",