summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@qt.io>2017-09-02 10:27:08 +0200
committerFrederik Gladhorn <frederik.gladhorn@qt.io>2017-09-02 10:27:09 +0200
commit9831118378c5d489f76089011277a1b7234a8d68 (patch)
treea67e82fde179fa727172fff9098758d60912189d /src/corelib
parentb5d471d0c23128528a0aa33ed5172bb1bab05bb1 (diff)
parent4fa90c1757c15425d5e0df1a4f5dbc7e77c265f8 (diff)
Merge dev into 5.10
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/corelib.pro10
-rw-r--r--src/corelib/global/qfloat16.h2
-rw-r--r--src/corelib/global/qglobal.cpp4
-rw-r--r--src/corelib/global/qnamespace.h1
-rw-r--r--src/corelib/global/qnamespace.qdoc40
-rw-r--r--src/corelib/global/qoperatingsystemversion.cpp9
-rw-r--r--src/corelib/global/qoperatingsystemversion.h1
-rw-r--r--src/corelib/global/qrandom.cpp73
-rw-r--r--src/corelib/io/qdatastream.cpp31
-rw-r--r--src/corelib/io/qfileinfo.cpp22
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp14
-rw-r--r--src/corelib/io/qfilesystemwatcher_inotify.cpp10
-rw-r--r--src/corelib/io/qiodevice.cpp122
-rw-r--r--src/corelib/io/qiodevice.h1
-rw-r--r--src/corelib/io/qiodevice_p.h3
-rw-r--r--src/corelib/io/qprocess.cpp18
-rw-r--r--src/corelib/io/qprocess_unix.cpp12
-rw-r--r--src/corelib/kernel/qcore_mac_p.h3
-rw-r--r--src/corelib/thread/qthread_unix.cpp2
-rw-r--r--src/corelib/tools/qhash.cpp2
-rw-r--r--src/corelib/tools/qsimd_p.h3
-rw-r--r--src/corelib/tools/qstring.h2
22 files changed, 277 insertions, 108 deletions
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index 376ef872ee..7f018bdb94 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -53,8 +53,10 @@ win32 {
# Override MinGW's definition in _mingw.h
DEFINES += WINVER=0x600 _WIN32_WINNT=0x0600
}
-
- !winrt: LIBS_PRIVATE += -lwinmm
+ LIBS_PRIVATE += -lws2_32
+ !winrt {
+ LIBS_PRIVATE += -lkernel32 -luser32 -lshell32 -luuid -lole32 -ladvapi32 -lwinmm
+ }
}
darwin {
@@ -66,7 +68,9 @@ darwin {
LIBS_PRIVATE += -framework Foundation
}
-QMAKE_LIBS += $$QMAKE_LIBS_CORE
+integrity {
+ LIBS_PRIVATE += -lposix -livfs -lsocket -lnet -lshm_client
+}
QMAKE_DYNAMIC_LIST_FILE = $$PWD/QtCore.dynlist
diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h
index 054d503249..89a62a93db 100644
--- a/src/corelib/global/qfloat16.h
+++ b/src/corelib/global/qfloat16.h
@@ -141,7 +141,7 @@ inline qfloat16::operator float() const Q_DECL_NOTHROW
#elif defined (__ARM_FP16_FORMAT_IEEE)
__fp16 f16;
memcpy(&f16, &b16, sizeof(quint16));
- return f16;
+ return float(f16);
#else
quint32 u = mantissatable[offsettable[b16 >> 10] + (b16 & 0x3ff)]
+ exponenttable[b16 >> 10];
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 33d7d58df4..f2f807e1d9 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -2385,6 +2385,7 @@ Lollipop
Marshmallow
Nougat
Nougat
+Oreo
*/
static const char versions_string[] =
"\0"
@@ -2400,13 +2401,14 @@ Nougat
"Lollipop\0"
"Marshmallow\0"
"Nougat\0"
+ "Oreo\0"
"\0";
static const int versions_indices[] = {
0, 0, 0, 1, 9, 15, 15, 15,
22, 28, 28, 40, 40, 40, 50, 50,
69, 69, 69, 80, 80, 87, 87, 96,
- 108, 108, -1
+ 108, 108, 115, -1
};
static const int versions_count = (sizeof versions_indices) / (sizeof versions_indices[0]);
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index fa3d5913b5..ab83730caa 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -513,6 +513,7 @@ public:
AA_DisableShaderDiskCache = 27,
AA_DontShowShortcutsInContextMenus = 28,
AA_CompressTabletEvents = 29,
+ AA_DisableWindowContextHelpButton = 30, // ### Qt 6: remove me
// Add new attributes before this line
AA_AttributeCount
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 4ddb89014e..e74ba4026a 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -128,15 +128,13 @@
\value AA_PluginApplication Indicates that Qt is used to author a plugin. Depending
on the operating system, it suppresses specific initializations that do not
necessarily make sense in the plugin case.
- For example on OS X, this includes avoiding loading our nib for the main
+ For example on \macos, this includes avoiding loading our nib for the main
menu and not taking possession of the native menu bar. Setting this
attribute to true will also set the AA_DontUseNativeMenuBar attribute
to true. It also disables native event filters.
This attribute has been added in Qt 5.7. It must be set before
- \l {QGuiApplication}{Q(Gui)Application} is constructed.
+ \l {QGuiApplication}{Q\(Gui\)Application} is constructed.
- \value AA_MacPluginApplication This attribute has been deprecated.
- Use AA_PluginApplication instead.
\value AA_DontUseNativeMenuBar All menubars created while this attribute is
set to true won't be used as a native menubar (e.g, the menubar at
@@ -155,8 +153,6 @@
to be consistent in pixels-per-point across devices rather than
defining 1 point as 1/72 inch.
- \value AA_X11InitThreads This value is obsolete and has no effect.
-
\value AA_SynthesizeTouchForUnhandledMouseEvents All mouse events
that are not accepted by the application will be translated
to touch events instead.
@@ -179,12 +175,13 @@
\value AA_UseDesktopOpenGL Forces the usage of desktop OpenGL (for example,
\e opengl32.dll or \e libGL.so) on platforms that use dynamic loading
of the OpenGL implementation. This value has been added in Qt 5.3.
- This attribute must be set before Q(Gui)Application is constructed.
+ This attribute must be set before \l {QGuiApplication}
+ {Q\(Gui\)Application} is constructed.
\value AA_UseOpenGLES Forces the usage of OpenGL ES 2.0 or higher on
platforms that use dynamic loading of the OpenGL implementation.
This value has been added in Qt 5.3. This attribute must be set
- before Q(Gui)Application is constructed.
+ before \l {QGuiApplication}{Q\(Gui\)Application} is constructed.
\value AA_UseSoftwareOpenGL Forces the usage of a software based OpenGL
implementation on platforms that use dynamic loading of the OpenGL
@@ -196,24 +193,25 @@
variable \e QT_OPENGL_DLL. See the platform-specific pages, for
instance \l{Qt for Windows}, for more information. This value has
been added in Qt 5.4. This attribute must be set before
- Q(Gui)Application is constructed.
+ \l {QGuiApplication}{Q\(Gui\)Application} is constructed.
\value AA_ShareOpenGLContexts Enables resource sharing between the OpenGL
contexts used by classes like QOpenGLWidget and QQuickWidget. This
allows sharing OpenGL resources, like textures, between QOpenGLWidget
instances that belong to different top-level windows. This value has
been added in Qt 5.4. This attribute must be set before
- Q(Gui)Application is constructed.
+ \l {QGuiApplication}{Q\(Gui\)Application} is constructed.
\value AA_SetPalette Indicates whether a palette was explicitly set on the
- QApplication/QGuiApplication. This value has been added in Qt 5.5.
+ \l {QGuiApplication}{Q\(Gui\)Application}. This value has been added
+ in Qt 5.5.
\value AA_EnableHighDpiScaling Enables high-DPI scaling in Qt on supported
platforms (see also \l{High DPI Displays}). Supported platforms are
X11, Windows and Android. Enabling makes Qt scale the main (device
independent) coordinate system according to display scale factors
provided by the operating system. This corresponds to setting the
- QT_AUTO_SCREEN_SCALE_FACTOR environment variable to 1. This value
+ QT_AUTO_SCREEN\unicode{0x200b}_SCALE_FACTOR environment variable to 1. This value
has been added in Qt 5.6. This attribute must be set before
Q(Gui)Application is constructed.
@@ -221,8 +219,9 @@
system coordinates. Note that the window system may do its own scaling,
so this does not guarantee that QPaintDevice::devicePixelRatio() will
be equal to 1. In addition, scale factors set by QT_SCALE_FACTOR will not
- be affected. This corresponds to setting the QT_AUTO_SCREEN_SCALE_FACTOR
- environment variable to 0. This value has been added in Qt 5.6. This
+ be affected. This corresponds to setting the
+ QT_AUTO_SCREEN\unicode{0x200b}_SCALE_FACTOR environment variable to 0.
+ This value has been added in Qt 5.6. This
attribute must be set before Q(Gui)Application is constructed.
\value AA_UseStyleSheetPropagationInWidgetStyles By default, Qt Style Sheets
@@ -275,7 +274,13 @@
\e glProgramBinary(). In the unlikely event of this being problematic,
set this attribute to disable all disk-based caching of shaders.
- The following values are obsolete:
+ \value AA_DisableWindowContextHelpButton Disables the WindowContextHelpButtonHint
+ by default on Qt::Sheet and Qt::Dialog widgets. This hides the \gui ? button
+ on Windows, which only makes sense if you use \l QWhatsThis functionality.
+ This value has been added in Qt 5.10. For Qt 6, WindowContextHelpButtonHint
+ will not be set by default.
+
+ The following values are deprecated or obsolete:
\value AA_ImmediateWidgetCreation This attribute is no longer fully
supported in Qt 5. It ensures that widgets are created
@@ -287,9 +292,14 @@
Therefore, if it is important to minimize resource
consumption, do not set this attribute.
+ \value AA_MacPluginApplication This attribute has been deprecated.
+ Use AA_PluginApplication instead.
+
\value AA_MSWindowsUseDirect3DByDefault This value is obsolete and
has no effect.
+ \value AA_X11InitThreads This value is obsolete and has no effect.
+
\omitvalue AA_AttributeCount
*/
diff --git a/src/corelib/global/qoperatingsystemversion.cpp b/src/corelib/global/qoperatingsystemversion.cpp
index 83ba6e69ee..594dc6bc17 100644
--- a/src/corelib/global/qoperatingsystemversion.cpp
+++ b/src/corelib/global/qoperatingsystemversion.cpp
@@ -204,6 +204,7 @@ QOperatingSystemVersion QOperatingSystemVersion::current()
{ 6, 0 }, // API level 23
{ 7, 0 }, // API level 24
{ 7, 1 }, // API level 25
+ { 8, 0 }, // API level 26
};
// This will give us at least the first 2 version components
@@ -501,4 +502,12 @@ const QOperatingSystemVersion QOperatingSystemVersion::AndroidNougat =
const QOperatingSystemVersion QOperatingSystemVersion::AndroidNougat_MR1 =
QOperatingSystemVersion(QOperatingSystemVersion::Android, 7, 1);
+/*!
+ \variable QOperatingSystemVersion::AndroidOreo
+ \brief a version corresponding to Android Oreo (version 8.0, API level 26).
+ \since 5.9.2
+ */
+const QOperatingSystemVersion QOperatingSystemVersion::AndroidOreo =
+ QOperatingSystemVersion(QOperatingSystemVersion::Android, 8, 0);
+
QT_END_NAMESPACE
diff --git a/src/corelib/global/qoperatingsystemversion.h b/src/corelib/global/qoperatingsystemversion.h
index 2e319e66d5..1f3ff8e1ab 100644
--- a/src/corelib/global/qoperatingsystemversion.h
+++ b/src/corelib/global/qoperatingsystemversion.h
@@ -80,6 +80,7 @@ public:
static const QOperatingSystemVersion AndroidMarshmallow;
static const QOperatingSystemVersion AndroidNougat;
static const QOperatingSystemVersion AndroidNougat_MR1;
+ static const QOperatingSystemVersion AndroidOreo;
Q_DECL_CONSTEXPR QOperatingSystemVersion(OSType osType,
int vmajor, int vminor = -1, int vmicro = -1)
diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp
index fb20f459b5..395bf0b0cb 100644
--- a/src/corelib/global/qrandom.cpp
+++ b/src/corelib/global/qrandom.cpp
@@ -918,15 +918,16 @@ void QRandomGenerator::fillRange_helper(void *buffer, void *bufferEnd)
fill(buffer, bufferEnd);
}
-#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0)
+#if defined(Q_OS_ANDROID) && (__ANDROID_API__ < 21)
+typedef QThreadStorage<QJNIObjectPrivate> AndroidRandomStorage;
+Q_GLOBAL_STATIC(AndroidRandomStorage, randomTLS)
+
+#elif defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0)
using SeedStorageType = QtPrivate::FunctionPointer<decltype(&srand)>::Arguments::Car;
typedef QThreadStorage<SeedStorageType *> SeedStorage;
Q_GLOBAL_STATIC(SeedStorage, randTLS) // Thread Local Storage for seed value
-#elif defined(Q_OS_ANDROID)
-typedef QThreadStorage<QJNIObjectPrivate> AndroidRandomStorage;
-Q_GLOBAL_STATIC(AndroidRandomStorage, randomTLS)
#endif
/*!
@@ -946,21 +947,7 @@ Q_GLOBAL_STATIC(AndroidRandomStorage, randomTLS)
*/
void qsrand(uint seed)
{
-#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0)
- SeedStorage *seedStorage = randTLS();
- if (seedStorage) {
- SeedStorageType *pseed = seedStorage->localData();
- if (!pseed)
- seedStorage->setLocalData(pseed = new SeedStorageType);
- *pseed = seed;
- } else {
- //global static seed storage should always exist,
- //except after being deleted by QGlobalStaticDeleter.
- //But since it still can be called from destructor of another
- //global static object, fallback to srand(seed)
- srand(seed);
- }
-#elif defined(Q_OS_ANDROID)
+#if defined(Q_OS_ANDROID) && (__ANDROID_API__ < 21)
if (randomTLS->hasLocalData()) {
randomTLS->localData().callMethod<void>("setSeed", "(J)V", jlong(seed));
return;
@@ -975,6 +962,20 @@ void qsrand(uint seed)
}
randomTLS->setLocalData(random);
+#elif defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0)
+ SeedStorage *seedStorage = randTLS();
+ if (seedStorage) {
+ SeedStorageType *pseed = seedStorage->localData();
+ if (!pseed)
+ seedStorage->setLocalData(pseed = new SeedStorageType);
+ *pseed = seed;
+ } else {
+ //global static seed storage should always exist,
+ //except after being deleted by QGlobalStaticDeleter.
+ //But since it still can be called from destructor of another
+ //global static object, fallback to srand(seed)
+ srand(seed);
+ }
#else
// On Windows srand() and rand() already use Thread-Local-Storage
// to store the seed between calls
@@ -1002,23 +1003,7 @@ void qsrand(uint seed)
*/
int qrand()
{
-#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0)
- SeedStorage *seedStorage = randTLS();
- if (seedStorage) {
- SeedStorageType *pseed = seedStorage->localData();
- if (!pseed) {
- seedStorage->setLocalData(pseed = new SeedStorageType);
- *pseed = 1;
- }
- return rand_r(pseed);
- } else {
- //global static seed storage should always exist,
- //except after being deleted by QGlobalStaticDeleter.
- //But since it still can be called from destructor of another
- //global static object, fallback to rand()
- return rand();
- }
-#elif defined(Q_OS_ANDROID)
+#if defined(Q_OS_ANDROID) && (__ANDROID_API__ < 21)
AndroidRandomStorage *randomStorage = randomTLS();
if (!randomStorage)
return rand();
@@ -1038,6 +1023,22 @@ int qrand()
randomStorage->setLocalData(random);
return random.callMethod<jint>("nextInt", "(I)I", RAND_MAX);
+#elif defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0)
+ SeedStorage *seedStorage = randTLS();
+ if (seedStorage) {
+ SeedStorageType *pseed = seedStorage->localData();
+ if (!pseed) {
+ seedStorage->setLocalData(pseed = new SeedStorageType);
+ *pseed = 1;
+ }
+ return rand_r(pseed);
+ } else {
+ //global static seed storage should always exist,
+ //except after being deleted by QGlobalStaticDeleter.
+ //But since it still can be called from destructor of another
+ //global static object, fallback to rand()
+ return rand();
+ }
#else
// On Windows srand() and rand() already use Thread-Local-Storage
// to store the seed between calls
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index 9044ad74b1..1486d3630c 100644
--- a/src/corelib/io/qdatastream.cpp
+++ b/src/corelib/io/qdatastream.cpp
@@ -1385,32 +1385,13 @@ int QDataStream::writeRawData(const char *s, int len)
int QDataStream::skipRawData(int len)
{
CHECK_STREAM_PRECOND(-1)
+ if (q_status != Ok && dev->isTransactionStarted())
+ return -1;
- if (dev->isSequential()) {
- char buf[4096];
- int sumRead = 0;
-
- while (len > 0) {
- int blockSize = qMin(len, (int)sizeof(buf));
- int n = readBlock(buf, blockSize);
- if (n == -1)
- return -1;
- if (n == 0)
- return sumRead;
-
- sumRead += n;
- len -= blockSize;
- }
- return sumRead;
- } else {
- qint64 pos = dev->pos();
- qint64 size = dev->size();
- if (pos + len > size)
- len = size - pos;
- if (!dev->seek(pos + len))
- return -1;
- return len;
- }
+ const int skipResult = dev->skip(len);
+ if (skipResult != len)
+ setStatus(ReadPastEnd);
+ return skipResult;
}
QT_END_NAMESPACE
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index 235e391aa0..26078a6c71 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -870,12 +870,12 @@ QString QFileInfo::suffix() const
\b{Note:} The QDir returned always corresponds to the object's
parent directory, even if the QFileInfo represents a directory.
- For each of the following, dir() returns a QDir for
+ For each of the following, dir() returns the QDir
\c{"~/examples/191697"}.
\snippet fileinfo/main.cpp 0
- For each of the following, dir() returns a QDir for
+ For each of the following, dir() returns the QDir
\c{"."}.
\snippet fileinfo/main.cpp 1
@@ -1034,12 +1034,16 @@ bool QFileInfo::isBundle() const
}
/*!
- Returns \c true if this object points to a symbolic link (or to a
- shortcut on Windows); otherwise returns \c false.
+ Returns \c true if this object points to a symbolic link;
+ otherwise returns \c false.
- On Unix (including \macos and iOS), opening a symlink effectively opens
- the \l{symLinkTarget()}{link's target}. On Windows, it opens the \c
- .lnk file itself.
+ Symbolic links exist on Unix (including \macos and iOS) and Windows
+ and are typically created by the \c{ln -s} or \c{mklink} commands,
+ respectively. Opening a symbolic link effectively opens
+ the \l{symLinkTarget()}{link's target}.
+
+ In addition, true will be returned for shortcuts (\c *.lnk files) on
+ Windows. Opening those will open the \c .lnk file itself.
Example:
@@ -1090,8 +1094,8 @@ bool QFileInfo::isRoot() const
\fn QString QFileInfo::symLinkTarget() const
\since 4.2
- Returns the absolute path to the file or directory a symlink (or shortcut
- on Windows) points to, or a an empty string if the object isn't a symbolic
+ Returns the absolute path to the file or directory a symbolic link
+ points to, or an empty string if the object isn't a symbolic
link.
This name may not represent an existing file; it is only a string.
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 3f2bc04b9c..2828c85048 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -635,13 +635,11 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link,
ret += QFile::decodeName(s);
if (!ret.startsWith(QLatin1Char('/'))) {
- const QString linkFilePath = link.filePath();
- if (linkFilePath.startsWith(QLatin1Char('/'))) {
- ret.prepend(linkFilePath.leftRef(linkFilePath.lastIndexOf(QLatin1Char('/')))
- + QLatin1Char('/'));
- } else {
- ret.prepend(QDir::currentPath() + QLatin1Char('/'));
- }
+ const QString linkPath = link.path();
+ if (linkPath.startsWith(QLatin1Char('/')))
+ ret.prepend(linkPath + QLatin1Char('/'));
+ else
+ ret.prepend(QDir::currentPath() + QLatin1Char('/') + linkPath + QLatin1Char('/'));
}
ret = QDir::cleanPath(ret);
if (ret.size() > 1 && ret.endsWith(QLatin1Char('/')))
@@ -853,7 +851,7 @@ QString QFileSystemEngine::resolveGroupName(uint groupId)
#if !defined(Q_OS_INTEGRITY)
struct group *gr = 0;
-#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS)
+#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID) && (__ANDROID_API__ >= 24))
size_max = sysconf(_SC_GETGR_R_SIZE_MAX);
if (size_max == -1)
size_max = 1024;
diff --git a/src/corelib/io/qfilesystemwatcher_inotify.cpp b/src/corelib/io/qfilesystemwatcher_inotify.cpp
index 3cfc6a254f..048669b92f 100644
--- a/src/corelib/io/qfilesystemwatcher_inotify.cpp
+++ b/src/corelib/io/qfilesystemwatcher_inotify.cpp
@@ -222,6 +222,14 @@ QT_END_NAMESPACE
#include <sys/inotify.h>
+// see https://github.com/android-ndk/ndk/issues/394
+# if defined(Q_OS_ANDROID) && (__ANDROID_API__ < 21)
+static inline int inotify_init1(int flags)
+{
+ return syscall(__NR_inotify_init1, flags);
+}
+# endif
+
#endif
QT_BEGIN_NAMESPACE
@@ -229,7 +237,7 @@ QT_BEGIN_NAMESPACE
QInotifyFileSystemWatcherEngine *QInotifyFileSystemWatcherEngine::create(QObject *parent)
{
int fd = -1;
-#ifdef IN_CLOEXEC
+#if defined(IN_CLOEXEC)
fd = inotify_init1(IN_CLOEXEC);
#endif
if (fd == -1) {
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index 80122eac5e..82fc34c537 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -1879,6 +1879,128 @@ QByteArray QIODevice::peek(qint64 maxSize)
}
/*!
+ \since 5.11
+
+ Skips up to \a maxSize bytes from the device. Returns the number of bytes
+ actually skipped, or -1 on error.
+
+ This function does not wait and only discards the data that is already
+ available for reading.
+
+ If the device is opened in text mode, end-of-line terminators are
+ translated to '\n' symbols and count as a single byte identically to the
+ read() and peek() behavior.
+
+ This function works for all devices, including sequential ones that cannot
+ seek(). It is optimized to skip unwanted data after a peek() call.
+
+ For random-access devices, skip() can be used to seek forward from the
+ current position. Negative \a maxSize values are not allowed.
+
+ \sa peek(), seek(), read()
+*/
+qint64 QIODevice::skip(qint64 maxSize)
+{
+ Q_D(QIODevice);
+ CHECK_MAXLEN(skip, qint64(-1));
+ CHECK_READABLE(skip, qint64(-1));
+
+ const bool sequential = d->isSequential();
+
+#if defined QIODEVICE_DEBUG
+ printf("%p QIODevice::skip(%lld), d->pos = %lld, d->buffer.size() = %lld\n",
+ this, maxSize, d->pos, d->buffer.size());
+#endif
+
+ if ((sequential && d->transactionStarted) || (d->openMode & QIODevice::Text) != 0)
+ return d->skipByReading(maxSize);
+
+ // First, skip over any data in the internal buffer.
+ qint64 skippedSoFar = 0;
+ if (!d->buffer.isEmpty()) {
+ skippedSoFar = d->buffer.skip(maxSize);
+#if defined QIODEVICE_DEBUG
+ printf("%p \tskipping %lld bytes in buffer\n", this, skippedSoFar);
+#endif
+ if (!sequential)
+ d->pos += skippedSoFar;
+ if (d->buffer.isEmpty())
+ readData(nullptr, 0);
+ if (skippedSoFar == maxSize)
+ return skippedSoFar;
+
+ maxSize -= skippedSoFar;
+ }
+
+ // Try to seek on random-access device. At this point,
+ // the internal read buffer is empty.
+ if (!sequential) {
+ const qint64 bytesToSkip = qMin(size() - d->pos, maxSize);
+
+ // If the size is unknown or file position is at the end,
+ // fall back to reading below.
+ if (bytesToSkip > 0) {
+ if (!seek(d->pos + bytesToSkip))
+ return skippedSoFar ? skippedSoFar : Q_INT64_C(-1);
+ if (bytesToSkip == maxSize)
+ return skippedSoFar + bytesToSkip;
+
+ skippedSoFar += bytesToSkip;
+ maxSize -= bytesToSkip;
+ }
+ }
+
+ const qint64 skipResult = d->skip(maxSize);
+ if (skippedSoFar == 0)
+ return skipResult;
+
+ if (skipResult == -1)
+ return skippedSoFar;
+
+ return skippedSoFar + skipResult;
+}
+
+/*!
+ \internal
+*/
+qint64 QIODevicePrivate::skipByReading(qint64 maxSize)
+{
+ qint64 readSoFar = 0;
+ do {
+ char dummy[4096];
+ const qint64 readBytes = qMin<qint64>(maxSize, sizeof(dummy));
+ const qint64 readResult = read(dummy, readBytes);
+
+ // Do not try again, if we got less data.
+ if (readResult != readBytes) {
+ if (readSoFar == 0)
+ return readResult;
+
+ if (readResult == -1)
+ return readSoFar;
+
+ return readSoFar + readResult;
+ }
+
+ readSoFar += readResult;
+ maxSize -= readResult;
+ } while (maxSize > 0);
+
+ return readSoFar;
+}
+
+/*!
+ \internal
+*/
+qint64 QIODevicePrivate::skip(qint64 maxSize)
+{
+ // Base implementation discards the data by reading into the dummy buffer.
+ // It's slow, but this works for all types of devices. Subclasses can
+ // reimplement this function to improve on that.
+ return skipByReading(maxSize);
+}
+
+/*!
Blocks until new data is available for reading and the readyRead()
signal has been emitted, or until \a msecs milliseconds have
passed. If msecs is -1, this function will not time out.
diff --git a/src/corelib/io/qiodevice.h b/src/corelib/io/qiodevice.h
index 162480d22f..e64a4d0bb1 100644
--- a/src/corelib/io/qiodevice.h
+++ b/src/corelib/io/qiodevice.h
@@ -136,6 +136,7 @@ public:
qint64 peek(char *data, qint64 maxlen);
QByteArray peek(qint64 maxlen);
+ qint64 skip(qint64 maxSize);
virtual bool waitForReadyRead(int msecs);
virtual bool waitForBytesWritten(int msecs);
diff --git a/src/corelib/io/qiodevice_p.h b/src/corelib/io/qiodevice_p.h
index 71a326dd53..de2aa1597e 100644
--- a/src/corelib/io/qiodevice_p.h
+++ b/src/corelib/io/qiodevice_p.h
@@ -174,6 +174,9 @@ public:
qint64 read(char *data, qint64 maxSize, bool peeking = false);
virtual qint64 peek(char *data, qint64 maxSize);
virtual QByteArray peek(qint64 maxSize);
+ qint64 skipByReading(qint64 maxSize);
+ // ### Qt6: consider replacing with a protected virtual QIODevice::skipData().
+ virtual qint64 skip(qint64 maxSize);
#ifdef QT_NO_QOBJECT
QIODevice *q_ptr;
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 4e106691f7..7ed319f5f1 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -1024,7 +1024,8 @@ bool QProcessPrivate::tryReadFromChannel(Channel *channel)
if (readBytes == -1) {
setErrorAndEmit(QProcess::ReadError);
#if defined QPROCESS_DEBUG
- qDebug("QProcessPrivate::tryReadFromChannel(%d), failed to read from the process", channel - &stdinChannel);
+ qDebug("QProcessPrivate::tryReadFromChannel(%d), failed to read from the process",
+ int(channel - &stdinChannel));
#endif
return false;
}
@@ -1034,13 +1035,14 @@ bool QProcessPrivate::tryReadFromChannel(Channel *channel)
channel->notifier->setEnabled(false);
closeChannel(channel);
#if defined QPROCESS_DEBUG
- qDebug("QProcessPrivate::tryReadFromChannel(%d), 0 bytes available", channel - &stdinChannel);
+ qDebug("QProcessPrivate::tryReadFromChannel(%d), 0 bytes available",
+ int(channel - &stdinChannel));
#endif
return false;
}
#if defined QPROCESS_DEBUG
- qDebug("QProcessPrivate::tryReadFromChannel(%d), read %d bytes from the process' output", channel - &stdinChannel
- int(readBytes));
+ qDebug("QProcessPrivate::tryReadFromChannel(%d), read %d bytes from the process' output",
+ int(channel - &stdinChannel), int(readBytes));
#endif
if (channel->closed) {
@@ -2121,8 +2123,12 @@ void QProcess::start(OpenMode mode)
\note On QNX, this may cause all application threads to
temporarily freeze.
- If the function is successful then *\a pid is set to the process
- identifier of the started process.
+ If the function is successful then *\a pid is set to the process identifier
+ of the started process. Note that the child process may exit and the PID
+ may become invalid without notice. Furthermore, after the child process
+ exits, the same PID may be recycled and used by a completely different
+ process. User code should be careful when using this variable, especially
+ if one intends to forcibly terminate the process by operating system means.
Only the following property setters are supported by startDetached():
\list
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index cf9d38097a..15752f84b2 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -762,6 +762,10 @@ bool QProcessPrivate::waitForReadyRead(int msecs)
if (qt_pollfd_check(poller.stdinPipe(), POLLOUT))
_q_canWrite();
+ // Signals triggered by I/O may have stopped this process:
+ if (processState == QProcess::NotRunning)
+ return false;
+
if (qt_pollfd_check(poller.forkfd(), POLLIN)) {
if (_q_processDied())
return false;
@@ -808,6 +812,10 @@ bool QProcessPrivate::waitForBytesWritten(int msecs)
if (qt_pollfd_check(poller.stderrPipe(), POLLIN))
_q_canReadStandardError();
+ // Signals triggered by I/O may have stopped this process:
+ if (processState == QProcess::NotRunning)
+ return false;
+
if (qt_pollfd_check(poller.forkfd(), POLLIN)) {
if (_q_processDied())
return false;
@@ -853,6 +861,10 @@ bool QProcessPrivate::waitForFinished(int msecs)
if (qt_pollfd_check(poller.stderrPipe(), POLLIN))
_q_canReadStandardError();
+ // Signals triggered by I/O may have stopped this process:
+ if (processState == QProcess::NotRunning)
+ return true;
+
if (qt_pollfd_check(poller.forkfd(), POLLIN)) {
if (_q_processDied())
return true;
diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h
index 5be8df1a48..5522a617b3 100644
--- a/src/corelib/kernel/qcore_mac_p.h
+++ b/src/corelib/kernel/qcore_mac_p.h
@@ -129,7 +129,8 @@ public:
template <typename X> X as() const { return reinterpret_cast<X>(this->value); }
static QCFType constructFromGet(const T &t)
{
- CFRetain(t);
+ if (t)
+ CFRetain(t);
return QCFType<T>(t);
}
};
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index cddc4053b1..6540f02f34 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -105,7 +105,7 @@
# define SCHED_IDLE 5
#endif
-#if defined(Q_OS_DARWIN) || !defined(Q_OS_OPENBSD) && defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && (_POSIX_THREAD_PRIORITY_SCHEDULING-0 >= 0)
+#if defined(Q_OS_DARWIN) || !defined(Q_OS_ANDROID) && !defined(Q_OS_OPENBSD) && defined(_POSIX_THREAD_PRIORITY_SCHEDULING) && (_POSIX_THREAD_PRIORITY_SCHEDULING-0 >= 0)
#define QT_HAS_THREAD_PRIORITY_SCHEDULING
#endif
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index 9d8c276cff..e336b7e618 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -140,7 +140,9 @@ static inline bool hasFastCrc32()
}
template <typename Char>
+#if defined(Q_PROCESSOR_ARM_64)
QT_FUNCTION_TARGET(CRC32)
+#endif
static uint crc32(const Char *ptr, size_t len, uint h)
{
// The crc32[whbd] instructions on Aarch64/Aarch32 calculate a 32-bit CRC32 checksum
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index 3ef29f4823..181da4f7de 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -326,7 +326,10 @@
#endif
// AArch64/ARM64
#if defined(Q_PROCESSOR_ARM_V8) && defined(__ARM_FEATURE_CRC32)
+#if defined(Q_PROCESSOR_ARM_64)
+// only available on aarch64
#define QT_FUNCTION_TARGET_STRING_CRC32 "+crc"
+#endif
# include <arm_acle.h>
#endif
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index a3e100c568..16472ff6b9 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -56,7 +56,7 @@
#include <string>
#include <iterator>
-#if defined(Q_OS_ANDROID)
+#if defined(Q_OS_ANDROID) && !defined(ANDROID_HAS_WSTRING)
// std::wstring is disabled on android's glibc, as bionic lacks certain features
// that libstdc++ checks for (like mbcslen).
namespace std