summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/animation/qabstractanimation.cpp7
-rw-r--r--src/corelib/codecs/qutfcodec.cpp44
-rw-r--r--src/corelib/doc/qtcore.qdocconf2
-rw-r--r--src/corelib/doc/snippets/code/doc_src_plugins-howto.pro4
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qregexp.cpp2
-rw-r--r--src/corelib/doc/src/plugins-howto.qdoc50
-rw-r--r--src/corelib/global/qcompilerdetection.h23
-rw-r--r--src/corelib/global/qglobal.h3
-rw-r--r--src/corelib/global/qlogging.cpp36
-rw-r--r--src/corelib/io/qfiledevice.cpp7
-rw-r--r--src/corelib/io/qfileinfo.cpp11
-rw-r--r--src/corelib/io/qfilesystemengine.cpp4
-rw-r--r--src/corelib/io/qfilesystemiterator_p.h4
-rw-r--r--src/corelib/io/qfilesystemiterator_unix.cpp15
-rw-r--r--src/corelib/io/qfilesystemwatcher_polling.cpp10
-rw-r--r--src/corelib/io/qwindowspipereader.cpp1
-rw-r--r--src/corelib/io/qwindowspipewriter.cpp1
-rw-r--r--src/corelib/kernel/qmath.cpp84
-rw-r--r--src/corelib/kernel/qmath.qdoc95
-rw-r--r--src/corelib/kernel/qobject.cpp17
-rw-r--r--src/corelib/kernel/qobject.h2
-rw-r--r--src/corelib/kernel/qtranslator.cpp6
-rw-r--r--src/corelib/thread/qthread_win.cpp21
-rw-r--r--src/corelib/tools/qarraydata.cpp13
-rw-r--r--src/corelib/tools/qarraydata.h4
-rw-r--r--src/corelib/tools/qarraydatapointer.h4
-rw-r--r--src/corelib/tools/qchar.h3
-rw-r--r--src/corelib/tools/qcollator.cpp5
-rw-r--r--src/corelib/tools/qcontiguouscache.h2
-rw-r--r--src/corelib/tools/qhash.h2
-rw-r--r--src/corelib/tools/qlinkedlist.h2
-rw-r--r--src/corelib/tools/qlist.h2
-rw-r--r--src/corelib/tools/qmap.h2
-rw-r--r--src/corelib/tools/qrefcount.h18
-rw-r--r--src/corelib/tools/qregexp.cpp4
-rw-r--r--src/corelib/tools/qset.h2
-rw-r--r--src/corelib/tools/qsize.cpp2
-rw-r--r--src/corelib/tools/qstring.cpp24
-rw-r--r--src/corelib/tools/qstring.h3
-rw-r--r--src/corelib/tools/qtimezone.cpp7
-rw-r--r--src/corelib/tools/qunicodetools.cpp38
-rw-r--r--src/corelib/tools/qvector.h14
-rw-r--r--src/corelib/tools/tools.pri4
43 files changed, 367 insertions, 237 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index f7bb1e91bd..95d7713cfe 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -253,8 +253,9 @@ QUnifiedTimer *QUnifiedTimer::instance()
void QUnifiedTimer::maybeUpdateAnimationsToCurrentTime()
{
- if (time.elapsed() - lastTick > 50)
- updateAnimationTimers(driver->elapsed());
+ qint64 elapsed = driver->elapsed();
+ if (elapsed - lastTick > 50)
+ updateAnimationTimers(elapsed);
}
void QUnifiedTimer::updateAnimationTimers(qint64 currentTick)
@@ -263,7 +264,7 @@ void QUnifiedTimer::updateAnimationTimers(qint64 currentTick)
if(insideTick)
return;
- qint64 totalElapsed = currentTick >= 0 ? currentTick : time.elapsed();
+ qint64 totalElapsed = currentTick >= 0 ? currentTick : driver->elapsed();
// ignore consistentTiming in case the pause timer is active
qint64 delta = (consistentTiming && !pauseTimer.isActive()) ?
diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp
index 54312601e4..072cda63aa 100644
--- a/src/corelib/codecs/qutfcodec.cpp
+++ b/src/corelib/codecs/qutfcodec.cpp
@@ -52,6 +52,8 @@ QT_BEGIN_NAMESPACE
enum { Endian = 0, Data = 1 };
+static const uchar utf8bom[] = { 0xef, 0xbb, 0xbf };
+
#if defined(__SSE2__) && defined(QT_COMPILER_SUPPORTS_SSE2)
static inline bool simdEncodeAscii(uchar *&dst, const ushort *&nextAscii, const ushort *&src, const ushort *end)
{
@@ -187,9 +189,9 @@ QByteArray QUtf8::convertFromUnicode(const QChar *uc, int len, QTextCodec::Conve
int invalid = 0;
if (state && !(state->flags & QTextCodec::IgnoreHeader)) {
// append UTF-8 BOM
- *cursor++ = 0xef;
- *cursor++ = 0xbb;
- *cursor++ = 0xbf;
+ *cursor++ = utf8bom[0];
+ *cursor++ = utf8bom[1];
+ *cursor++ = utf8bom[2];
}
const ushort *nextAscii = src;
@@ -240,19 +242,31 @@ QString QUtf8::convertToUnicode(const char *chars, int len)
const uchar *src = reinterpret_cast<const uchar *>(chars);
const uchar *end = src + len;
- while (src < end) {
- const uchar *nextAscii = end;
- if (simdDecodeAscii(dst, nextAscii, src, end))
- break;
+ // attempt to do a full decoding in SIMD
+ const uchar *nextAscii = end;
+ if (!simdDecodeAscii(dst, nextAscii, src, end)) {
+ // at least one non-ASCII entry
+ // check if we failed to decode the UTF-8 BOM; if so, skip it
+ if (Q_UNLIKELY(src == reinterpret_cast<const uchar *>(chars))
+ && end - src >= 3
+ && Q_UNLIKELY(src[0] == utf8bom[0] && src[1] == utf8bom[1] && src[2] == utf8bom[2])) {
+ src += 3;
+ }
- do {
- uchar b = *src++;
- int res = QUtf8Functions::fromUtf8<QUtf8BaseTraits>(b, dst, src, end);
- if (res < 0) {
- // decoding error
- *dst++ = QChar::ReplacementCharacter;
- }
- } while (src < nextAscii);
+ while (src < end) {
+ nextAscii = end;
+ if (simdDecodeAscii(dst, nextAscii, src, end))
+ break;
+
+ do {
+ uchar b = *src++;
+ int res = QUtf8Functions::fromUtf8<QUtf8BaseTraits>(b, dst, src, end);
+ if (res < 0) {
+ // decoding error
+ *dst++ = QChar::ReplacementCharacter;
+ }
+ } while (src < nextAscii);
+ }
}
result.truncate(dst - reinterpret_cast<const ushort *>(result.constData()));
diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf
index 18342d0138..c8eb15a7f7 100644
--- a/src/corelib/doc/qtcore.qdocconf
+++ b/src/corelib/doc/qtcore.qdocconf
@@ -26,7 +26,7 @@ qhp.QtCore.subprojects.classes.sortPages = true
tagfile = ../../../doc/qtcore/qtcore.tags
-depends += qtgui qtwidgets qtnetwork qtdoc qtmacextras qtquick qtlinguist qtdesigner qtconcurrent qtxml qmake
+depends += activeqt qtdbus qtgui qtwidgets qtnetwork qtdoc qtmacextras qtqml qtquick qtlinguist qtdesigner qtconcurrent qtxml qmake
headerdirs += ..
diff --git a/src/corelib/doc/snippets/code/doc_src_plugins-howto.pro b/src/corelib/doc/snippets/code/doc_src_plugins-howto.pro
index 5eb9604ed7..dc75c1d9d7 100644
--- a/src/corelib/doc/snippets/code/doc_src_plugins-howto.pro
+++ b/src/corelib/doc/snippets/code/doc_src_plugins-howto.pro
@@ -43,7 +43,7 @@ CONFIG += release
#! [3]
#! [4]
-CONFIG += qpa_minimal_plugin
+QTPLUGIN.platforms = qminimal
#! [4]
#! [5]
@@ -53,7 +53,7 @@ QTPLUGIN += qjpeg \
#! [5]
#! [6]
-CONFIG -= import_qpa_plugin
+QTPLUGIN.platforms = -
#! [6]
#! [7]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qregexp.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qregexp.cpp
index 779fbaa723..530819a173 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qregexp.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qregexp.cpp
@@ -77,7 +77,7 @@ QRegExp mark("\\b" // word boundary
QRegExp rx("^\\d\\d?$"); // match integers 0 to 99
rx.indexIn("123"); // returns -1 (no match)
rx.indexIn("-6"); // returns -1 (no match)
-rx.indexIn("6"); // returns 0 (matched as position 0)
+rx.indexIn("6"); // returns 0 (matched at position 0)
//! [4]
diff --git a/src/corelib/doc/src/plugins-howto.qdoc b/src/corelib/doc/src/plugins-howto.qdoc
index 7565d610cc..7dc0d01cce 100644
--- a/src/corelib/doc/src/plugins-howto.qdoc
+++ b/src/corelib/doc/src/plugins-howto.qdoc
@@ -234,7 +234,7 @@
application is to compile it into a dynamic library that is shipped
separately, and detected and loaded at runtime.
- Plugins can be linked statically against your application. If you
+ Plugins can be linked statically into your application. If you
build the static version of Qt, this is the only option for
including Qt's predefined plugins. Using static plugins makes the
deployment less error-prone, but has the disadvantage that no
@@ -253,7 +253,8 @@
\row \li \c qico \li Image formats \li ICO
\row \li \c qsvg \li Image formats \li SVG
\row \li \c qtiff \li Image formats \li TIFF
- \row \li \c qsqldb2 \li SQL driver \li IBM DB2 \row \li \c qsqlibase \li SQL driver \li Borland InterBase
+ \row \li \c qsqldb2 \li SQL driver \li IBM DB2
+ \row \li \c qsqlibase \li SQL driver \li Borland InterBase
\row \li \c qsqlite \li SQL driver \li SQLite version 3
\row \li \c qsqlite2 \li SQL driver \li SQLite version 2
\row \li \c qsqlmysql \li SQL driver \li MySQL
@@ -263,22 +264,48 @@
\row \li \c qsqltds \li SQL driver \li Sybase Adaptive Server (TDS)
\endtable
- To link statically against those plugins, you need to add
+ To link those plugins statically, you need to add
the required plugins to your build using \c QTPLUGIN.
- Q_IMPORT_PLUGIN() macros are also needed in application code,
- but those are automatically generated by qmake and added to
- your application project.
In the \c .pro file for your application, you need the following
entry:
\snippet code/doc_src_plugins-howto.pro 5
+ qmake automatically adds the plugins to QTPLUGIN that are typically
+ needed by the used Qt modules (see \c QT), while more specialized
+ plugins need to be added manually.
+ The default list of automatically added plugins can be overridden
+ per type.
+ For example, to link the minimal plugin instead of the default Qt
+ platform adaptation plugin, use:
+
+ \snippet code/doc_src_plugins-howto.pro 4
+
+ If you want neither the default nor the minimal QPA plugin to be
+ linked automatically, use:
+
+ \snippet code/doc_src_plugins-howto.pro 6
+
+ The defaults are tuned towards an optimal out-of-the-box experience,
+ but may unnecessarily bloat the application.
+ It is recommended to inspect the linker command line built by qmake
+ and eliminate unnecessary plugins.
+
+ \section2 Details of Linking Static Plugins
+
+ To cause static plugins actually being linked and instantiated,
+ Q_IMPORT_PLUGIN() macros are also needed in application code,
+ but those are automatically generated by qmake and added to
+ your application project.
+
If you do not want all plugins added to QTPLUGIN to be automatically
linked, remove \c import_plugins from the \c CONFIG variable:
\snippet code/doc_src_plugins-howto.pro 7
+ \section2 Creating Static Plugins
+
It is also possible to create your own static plugins, by
following these steps:
@@ -297,17 +324,6 @@
to make sure that the \c{QT_STATICPLUGIN} preprocessor macro is
defined.
- The default Qt platform adaptation plugin is automatically added to QTPLUGIN
- in static builds. If you want to add the minimal plugin instead, add \c qpa_minimal_plugin
- to \c CONFIG:
-
- \snippet code/doc_src_plugins-howto.pro 4
-
- If you want neither the default nor the minimal QPA plugin to be linked automatically,
- remove \c import_qpa_plugin from \c CONFIG:
-
- \snippet code/doc_src_plugins-howto.pro 6
-
\section1 Deploying and Debugging Plugins
The \l{Deploying Plugins} document covers the process of deploying
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index b62ae30fc5..bb892cf751 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -844,21 +844,28 @@
#endif /* Q_CC_MSVC */
#ifdef __cplusplus
+# include <utility>
# if defined(Q_OS_QNX)
-# include <utility>
# if defined(_YVALS) || defined(_LIBCPP_VER)
// QNX: libcpp (Dinkumware-based) doesn't have the <initializer_list>
// header, so the feature is useless, even if the compiler supports
// it. Disable.
-# ifdef Q_COMPILER_INITIALIZER_LISTS
-# undef Q_COMPILER_INITIALIZER_LISTS
-# endif
-# ifdef Q_COMPILER_RVALUE_REFS
-# undef Q_COMPILER_RVALUE_REFS
-# endif
+# undef Q_COMPILER_INITIALIZER_LISTS
+// That libcpp doesn't have std::move either, so disable everything
+// related to rvalue refs.
+# undef Q_COMPILER_RVALUE_REFS
+# undef Q_COMPILER_REF_QUALIFIERS
# endif
+# endif // Q_OS_QNX
+# if (defined(Q_CC_CLANG) || defined(Q_CC_INTEL)) && defined(Q_OS_MAC) && defined(__GNUC_LIBSTD__) \
+ && ((__GNUC_LIBSTD__-0) * 100 + __GNUC_LIBSTD_MINOR__-0 <= 402)
+// Mac OS X: Apple has not updated libstdc++ since 2007, which means it does not have
+// <initializer_list> or std::move. Let's disable these features
+# undef Q_COMPILER_INITIALIZER_LISTS
+# undef Q_COMPILER_RVALUE_REFS
+# undef Q_COMPILER_REF_QUALIFIERS
# endif
-#endif // Q_OS_QNX
+#endif
/*
* C++11 keywords and expressions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 3832e70c94..a9621e744c 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -58,7 +58,10 @@
#if !defined(QT_BUILD_QMAKE) && !defined(QT_BUILD_CONFIGURE)
#include <QtCore/qconfig.h>
#include <QtCore/qfeatures.h>
+#endif
#define QT_SUPPORTS(FEATURE) (!defined(QT_NO_##FEATURE))
+#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
+# define QT_NO_UNSHARABLE_CONTAINERS
#endif
/* These two macros makes it possible to turn the builtin line expander into a
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index da26490d18..4a602e4b2b 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -1207,6 +1207,23 @@ static void android_default_message_handler(QtMsgType type,
static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &context,
const QString &buf)
{
+ // to determine logging destination and marking logging environment variable as deprecated
+ // ### remove when deprecated
+ struct LogDestination {
+ LogDestination(const char *deprecated, bool forceConsole) {
+ const char* replacement = "QT_LOGGING_TO_CONSOLE";
+ bool newEnv = qEnvironmentVariableIsSet(replacement);
+ bool oldEnv = qEnvironmentVariableIsSet(deprecated);
+ if (oldEnv && !newEnv && !forceConsole) {
+ fprintf(stderr, "Warning: Environment variable %s is deprecated, "
+ "use %s instead.\n", deprecated, replacement);
+ fflush(stderr);
+ }
+ toConsole = newEnv || oldEnv || forceConsole;
+ }
+ bool toConsole;
+ };
+
QString logMessage = qMessageFormatString(type, context, buf);
#if defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB)
@@ -1217,12 +1234,19 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con
#endif // Q_OS_WIN
#if defined(QT_USE_SLOG2)
- slog2_default_handler(type, logMessage.toLocal8Bit().constData());
+ static const bool logToConsole = qEnvironmentVariableIsSet("QT_LOGGING_TO_CONSOLE");
+ if (!logToConsole) {
+ slog2_default_handler(type, logMessage.toLocal8Bit().constData());
+ } else {
+ fprintf(stderr, "%s", logMessage.toLocal8Bit().constData());
+ fflush(stderr);
+ }
#elif defined(QT_USE_JOURNALD) && !defined(QT_BOOTSTRAPPED)
// We use isatty to catch the obvious case of someone running something interactively.
- // We also support an environment variable for Qt Creator use, or more complicated cases like subprocesses.
- static bool logToConsole = isatty(fileno(stdin)) || !qEnvironmentVariableIsEmpty("QT_NO_JOURNALD_LOG");
- if (Q_LIKELY(!logToConsole)) {
+ // We also support environment variables for Qt Creator use, or more complicated cases
+ // like subprocesses.
+ static const LogDestination logdest("QT_NO_JOURNALD_LOG", isatty(fileno(stdin)));
+ if (Q_LIKELY(!logdest.toConsole)) {
// remove trailing \n, systemd appears to want them newline-less
logMessage.chop(1);
systemd_default_message_handler(type, context, logMessage);
@@ -1231,8 +1255,8 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con
fflush(stderr);
}
#elif defined(Q_OS_ANDROID)
- static bool logToAndroid = qEnvironmentVariableIsEmpty("QT_ANDROID_PLAIN_LOG");
- if (logToAndroid) {
+ static const LogDestination logdest("QT_ANDROID_PLAIN_LOG", false);
+ if (!logdest.toConsole) {
android_default_message_handler(type, context, logMessage);
} else {
fprintf(stderr, "%s", logMessage.toLocal8Bit().constData());
diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp
index d2c8d37d4a..f7e58a7bed 100644
--- a/src/corelib/io/qfiledevice.cpp
+++ b/src/corelib/io/qfiledevice.cpp
@@ -139,10 +139,9 @@ void QFileDevicePrivate::setError(QFileDevice::FileError err, int errNum)
are returned and on Windows the rights of the current user are
returned. This behavior might change in a future Qt version.
- Note that Qt does not by default check for permissions on NTFS
- file systems, as this may decrease the performance of file
- handling considerably. It is possible to force permission checking
- on NTFS by including the following code in your source:
+ \note On NTFS file systems, ownership and permissions checking is
+ disabled by default for performance reasons. To enable it,
+ include the following line:
\snippet ntfsp.cpp 0
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index 2cf97ef94e..60f7e47e62 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -271,6 +271,17 @@ QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request)
groupId(). You can examine a file's permissions and ownership in a
single statement using the permission() function.
+ \note On NTFS file systems, ownership and permissions checking is
+ disabled by default for performance reasons. To enable it,
+ include the following line:
+
+ \snippet ntfsp.cpp 0
+
+ Permission checking is then turned on and off by incrementing and
+ decrementing \c qt_ntfs_permission_lookup by 1.
+
+ \snippet ntfsp.cpp 1
+
\section1 Performance Issues
Some of QFileInfo's functions query the file system, but for
diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp
index 53cf6158ad..8b6ceebc62 100644
--- a/src/corelib/io/qfilesystemengine.cpp
+++ b/src/corelib/io/qfilesystemengine.cpp
@@ -224,7 +224,7 @@ bool QFileSystemEngine::fillMetaData(int fd, QFileSystemMetaData &data)
return false;
}
-#if defined(Q_OS_QNX)
+#if defined(QT_EXT_QNX_READDIR_R)
static void fillStat64fromStat32(struct stat64 *statBuf64, const struct stat &statBuf32)
{
statBuf64->st_mode = statBuf32.st_mode;
@@ -289,7 +289,7 @@ void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer)
void QFileSystemMetaData::fillFromDirEnt(const QT_DIRENT &entry)
{
-#if defined(Q_OS_QNX)
+#if defined(QT_EXT_QNX_READDIR_R)
knownFlagsMask = 0;
entryFlags = 0;
for (dirent_extra *extra = _DEXTRA_FIRST(&entry); _DEXTRA_VALID(extra, &entry);
diff --git a/src/corelib/io/qfilesystemiterator_p.h b/src/corelib/io/qfilesystemiterator_p.h
index 4164020359..18a9c2dbda 100644
--- a/src/corelib/io/qfilesystemiterator_p.h
+++ b/src/corelib/io/qfilesystemiterator_p.h
@@ -95,10 +95,10 @@ private:
#else
QT_DIR *dir;
QT_DIRENT *dirEntry;
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN)
+#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) || defined(QT_EXT_QNX_READDIR_R)
// for readdir_r
QScopedPointer<QT_DIRENT, QScopedPointerPodDeleter> mt_file;
-#if defined(Q_OS_QNX) && defined(__EXT_QNX__READDIR_R)
+#if defined(QT_EXT_QNX_READDIR_R)
// for _readdir_r
size_t direntSize;
#endif
diff --git a/src/corelib/io/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp
index 0b59aa169a..0f9bbd8a29 100644
--- a/src/corelib/io/qfilesystemiterator_unix.cpp
+++ b/src/corelib/io/qfilesystemiterator_unix.cpp
@@ -70,7 +70,7 @@ QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Fi
if (!nativePath.endsWith('/'))
nativePath.append('/');
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN)
+#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) || defined(QT_EXT_QNX_READDIR_R)
// ### Race condition; we should use fpathconf and dirfd().
size_t maxPathName = ::pathconf(nativePath.constData(), _PC_NAME_MAX);
if (maxPathName == size_t(-1))
@@ -81,13 +81,14 @@ QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Fi
Q_CHECK_PTR(p);
mt_file.reset(p);
-#if defined(Q_OS_QNX) && defined(__EXT_QNX__READDIR_R)
+#if defined(QT_EXT_QNX_READDIR_R)
direntSize = maxPathName;
- // Include extra stat information in the readdir() call (d_stat member of dirent_extra_stat).
- // This is used in QFileSystemMetaData::fillFromDirEnt() to avoid extra stat() calls when iterating
- // over directories
- if (dircntl(dir, D_SETFLAG, D_FLAG_STAT) == -1)
+ // Include extra stat information in the readdir() call (d_stat member of
+ // dirent_extra_stat). This is used in QFileSystemMetaData::fillFromDirEnt() to
+ // avoid extra stat() calls when iterating over directories
+ int flags = dircntl(dir, D_GETFLAG) | D_FLAG_STAT | D_FLAG_FILTER;
+ if (dircntl(dir, D_SETFLAG, flags) == -1)
lastError = errno;
#endif
#endif
@@ -105,7 +106,7 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa
if (!dir)
return false;
-#if defined(Q_OS_QNX) && defined(QT_EXT_QNX_READDIR_R)
+#if defined(QT_EXT_QNX_READDIR_R)
lastError = QT_EXT_QNX_READDIR_R(dir, mt_file.data(), &dirEntry, direntSize);
if (lastError)
return false;
diff --git a/src/corelib/io/qfilesystemwatcher_polling.cpp b/src/corelib/io/qfilesystemwatcher_polling.cpp
index 689f05bb1b..401f95ae82 100644
--- a/src/corelib/io/qfilesystemwatcher_polling.cpp
+++ b/src/corelib/io/qfilesystemwatcher_polling.cpp
@@ -65,14 +65,16 @@ QStringList QPollingFileSystemWatcherEngine::addPaths(const QStringList &paths,
if (!fi.exists())
continue;
if (fi.isDir()) {
- if (!directories->contains(path))
- directories->append(path);
+ if (directories->contains(path))
+ continue;
+ directories->append(path);
if (!path.endsWith(QLatin1Char('/')))
fi = QFileInfo(path + QLatin1Char('/'));
this->directories.insert(path, fi);
} else {
- if (!files->contains(path))
- files->append(path);
+ if (files->contains(path))
+ continue;
+ files->append(path);
this->files.insert(path, fi);
}
it.remove();
diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp
index df65aebcff..7dd2125e70 100644
--- a/src/corelib/io/qwindowspipereader.cpp
+++ b/src/corelib/io/qwindowspipereader.cpp
@@ -318,6 +318,7 @@ bool QWindowsPipeReader::waitForPipeClosed(int msecs)
QElapsedTimer stopWatch;
stopWatch.start();
forever {
+ waitForReadyRead(0);
checkPipeState();
if (pipeBroken)
return true;
diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp
index daa8068734..daad542705 100644
--- a/src/corelib/io/qwindowspipewriter.cpp
+++ b/src/corelib/io/qwindowspipewriter.cpp
@@ -40,7 +40,6 @@
****************************************************************************/
#include "qwindowspipewriter_p.h"
-#include <string.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/kernel/qmath.cpp b/src/corelib/kernel/qmath.cpp
index b1860fa24a..9f276b4ca9 100644
--- a/src/corelib/kernel/qmath.cpp
+++ b/src/corelib/kernel/qmath.cpp
@@ -303,88 +303,4 @@ const qreal qt_sine_table[QT_SINE_TABLE_SIZE] = {
qreal(-0.024541228522912448)
};
-/*!
- \headerfile <QtMath>
- \title Generic Math Declarations
- \ingroup funclists
-
- \brief The <QtMath> header file includes generic math declarations.
-
- These functions are partly convenience definitions for basic
- operations, for instance not available in the Standard Template Library et
- al.
-*/
-
-/*!
- \fn float qDegreesToRadians(float degrees)
- \relates <QtMath>
- \since 5.1
-
- \brief The function converts the \a degrees in float to radians.
-
- The purpose of the function is to aid the conversion as such a convenient
- function is not part of the Standard Template Library, i.e. in <cmath> or
- elsewhere.
-
- Example:
-
- \snippet code/src_corelib_kernel_qmath.cpp 0
-
- \sa qRadiansToDegrees()
-*/
-
-/*!
- \fn double qDegreesToRadians(double degrees)
- \relates <QtMath>
- \since 5.1
-
- \brief The function converts the \a degrees in double to radians.
-
- The purpose of the function is to aid the conversion as such a convenient
- function is not part of the Standard Template Library, i.e. in <cmath> or
- elsewhere.
-
- Example:
-
- \snippet code/src_corelib_kernel_qmath.cpp 1
-
- \sa qRadiansToDegrees()
-*/
-
-/*!
- \fn float qRadiansToDegrees(float radians)
- \relates <QtMath>
- \since 5.1
-
- \brief The function converts the \a radians in float to degrees.
-
- The purpose of the function is to aid the conversion as such a convenient
- function is not part of the Standard Template Library, i.e. in <cmath> or
- elsewhere.
-
- Example:
-
- \snippet code/src_corelib_kernel_qmath.cpp 2
-
- \sa qDegreesToRadians()
-*/
-
-/*!
- \fn double qRadiansToDegrees(double radians)
- \relates <QtMath>
- \since 5.1
-
- \brief The function converts the \a radians in double to degrees.
-
- The purpose of the function is to aid the conversion as such a convenient
- function is not part of the Standard Template Library, i.e. in <cmath> or
- elsewhere.
-
- Example:
-
- \snippet code/src_corelib_kernel_qmath.cpp 3
-
- \sa qDegreesToRadians()
-*/
-
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qmath.qdoc b/src/corelib/kernel/qmath.qdoc
index 06d8db9277..04dbbb0a3b 100644
--- a/src/corelib/kernel/qmath.qdoc
+++ b/src/corelib/kernel/qmath.qdoc
@@ -26,10 +26,15 @@
****************************************************************************/
/*!
- \headerfile <QtCore/qmath.h>
- \title Math Functions
+ \headerfile <QtMath>
+ \title Generic Math Functions
\ingroup funclists
- \brief The <QtCore/qmath.h> header provides various math functions.
+
+ \brief The <QtMath> header file provides various math functions.
+
+ These functions are partly convenience definitions for basic math operations
+ not available in the C or Standard Template Libraries.
+
\pagekeywords math trigonometry qmath floor ceiling absolute sine cosine tangent inverse tan exponent power natural logarithm
*/
@@ -40,7 +45,7 @@
The ceiling is the smallest integer that is not less than \a v.
For example, if \a v is 41.2, then the ceiling is 42.
- \relates <QtCore/qmath.h>
+ \relates <QtMath>
\sa qFloor()
*/
@@ -51,7 +56,7 @@
The floor is the largest integer that is not greater than \a v.
For example, if \a v is 41.2, then the floor is 41.
- \relates <QtCore/qmath.h>
+ \relates <QtMath>
\sa qCeil()
*/
@@ -59,14 +64,14 @@
\fn qreal qFabs(qreal v)
Returns the absolute value of \a v as a qreal.
- \relates <QtCore/qmath.h>
+ \relates <QtMath>
*/
/*!
\fn qreal qSin(qreal v)
Returns the sine of the angle \a v in radians.
- \relates <QtCore/qmath.h>
+ \relates <QtMath>
\sa qCos(), qTan()
*/
@@ -74,7 +79,7 @@
\fn qreal qCos(qreal v)
Returns the cosine of an angle \a v in radians.
- \relates <QtCore/qmath.h>
+ \relates <QtMath>
\sa qSin(), qTan()
*/
@@ -82,7 +87,7 @@
\fn qreal qTan(qreal v)
Returns the tangent of an angle \a v in radians.
- \relates <QtCore/qmath.h>
+ \relates <QtMath>
\sa qSin(), qCos()
*/
@@ -91,7 +96,7 @@
Returns the arccosine of \a v as an angle in radians.
Arccosine is the inverse operation of cosine.
- \relates <QtCore/qmath.h>
+ \relates <QtMath>
\sa qAtan(), qAsin(), qCos()
*/
@@ -100,7 +105,7 @@
Returns the arcsine of \a v as an angle in radians.
Arcsine is the inverse operation of sine.
- \relates <QtCore/qmath.h>
+ \relates <QtMath>
\sa qSin(), qAtan(), qAcos()
*/
@@ -109,7 +114,7 @@
Returns the arctangent of \a v as an angle in radians.
Arctangent is the inverse operation of tangent.
- \relates <QtCore/qmath.h>
+ \relates <QtMath>
\sa qTan(), qAcos(), qAsin()
*/
@@ -118,7 +123,7 @@
Returns the arctangent of a point specified by the coordinates \a y and \a x.
This function will return the angle (argument) of that point.
- \relates <QtCore/qmath.h>
+ \relates <QtMath>
\sa qAtan()
*/
@@ -127,7 +132,7 @@
Returns the square root of \a v.
This function returns a NaN if \a v is a negative number.
- \relates <QtCore/qmath.h>
+ \relates <QtMath>
\sa qPow()
*/
@@ -135,7 +140,7 @@
\fn qreal qLn(qreal v)
Returns the natural logarithm of \a v. Natural logarithm uses base e.
- \relates <QtCore/qmath.h>
+ \relates <QtMath>
\sa qExp()
*/
@@ -143,7 +148,7 @@
\fn qreal qExp(qreal v)
Returns the exponential function of \c e to the power of \a v.
- \relates <QtCore/qmath.h>
+ \relates <QtMath>
\sa qLn()
*/
@@ -152,6 +157,62 @@
Returns the value of \a x raised to the power of \a y.
That is, \a x is the base and \a y is the exponent.
- \relates <QtCore/qmath.h>
+ \relates <QtMath>
\sa qSqrt()
*/
+
+/*!
+ \fn float qDegreesToRadians(float degrees)
+ \relates <QtMath>
+ \since 5.1
+
+ This function converts the \a degrees in float to radians.
+
+ Example:
+
+ \snippet code/src_corelib_kernel_qmath.cpp 0
+
+ \sa qRadiansToDegrees()
+*/
+
+/*!
+ \fn double qDegreesToRadians(double degrees)
+ \relates <QtMath>
+ \since 5.1
+
+ This function converts the \a degrees in double to radians.
+
+ Example:
+
+ \snippet code/src_corelib_kernel_qmath.cpp 1
+
+ \sa qRadiansToDegrees()
+*/
+
+/*!
+ \fn float qRadiansToDegrees(float radians)
+ \relates <QtMath>
+ \since 5.1
+
+ This function converts the \a radians in float to degrees.
+
+ Example:
+
+ \snippet code/src_corelib_kernel_qmath.cpp 2
+
+ \sa qDegreesToRadians()
+*/
+
+/*!
+ \fn double qRadiansToDegrees(double radians)
+ \relates <QtMath>
+ \since 5.1
+
+ This function converts the \a radians in double to degrees.
+
+ Example:
+
+ \snippet code/src_corelib_kernel_qmath.cpp 3
+
+ \sa qDegreesToRadians()
+*/
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 0184e9a9e7..c0773882f3 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -4071,18 +4071,21 @@ QDebug operator<<(QDebug dbg, const QObject *o) {
\macro Q_CLASSINFO(Name, Value)
\relates QObject
- This macro associates extra information to the class, which is
- available using QObject::metaObject(). Except for the ActiveQt
- extension, Qt doesn't use this information.
+ This macro associates extra information to the class, which is available
+ using QObject::metaObject(). Qt makes only limited use of this feature, in
+ the \l{Active Qt}, \l{Qt D-Bus} and \l{Qt QML} modules.
- The extra information takes the form of a \a Name string and a \a
- Value literal string.
+ The extra information takes the form of a \a Name string and a \a Value
+ literal string.
Example:
\snippet code/src_corelib_kernel_qobject.cpp 35
\sa QMetaObject::classInfo()
+ \sa QAxFactory
+ \sa {Using Qt D-Bus Adaptors}
+ \sa {Extending QML - Default Property Example}
*/
/*!
@@ -4441,6 +4444,8 @@ void qDeleteInEventHandler(QObject *o)
\snippet code/src_corelib_kernel_qobject.cpp 46
The connection will automatically disconnect if the sender is destroyed.
+ However, you should take care that any objects used within the functor
+ are still alive when the signal is emitted.
\note If the compiler does not support C++11 variadic templates, the number
of arguments in the signal or slot are limited to 6, and the functor object
@@ -4478,6 +4483,8 @@ void qDeleteInEventHandler(QObject *o)
The connection will automatically disconnect if the sender or the context
is destroyed.
+ However, you should take care that any objects used within the functor
+ are still alive when the signal is emitted.
\note If the compiler does not support C++11 variadic templates, the number
of arguments in the signal or slot are limited to 6, and the functor object
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index ee6ef23139..a54690606a 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -549,7 +549,7 @@ template <class T> inline const char * qobject_interface_iid()
Q_CORE_EXPORT QDebug operator<<(QDebug, const QObject *);
#endif
-class Q_CORE_EXPORT QSignalBlocker
+class QSignalBlocker
{
public:
inline explicit QSignalBlocker(QObject *o);
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index 843a6edce1..94c77302dd 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -465,6 +465,12 @@ QTranslator::~QTranslator()
\li \c /opt/foolib/foo.qm
\li \c /opt/foolib/foo
\endlist
+
+ Usually, it is better to use the QTranslator::load(const QLocale &,
+ const QString &, const QString &, const QString &, const QString &)
+ function instead, because it uses \l{QLocale::uiLanguages()} and not simply
+ the locale name, which refers to the formatting of dates and numbers and not
+ necessarily the UI language.
*/
bool QTranslator::load(const QString & filename, const QString & directory,
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index a12636778e..bdc3463b9f 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -63,6 +63,7 @@
#include <qt_windows.h>
#ifdef Q_OS_WINRT
+#include <qelapsedtimer.h>
#include <thread>
#endif
@@ -680,21 +681,11 @@ bool QThread::wait(unsigned long time)
break;
}
#else // !Q_OS_WINRT
- if (d->handle->joinable()) {
- HANDLE handle = d->handle->native_handle();
- switch (WaitForSingleObjectEx(handle, time, FALSE)) {
- case WAIT_OBJECT_0:
- ret = true;
- d->handle->join();
- break;
- case WAIT_FAILED:
- qErrnoWarning("QThread::wait: WaitForSingleObjectEx() failed");
- break;
- case WAIT_ABANDONED:
- case WAIT_TIMEOUT:
- default:
- break;
- }
+ if (!d->finished) {
+ QElapsedTimer timer;
+ timer.start();
+ while (timer.elapsed() < time && !d->finished)
+ yieldCurrentThread();
}
#endif // Q_OS_WINRT
diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp
index 45587b1214..2d744f97c0 100644
--- a/src/corelib/tools/qarraydata.cpp
+++ b/src/corelib/tools/qarraydata.cpp
@@ -75,10 +75,13 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment,
&& !(alignment & (alignment - 1)));
// Don't allocate empty headers
- if (!(options & RawData) && !capacity)
- return !(options & Unsharable)
- ? const_cast<QArrayData *>(&qt_array_empty)
- : const_cast<QArrayData *>(&qt_array_unsharable_empty);
+ if (!(options & RawData) && !capacity) {
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+ if (options & Unsharable)
+ return const_cast<QArrayData *>(&qt_array_unsharable_empty);
+#endif
+ return const_cast<QArrayData *>(&qt_array_empty);
+ }
size_t headerSize = sizeof(QArrayData);
@@ -118,8 +121,10 @@ void QArrayData::deallocate(QArrayData *data, size_t objectSize,
&& !(alignment & (alignment - 1)));
Q_UNUSED(objectSize) Q_UNUSED(alignment)
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
if (data == &qt_array_unsharable_empty)
return;
+#endif
Q_ASSERT_X(!data->ref.isStatic(), "QArrayData::deallocate", "Static data can not be deleted");
::free(data);
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h
index 534f310d36..5a8c46b582 100644
--- a/src/corelib/tools/qarraydata.h
+++ b/src/corelib/tools/qarraydata.h
@@ -80,7 +80,9 @@ struct Q_CORE_EXPORT QArrayData
enum AllocationOption {
CapacityReserved = 0x1,
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
Unsharable = 0x2,
+#endif
RawData = 0x4,
Grow = 0x8,
@@ -99,8 +101,10 @@ struct Q_CORE_EXPORT QArrayData
AllocationOptions detachFlags() const
{
AllocationOptions result;
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
if (!ref.isSharable())
result |= Unsharable;
+#endif
if (capacityReserved)
result |= CapacityReserved;
return result;
diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h
index 533f7a306f..2245106ec0 100644
--- a/src/corelib/tools/qarraydatapointer.h
+++ b/src/corelib/tools/qarraydatapointer.h
@@ -134,6 +134,7 @@ public:
return (!d->isMutable() || d->ref.isShared());
}
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
void setSharable(bool sharable)
{
if (needsDetach()) {
@@ -147,6 +148,9 @@ public:
}
}
+ bool isSharable() const { return d->isSharable(); }
+#endif
+
void swap(QArrayDataPointer &other)
{
qSwap(d, other.d);
diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h
index 88758bdd6d..9ef4ee91c6 100644
--- a/src/corelib/tools/qchar.h
+++ b/src/corelib/tools/qchar.h
@@ -358,6 +358,9 @@ public:
case QChar::Joining_Causing: return QChar::Center;
case QChar::Joining_Dual: return QChar::Dual;
case QChar::Joining_Right: return QChar::Right;
+ case QChar::Joining_None:
+ case QChar::Joining_Left:
+ case QChar::Joining_Transparent:
default: return QChar::OtherJoining;
}
}
diff --git a/src/corelib/tools/qcollator.cpp b/src/corelib/tools/qcollator.cpp
index 9c97d6b158..f7dfaa7d33 100644
--- a/src/corelib/tools/qcollator.cpp
+++ b/src/corelib/tools/qcollator.cpp
@@ -205,6 +205,11 @@ QLocale QCollator::locale() const
By default this mode is off.
+ \note On Windows, this functionality makes use of the \l{ICU} library. If Qt was
+ compiled without ICU support, it falls back to code using native Windows API,
+ which only works from Windows 7 onwards. On older versions of Windows, it will not work
+ and a warning will be emitted at runtime.
+
\sa numericMode()
*/
diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h
index d601ddb819..e05ef33aa2 100644
--- a/src/corelib/tools/qcontiguouscache.h
+++ b/src/corelib/tools/qcontiguouscache.h
@@ -104,7 +104,9 @@ public:
inline void detach() { if (d->ref.load() != 1) detach_helper(); }
inline bool isDetached() const { return d->ref.load() == 1; }
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; }
+#endif
QContiguousCache<T> &operator=(const QContiguousCache<T> &other);
#ifdef Q_COMPILER_RVALUE_REFS
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 67924c0888..1d76a2b3d1 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -326,7 +326,9 @@ public:
inline void detach() { if (d->ref.isShared()) detach_helper(); }
inline bool isDetached() const { return !d->ref.isShared(); }
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
inline void setSharable(bool sharable) { if (!sharable) detach(); if (d != &QHashData::shared_null) d->sharable = sharable; }
+#endif
inline bool isSharedWith(const QHash<Key, T> &other) const { return d == other.d; }
void clear();
diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h
index bdacdbcd26..3377d1bbc3 100644
--- a/src/corelib/tools/qlinkedlist.h
+++ b/src/corelib/tools/qlinkedlist.h
@@ -106,7 +106,9 @@ public:
inline void detach()
{ if (d->ref.isShared()) detach_helper2(this->e); }
inline bool isDetached() const { return !d->ref.isShared(); }
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
inline void setSharable(bool sharable) { if (!sharable) detach(); if (d != &QLinkedListData::shared_null) d->sharable = sharable; }
+#endif
inline bool isSharedWith(const QLinkedList<T> &other) const { return d == other.d; }
inline bool isEmpty() const { return d->size == 0; }
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 3a0d01aa8d..9e4ba70908 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -146,6 +146,7 @@ public:
}
inline bool isDetached() const { return !d->ref.isShared(); }
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
inline void setSharable(bool sharable)
{
if (sharable == d->ref.isSharable())
@@ -155,6 +156,7 @@ public:
if (d != &QListData::shared_null)
d->ref.setSharable(sharable);
}
+#endif
inline bool isSharedWith(const QList<T> &other) const { return d == other.d; }
inline bool isEmpty() const { return p.isEmpty(); }
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index 487039ccfb..76f8bd6f17 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -377,6 +377,7 @@ public:
inline void detach() { if (d->ref.isShared()) detach_helper(); }
inline bool isDetached() const { return !d->ref.isShared(); }
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
inline void setSharable(bool sharable)
{
if (sharable == d->ref.isSharable())
@@ -386,6 +387,7 @@ public:
// Don't call on shared_null
d->ref.setSharable(sharable);
}
+#endif
inline bool isSharedWith(const QMap<Key, T> &other) const { return d == other.d; }
void clear();
diff --git a/src/corelib/tools/qrefcount.h b/src/corelib/tools/qrefcount.h
index 84314b1fcc..3a8f0f3982 100644
--- a/src/corelib/tools/qrefcount.h
+++ b/src/corelib/tools/qrefcount.h
@@ -55,8 +55,10 @@ class RefCount
public:
inline bool ref() Q_DECL_NOTHROW {
int count = atomic.load();
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
if (count == 0) // !isSharable
return false;
+#endif
if (count != -1) // !isStatic
atomic.ref();
return true;
@@ -64,13 +66,16 @@ public:
inline bool deref() Q_DECL_NOTHROW {
int count = atomic.load();
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
if (count == 0) // !isSharable
return false;
+#endif
if (count == -1) // isStatic
return true;
return atomic.deref();
}
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
bool setSharable(bool sharable) Q_DECL_NOTHROW
{
Q_ASSERT(!isShared());
@@ -80,17 +85,18 @@ public:
return atomic.testAndSetRelaxed(1, 0);
}
- bool isStatic() const Q_DECL_NOTHROW
- {
- // Persistent object, never deleted
- return atomic.load() == -1;
- }
-
bool isSharable() const Q_DECL_NOTHROW
{
// Sharable === Shared ownership.
return atomic.load() != 0;
}
+#endif
+
+ bool isStatic() const Q_DECL_NOTHROW
+ {
+ // Persistent object, never deleted
+ return atomic.load() == -1;
+ }
bool isShared() const Q_DECL_NOTHROW
{
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index cadf2da019..fbcd271f1d 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -388,7 +388,7 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
Note: Quantifiers are normally "greedy". They always match as much
text as they can. For example, \b{0+} matches the first zero it
finds and all the consecutive zeros after the first zero. Applied
- to '20005', it matches'2\underline{000}5'. Quantifiers can be made
+ to '20005', it matches '2\underline{000}5'. Quantifiers can be made
non-greedy, see setMinimal().
\target capturing parentheses
@@ -678,7 +678,7 @@ int qFindString(const QChar *haystack, int haystackLen, int from,
QRegExp can match case insensitively using setCaseSensitivity(),
and can use non-greedy matching, see setMinimal(). By
default QRegExp uses full regexps but this can be changed with
- setWildcard(). Searching can be forward with indexIn() or backward
+ setPatternSyntax(). Searching can be done forward with indexIn() or backward
with lastIndexIn(). Captured text can be accessed using
capturedTexts() which returns a string list of all captured
strings, or using cap() which returns the captured string for the
diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h
index 291c8fe4f9..992243def6 100644
--- a/src/corelib/tools/qset.h
+++ b/src/corelib/tools/qset.h
@@ -91,7 +91,9 @@ public:
inline void detach() { q_hash.detach(); }
inline bool isDetached() const { return q_hash.isDetached(); }
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
inline void setSharable(bool sharable) { q_hash.setSharable(sharable); }
+#endif
inline void clear() { q_hash.clear(); }
diff --git a/src/corelib/tools/qsize.cpp b/src/corelib/tools/qsize.cpp
index da447157ff..03966ab1d6 100644
--- a/src/corelib/tools/qsize.cpp
+++ b/src/corelib/tools/qsize.cpp
@@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE
width and height can be swapped using the transpose() function.
The isValid() function determines if a size is valid (a valid size
- has both width and height greater than zero). The isEmpty()
+ has both width and height greater than or equal to zero). The isEmpty()
function returns \c true if either of the width and height is less
than, or equal to, zero, while the isNull() function returns \c true
only if both the width and the height is zero.
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 79365b11b1..aac9c493c3 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -4331,14 +4331,6 @@ QByteArray QString::toLocal8Bit_helper(const QChar *data, int size)
UTF-8 is a Unicode codec and can represent all characters in a Unicode
string like QString.
- However, in the Unicode range, there are certain codepoints that are not
- considered characters. The Unicode standard reserves the last two
- codepoints in each Unicode Plane (U+FFFE, U+FFFF, U+1FFFE, U+1FFFF,
- U+2FFFE, etc.), as well as 32 codepoints in the range U+FDD0..U+FDEF,
- inclusive, as non-characters. If any of those appear in the string, they
- may be discarded and will not appear in the UTF-8 representation, or they
- may be replaced by one or more replacement characters.
-
\sa fromUtf8(), toLatin1(), toLocal8Bit(), QTextCodec
*/
@@ -4493,10 +4485,10 @@ QString QString::fromLocal8Bit_helper(const char *str, int size)
sequences, non-characters, overlong sequences or surrogate codepoints
encoded into UTF-8.
- Non-characters are codepoints that the Unicode standard reserves and must
- not be used in text interchange. They are the last two codepoints in each
- Unicode Plane (U+FFFE, U+FFFF, U+1FFFE, U+1FFFF, U+2FFFE, etc.), as well
- as 32 codepoints in the range U+FDD0..U+FDEF, inclusive.
+ This function can be used to process incoming data incrementally as long as
+ all UTF-8 characters are terminated within the incoming data. Any
+ unterminated characters at the end of the string will be replaced or
+ suppressed. In order to do stateful decoding, please use \l QTextDecoder.
\sa toUtf8(), fromLatin1(), fromLocal8Bit()
*/
@@ -9517,14 +9509,6 @@ QByteArray QStringRef::toLocal8Bit() const
UTF-8 is a Unicode codec and can represent all characters in a Unicode
string like QString.
- However, in the Unicode range, there are certain codepoints that are not
- considered characters. The Unicode standard reserves the last two
- codepoints in each Unicode Plane (U+FFFE, U+FFFF, U+1FFFE, U+1FFFF,
- U+2FFFE, etc.), as well as 16 codepoints in the range U+FDD0..U+FDDF,
- inclusive, as non-characters. If any of those appear in the string, they
- may be discarded and will not appear in the UTF-8 representation, or they
- may be replaced by one or more replacement characters.
-
\sa toLatin1(), toLocal8Bit(), QTextCodec
*/
QByteArray QStringRef::toUtf8() const
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 2d9a42957e..359d0c49e5 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -954,6 +954,9 @@ public:
case QChar::Joining_Causing: return QChar::Center;
case QChar::Joining_Dual: return QChar::Dual;
case QChar::Joining_Right: return QChar::Right;
+ case QChar::Joining_None:
+ case QChar::Joining_Left:
+ case QChar::Joining_Transparent:
default: return QChar::OtherJoining;
}
}
diff --git a/src/corelib/tools/qtimezone.cpp b/src/corelib/tools/qtimezone.cpp
index b30caf4289..e17ff2b249 100644
--- a/src/corelib/tools/qtimezone.cpp
+++ b/src/corelib/tools/qtimezone.cpp
@@ -418,6 +418,13 @@ QTimeZone::~QTimeZone()
}
/*!
+ \fn QTimeZone::swap(QTimeZone &other)
+
+ Swaps this time zone instance with \a other. This function is very
+ fast and never fails.
+*/
+
+/*!
Assignment operator, assign \a other to this.
*/
diff --git a/src/corelib/tools/qunicodetools.cpp b/src/corelib/tools/qunicodetools.cpp
index fac795051a..fc36d07a4a 100644
--- a/src/corelib/tools/qunicodetools.cpp
+++ b/src/corelib/tools/qunicodetools.cpp
@@ -667,7 +667,7 @@ Q_CORE_EXPORT void initCharAttributes(const ushort *string, int length,
// ----------------------------------------------------------------------------
//
-// The Unicode script property. See http://www.unicode.org/reports/tr24/ (some very old version)
+// The Unicode script property. See http://www.unicode.org/reports/tr24/tr24-21.html
//
// ----------------------------------------------------------------------------
@@ -689,15 +689,36 @@ Q_CORE_EXPORT void initScripts(const ushort *string, int length, uchar *scripts)
const QUnicodeTables::Properties *prop = QUnicodeTables::properties(ucs4);
- if (Q_LIKELY(prop->script == script || prop->script == QChar::Script_Inherited))
+ if (Q_LIKELY(prop->script == script || prop->script <= QChar::Script_Inherited))
continue;
// Never break between a combining mark (gc= Mc, Mn or Me) and its base character.
// Thus, a combining mark — whatever its script property value is — should inherit
// the script property value of its base character.
static const int test = (FLAG(QChar::Mark_NonSpacing) | FLAG(QChar::Mark_SpacingCombining) | FLAG(QChar::Mark_Enclosing));
- if (Q_UNLIKELY(FLAG(prop->category) & test))
- continue;
+ if (Q_UNLIKELY(FLAG(prop->category) & test)) {
+ // In cases where the base character itself has the Common script property value,
+ // and it is followed by one or more combining marks with a specific script property value,
+ // it may be even better for processing to let the base acquire the script property value
+ // from the first mark. This approach can be generalized by treating all the characters
+ // of a combining character sequence as having the script property value
+ // of the first non-Inherited, non-Common character in the sequence if there is one,
+ // and otherwise treating all the characters as having the Common script property value.
+ if (Q_LIKELY(script > QChar::Script_Common || prop->script <= QChar::Script_Common))
+ continue;
+
+ script = QChar::Script(prop->script);
+ }
+
+ if (Q_LIKELY(script != QChar::Script_Common)) {
+ // override preceding Common-s
+ while (sor > 0 && scripts[sor - 1] == QChar::Script_Common)
+ --sor;
+ } else {
+ // see if we are inheriting preceding run
+ if (sor > 0)
+ script = scripts[sor - 1];
+ }
while (sor < eor)
scripts[sor++] = script;
@@ -705,6 +726,15 @@ Q_CORE_EXPORT void initScripts(const ushort *string, int length, uchar *scripts)
script = prop->script;
}
eor = length;
+ if (Q_LIKELY(script != QChar::Script_Common)) {
+ // override preceding Common-s
+ while (sor > 0 && scripts[sor - 1] == QChar::Script_Common)
+ --sor;
+ } else {
+ // see if we are inheriting preceding run
+ if (sor > 0)
+ script = scripts[sor - 1];
+ }
while (sor < eor)
scripts[sor++] = script;
}
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 22031645dc..0a32c96958 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -107,6 +107,7 @@ public:
inline void detach();
inline bool isDetached() const { return !d->ref.isShared(); }
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
inline void setSharable(bool sharable)
{
if (sharable == d->ref.isSharable())
@@ -122,6 +123,7 @@ public:
}
Q_ASSERT(d->ref.isSharable() == sharable);
}
+#endif
inline bool isSharedWith(const QVector<T> &other) const { return d == other.d; }
@@ -348,10 +350,12 @@ template <typename T>
void QVector<T>::detach()
{
if (!isDetached()) {
- if (d->alloc)
- reallocData(d->size, int(d->alloc));
- else
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+ if (!d->alloc)
d = Data::unsharableEmpty();
+ else
+#endif
+ reallocData(d->size, int(d->alloc));
}
Q_ASSERT(isDetached());
}
@@ -503,7 +507,9 @@ void QVector<T>::reallocData(const int asize, const int aalloc, QArrayData::Allo
x = Data::allocate(aalloc, options);
Q_CHECK_PTR(x);
// aalloc is bigger then 0 so it is not [un]sharedEmpty
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
Q_ASSERT(x->ref.isSharable() || options.testFlag(QArrayData::Unsharable));
+#endif
Q_ASSERT(!x->ref.isStatic());
x->size = asize;
@@ -569,7 +575,9 @@ void QVector<T>::reallocData(const int asize, const int aalloc, QArrayData::Allo
Q_ASSERT(d->data());
Q_ASSERT(uint(d->size) <= d->alloc);
+#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
Q_ASSERT(d != Data::unsharableEmpty());
+#endif
Q_ASSERT(aalloc ? d != Data::sharedNull() : d == Data::sharedNull());
Q_ASSERT(d->alloc >= uint(aalloc));
Q_ASSERT(d->size == asize);
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index 863cf03439..57a9591060 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -163,10 +163,10 @@ contains(QT_CONFIG,icu) {
LIBS_PRIVATE += -lsicuin -lsicuuc -lsicudt
}
} else {
- LIBS_PRIVATE += -licuin -licuuc
+ LIBS_PRIVATE += -licuin -licuuc -licudt
}
} else {
- LIBS_PRIVATE += -licui18n -licuuc
+ LIBS_PRIVATE += -licui18n -licuuc -licudata
}
} else: win32 {
SOURCES += tools/qcollator_win.cpp