summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-03-18 15:23:56 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2015-03-18 22:27:24 +0000
commitdcf0ececbf167502ac9943c6435bb9ddeeb29d5e (patch)
tree19416d427b84f0a90e0d3028588404a544003734 /src/corelib
parent7aad6b9fd426e05fdfb3892d60432a45e4079887 (diff)
parent198606f6dbca95ba3a170fff387327d8271018cd (diff)
Merge "Merge remote-tracking branch 'origin/5.5' into dev" into refs/staging/dev
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/Qt5CoreMacros.cmake2
-rw-r--r--src/corelib/doc/qtcore.qdocconf3
-rw-r--r--src/corelib/doc/src/datastreamformat.qdoc14
-rw-r--r--src/corelib/global/qcompilerdetection.h1
-rw-r--r--src/corelib/global/qglobal.h2
-rw-r--r--src/corelib/global/qlibraryinfo.cpp65
-rw-r--r--src/corelib/io/forkfd_qt.cpp9
-rw-r--r--src/corelib/io/qiodevice.cpp76
-rw-r--r--src/corelib/json/qjsonarray.cpp1
-rw-r--r--src/corelib/json/qjsondocument.cpp1
-rw-r--r--src/corelib/json/qjsonobject.cpp1
-rw-r--r--src/corelib/json/qjsonparser.cpp1
-rw-r--r--src/corelib/json/qjsonparser_p.h6
-rw-r--r--src/corelib/json/qjsonvalue.cpp1
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp21
-rw-r--r--src/corelib/kernel/qvariant.cpp2
-rw-r--r--src/corelib/kernel/qvariant.h2
-rw-r--r--src/corelib/plugin/qplugin.qdoc2
-rw-r--r--src/corelib/thread/qthread.cpp14
-rw-r--r--src/corelib/thread/qthread.h1
-rw-r--r--src/corelib/tools/qdatetime.cpp115
-rw-r--r--src/corelib/tools/qstring.cpp18
-rw-r--r--src/corelib/tools/qstringalgorithms_p.h10
23 files changed, 209 insertions, 159 deletions
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake
index 95102be108..a94caf0d25 100644
--- a/src/corelib/Qt5CoreMacros.cmake
+++ b/src/corelib/Qt5CoreMacros.cmake
@@ -269,7 +269,7 @@ function(QT5_ADD_RESOURCES outfiles )
set(rcc_files ${_RCC_UNPARSED_ARGUMENTS})
set(rcc_options ${_RCC_OPTIONS})
- if(${rcc_options} MATCHES "-binary")
+ if("${rcc_options}" MATCHES "-binary")
message(WARNING "Use qt5_add_binary_resources for binary option")
endif()
diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf
index f3aff83a8b..df1ee4afea 100644
--- a/src/corelib/doc/qtcore.qdocconf
+++ b/src/corelib/doc/qtcore.qdocconf
@@ -36,7 +36,8 @@ exampledirs += \
../ \
snippets \
../../../examples/corelib \
- ../../../examples/network/dnslookup
+ ../../../examples/network/dnslookup \
+ ../../../examples/widgets/tools
imagedirs += images
diff --git a/src/corelib/doc/src/datastreamformat.qdoc b/src/corelib/doc/src/datastreamformat.qdoc
index c76cc1a95e..8ebc64ca85 100644
--- a/src/corelib/doc/src/datastreamformat.qdoc
+++ b/src/corelib/doc/src/datastreamformat.qdoc
@@ -129,7 +129,9 @@
\li \list
\li Date (QDate)
\li Time (QTime)
- \li The \l{Qt::TimeSpec}{time spec} (quint8)
+ \li The \l{Qt::TimeSpec}{time spec}
+ offsetFromUtc (qint32) if Qt::TimeSpec is offsetFromUtc
+ TimeZone(QTimeZone) if Qt::TimeSpec is TimeZone
\endlist
\row \li QEasingCurve
\li \list
@@ -145,11 +147,19 @@
\row \li QFont
\li \list
\li The family (QString)
- \li The point size (qint16)
+ \li The style name (QString)
+ \li The point size (double)
+ \li The pixel size (qint32)
\li The style hint (quint8)
+ \li The style strategy (quint16)
\li The char set (quint8)
\li The weight (quint8)
\li The font bits (quint8)
+ \li The font stretch (quint16)
+ \li The extended font bits (quint8)
+ \li The letter spacing (double)
+ \li The word spacing (double)
+ \li The hinting preference (quint8)
\endlist
\row \li QHash<Key, T>
\li \list
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 0ca67df1e2..1774378c06 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -1164,7 +1164,6 @@
const bool valueOfExpression = Expr;\
Q_ASSERT_X(valueOfExpression, "Q_ASSUME()", "Assumption in Q_ASSUME(\"" #Expr "\") was not correct");\
Q_ASSUME_IMPL(valueOfExpression);\
- Q_UNUSED(valueOfExpression); /* the value may not be used if Q_ASSERT_X and Q_ASSUME_IMPL are noop */\
} while (0)
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 6aa3eb305b..c4e2f7609c 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -681,7 +681,7 @@ Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *
#if !defined(Q_ASSERT_X)
# if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
-# define Q_ASSERT_X(cond, where, what) qt_noop()
+# define Q_ASSERT_X(cond, where, what) do { } while ((false) && (cond))
# else
# define Q_ASSERT_X(cond, where, what) ((!(cond)) ? qt_assert_x(where, what,__FILE__,__LINE__) : qt_noop())
# endif
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 322fc2f651..5db2e94602 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -63,12 +63,16 @@ extern void qDumpCPUFeatures(); // in qsimd.cpp
struct QLibrarySettings
{
QLibrarySettings();
+ void load();
+
QScopedPointer<QSettings> settings;
#ifdef QT_BUILD_QMAKE
bool haveDevicePaths;
bool haveEffectiveSourcePaths;
bool haveEffectivePaths;
bool havePaths;
+#else
+ bool reloadOnQAppAvailable;
#endif
};
Q_GLOBAL_STATIC(QLibrarySettings, qt_library_settings)
@@ -93,16 +97,31 @@ public:
static QSettings *configuration()
{
QLibrarySettings *ls = qt_library_settings();
- return ls ? ls->settings.data() : 0;
+ if (ls) {
+#ifndef QT_BUILD_QMAKE
+ if (ls->reloadOnQAppAvailable && QCoreApplication::instance() != 0)
+ ls->load();
+#endif
+ return ls->settings.data();
+ } else {
+ return 0;
+ }
}
};
static const char platformsSection[] = "Platforms";
QLibrarySettings::QLibrarySettings()
- : settings(QLibraryInfoPrivate::findConfiguration())
{
+ load();
+}
+
+void QLibrarySettings::load()
+{
+ // If we get any settings here, those won't change when the application shows up.
+ settings.reset(QLibraryInfoPrivate::findConfiguration());
#ifndef QT_BUILD_QMAKE
+ reloadOnQAppAvailable = (settings.data() == 0 && QCoreApplication::instance() == 0);
bool haveDevicePaths;
bool haveEffectivePaths;
bool havePaths;
@@ -139,33 +158,35 @@ QLibrarySettings::QLibrarySettings()
QSettings *QLibraryInfoPrivate::findConfiguration()
{
QString qtconfig = QStringLiteral(":/qt/etc/qt.conf");
+ if (QFile::exists(qtconfig))
+ return new QSettings(qtconfig, QSettings::IniFormat);
#ifdef QT_BUILD_QMAKE
- if(!QFile::exists(qtconfig))
- qtconfig = qmake_libraryInfoFile();
+ qtconfig = qmake_libraryInfoFile();
+ if (QFile::exists(qtconfig))
+ return new QSettings(qtconfig, QSettings::IniFormat);
#else
- if (!QFile::exists(qtconfig) && QCoreApplication::instance()) {
#ifdef Q_OS_MAC
- CFBundleRef bundleRef = CFBundleGetMainBundle();
- if (bundleRef) {
- QCFType<CFURLRef> urlRef = CFBundleCopyResourceURL(bundleRef,
- QCFString(QLatin1String("qt.conf")),
- 0,
- 0);
- if (urlRef) {
- QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle);
- qtconfig = QDir::cleanPath(path);
- }
+ CFBundleRef bundleRef = CFBundleGetMainBundle();
+ if (bundleRef) {
+ QCFType<CFURLRef> urlRef = CFBundleCopyResourceURL(bundleRef,
+ QCFString(QLatin1String("qt.conf")),
+ 0,
+ 0);
+ if (urlRef) {
+ QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle);
+ qtconfig = QDir::cleanPath(path);
+ if (QFile::exists(qtconfig))
+ return new QSettings(qtconfig, QSettings::IniFormat);
}
- if (qtconfig.isEmpty())
+ }
#endif
- {
- QDir pwd(QCoreApplication::applicationDirPath());
- qtconfig = pwd.filePath(QLatin1String("qt.conf"));
- }
+ if (QCoreApplication::instance()) {
+ QDir pwd(QCoreApplication::applicationDirPath());
+ qtconfig = pwd.filePath(QLatin1String("qt.conf"));
+ if (QFile::exists(qtconfig))
+ return new QSettings(qtconfig, QSettings::IniFormat);
}
#endif
- if (QFile::exists(qtconfig))
- return new QSettings(qtconfig, QSettings::IniFormat);
return 0; //no luck
}
diff --git a/src/corelib/io/forkfd_qt.cpp b/src/corelib/io/forkfd_qt.cpp
index 56a39f8df0..6704ec6f2a 100644
--- a/src/corelib/io/forkfd_qt.cpp
+++ b/src/corelib/io/forkfd_qt.cpp
@@ -36,10 +36,17 @@
# define _POSIX_C_SOURCE 200809L
#endif
#if !defined(_XOPEN_SOURCE) && !defined(__QNXNTO__) && !defined(ANDROID)
-# define _XOPEN_SOURCE 500
+# define _XOPEN_SOURCE 700
#endif
#include <QtCore/qatomic.h>
+#include "qprocess_p.h"
+
+#ifdef QPROCESS_USE_SPAWN
+# define FORKFD_NO_FORKFD
+#else
+# define FORKFD_NO_SPAWNFD
+#endif
#if defined(QT_NO_DEBUG) && !defined(NDEBUG)
# define NDEBUG
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index ea7e7b2731..7eb917c71f 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -586,7 +586,7 @@ qint64 QIODevice::pos() const
{
Q_D(const QIODevice);
#if defined QIODEVICE_DEBUG
- printf("%p QIODevice::pos() == %d\n", this, int(d->pos));
+ printf("%p QIODevice::pos() == %lld\n", this, d->pos);
#endif
return d->pos;
}
@@ -629,31 +629,30 @@ bool QIODevice::seek(qint64 pos)
return false;
}
if (pos < 0) {
- qWarning("QIODevice::seek: Invalid pos: %d", int(pos));
+ qWarning("QIODevice::seek: Invalid pos: %lld", pos);
return false;
}
#if defined QIODEVICE_DEBUG
- printf("%p QIODevice::seek(%d), before: d->pos = %d, d->buffer.size() = %d\n",
- this, int(pos), int(d->pos), d->buffer.size());
+ printf("%p QIODevice::seek(%lld), before: d->pos = %lld, d->buffer.size() = %lld\n",
+ this, pos, d->pos, d->buffer.size());
#endif
qint64 offset = pos - d->pos;
d->pos = pos;
d->devicePos = pos;
- if (offset < 0
- || offset >= qint64(d->buffer.size()))
+ if (offset < 0 || offset >= d->buffer.size())
// When seeking backwards, an operation that is only allowed for
// random-access devices, the buffer is cleared. The next read
// operation will then refill the buffer. We can optimize this, if we
// find that seeking backwards becomes a significant performance hit.
d->buffer.clear();
else if (!d->buffer.isEmpty())
- d->buffer.skip(int(offset));
+ d->buffer.skip(offset);
#if defined QIODEVICE_DEBUG
- printf("%p \tafter: d->pos == %d, d->buffer.size() == %d\n", this, int(d->pos),
+ printf("%p \tafter: d->pos == %lld, d->buffer.size() == %lld\n", this, d->pos,
d->buffer.size());
#endif
return true;
@@ -675,8 +674,9 @@ bool QIODevice::atEnd() const
{
Q_D(const QIODevice);
#if defined QIODEVICE_DEBUG
- printf("%p QIODevice::atEnd() returns %s, d->openMode == %d, d->pos == %d\n", this, (d->openMode == NotOpen || d->pos == size()) ? "true" : "false",
- int(d->openMode), int(d->pos));
+ printf("%p QIODevice::atEnd() returns %s, d->openMode == %d, d->pos == %lld\n", this,
+ (d->openMode == NotOpen || d->pos == size()) ? "true" : "false", int(d->openMode),
+ d->pos);
#endif
return d->openMode == NotOpen || (d->buffer.isEmpty() && bytesAvailable() == 0);
}
@@ -749,8 +749,8 @@ qint64 QIODevice::read(char *data, qint64 maxSize)
Q_D(QIODevice);
#if defined QIODEVICE_DEBUG
- printf("%p QIODevice::read(%p, %d), d->pos = %d, d->buffer.size() = %d\n",
- this, data, int(maxSize), int(d->pos), int(d->buffer.size()));
+ printf("%p QIODevice::read(%p, %lld), d->pos = %lld, d->buffer.size() = %lld\n",
+ this, data, maxSize, d->pos, d->buffer.size());
#endif
const bool sequential = d->isSequential();
@@ -791,8 +791,8 @@ qint64 QIODevice::read(char *data, qint64 maxSize)
data += bufferReadChunkSize;
maxSize -= bufferReadChunkSize;
#if defined QIODEVICE_DEBUG
- printf("%p \treading %d bytes from buffer into position %d\n", this,
- bufferReadChunkSize, int(readSoFar) - bufferReadChunkSize);
+ printf("%p \treading %lld bytes from buffer into position %lld\n", this,
+ bufferReadChunkSize, readSoFar - bufferReadChunkSize);
#endif
} else {
if (d->firstRead) {
@@ -813,8 +813,8 @@ qint64 QIODevice::read(char *data, qint64 maxSize)
readFromDevice = readData(data, maxSize);
deviceAtEof = (readFromDevice != maxSize);
#if defined QIODEVICE_DEBUG
- printf("%p \treading %d bytes from device (total %d)\n", this,
- int(readFromDevice), int(readSoFar));
+ printf("%p \treading %lld bytes from device (total %lld)\n", this,
+ readFromDevice, readSoFar);
#endif
if (readFromDevice > 0) {
readSoFar += readFromDevice;
@@ -826,17 +826,17 @@ qint64 QIODevice::read(char *data, qint64 maxSize)
}
}
} else {
- const int bytesToBuffer = QIODEVICE_BUFFERSIZE;
+ const qint64 bytesToBuffer = QIODEVICE_BUFFERSIZE;
// Try to fill QIODevice buffer by single read
readFromDevice = readData(d->buffer.reserve(bytesToBuffer), bytesToBuffer);
deviceAtEof = (readFromDevice != bytesToBuffer);
- d->buffer.chop(bytesToBuffer - qMax(0, int(readFromDevice)));
+ d->buffer.chop(bytesToBuffer - qMax(Q_INT64_C(0), readFromDevice));
if (readFromDevice > 0) {
if (!sequential)
d->devicePos += readFromDevice;
#if defined QIODEVICE_DEBUG
- printf("%p \treading %d from device into buffer\n", this,
- int(readFromDevice));
+ printf("%p \treading %lld from device into buffer\n", this,
+ readFromDevice);
#endif
continue;
}
@@ -884,8 +884,8 @@ qint64 QIODevice::read(char *data, qint64 maxSize)
}
#if defined QIODEVICE_DEBUG
- printf("%p \treturning %d, d->pos == %d, d->buffer.size() == %d\n", this,
- int(readSoFar), int(d->pos), d->buffer.size());
+ printf("%p \treturning %lld, d->pos == %lld, d->buffer.size() == %lld\n", this,
+ readSoFar, d->pos, d->buffer.size());
debugBinaryString(data - readSoFar, readSoFar);
#endif
@@ -916,8 +916,8 @@ QByteArray QIODevice::read(qint64 maxSize)
CHECK_MAXLEN(read, result);
#if defined QIODEVICE_DEBUG
- printf("%p QIODevice::read(%d), d->pos = %d, d->buffer.size() = %d\n",
- this, int(maxSize), int(d->pos), int(d->buffer.size()));
+ printf("%p QIODevice::read(%lld), d->pos = %lld, d->buffer.size() = %lld\n",
+ this, maxSize, d->pos, d->buffer.size());
#else
Q_UNUSED(d);
#endif
@@ -966,8 +966,8 @@ QByteArray QIODevice::readAll()
{
Q_D(QIODevice);
#if defined QIODEVICE_DEBUG
- printf("%p QIODevice::readAll(), d->pos = %d, d->buffer.size() = %d\n",
- this, int(d->pos), int(d->buffer.size()));
+ printf("%p QIODevice::readAll(), d->pos = %lld, d->buffer.size() = %lld\n",
+ this, d->pos, d->buffer.size());
#endif
QByteArray result;
@@ -1054,8 +1054,8 @@ qint64 QIODevice::readLine(char *data, qint64 maxSize)
}
#if defined QIODEVICE_DEBUG
- printf("%p QIODevice::readLine(%p, %d), d->pos = %d, d->buffer.size() = %d\n",
- this, data, int(maxSize), int(d->pos), int(d->buffer.size()));
+ printf("%p QIODevice::readLine(%p, %lld), d->pos = %lld, d->buffer.size() = %lld\n",
+ this, data, maxSize, d->pos, d->buffer.size());
#endif
// Leave room for a '\0'
@@ -1071,8 +1071,8 @@ qint64 QIODevice::readLine(char *data, qint64 maxSize)
if (!sequential)
d->pos += readSoFar;
#if defined QIODEVICE_DEBUG
- printf("%p \tread from buffer: %d bytes, last character read: %hhx\n", this,
- int(readSoFar), data[int(readSoFar) - 1]);
+ printf("%p \tread from buffer: %lld bytes, last character read: %hhx\n", this,
+ readSoFar, data[readSoFar - 1]);
if (readSoFar)
debugBinaryString(data, int(readSoFar));
#endif
@@ -1094,8 +1094,8 @@ qint64 QIODevice::readLine(char *data, qint64 maxSize)
d->baseReadLineDataCalled = false;
qint64 readBytes = readLineData(data + readSoFar, maxSize - readSoFar);
#if defined QIODEVICE_DEBUG
- printf("%p \tread from readLineData: %d bytes, readSoFar = %d bytes\n", this,
- int(readBytes), int(readSoFar));
+ printf("%p \tread from readLineData: %lld bytes, readSoFar = %lld bytes\n", this,
+ readBytes, readSoFar);
if (readBytes > 0) {
debugBinaryString(data, int(readSoFar + readBytes));
}
@@ -1122,8 +1122,8 @@ qint64 QIODevice::readLine(char *data, qint64 maxSize)
}
#if defined QIODEVICE_DEBUG
- printf("%p \treturning %d, d->pos = %d, d->buffer.size() = %d, size() = %d\n",
- this, int(readSoFar), int(d->pos), d->buffer.size(), int(size()));
+ printf("%p \treturning %lld, d->pos = %lld, d->buffer.size() = %lld, size() = %lld\n",
+ this, readSoFar, d->pos, d->buffer.size(), size());
debugBinaryString(data, int(readSoFar));
#endif
return readSoFar;
@@ -1147,8 +1147,8 @@ QByteArray QIODevice::readLine(qint64 maxSize)
CHECK_MAXLEN(readLine, result);
#if defined QIODEVICE_DEBUG
- printf("%p QIODevice::readLine(%d), d->pos = %d, d->buffer.size() = %d\n",
- this, int(maxSize), int(d->pos), int(d->buffer.size()));
+ printf("%p QIODevice::readLine(%lld), d->pos = %lld, d->buffer.size() = %lld\n",
+ this, maxSize, d->pos, d->buffer.size());
#else
Q_UNUSED(d);
#endif
@@ -1220,8 +1220,8 @@ qint64 QIODevice::readLineData(char *data, qint64 maxSize)
}
#if defined QIODEVICE_DEBUG
- printf("%p QIODevice::readLineData(%p, %d), d->pos = %d, d->buffer.size() = %d, returns %d\n",
- this, data, int(maxSize), int(d->pos), int(d->buffer.size()), int(readSoFar));
+ printf("%p QIODevice::readLineData(%p, %lld), d->pos = %lld, d->buffer.size() = %lld, "
+ "returns %lld\n", this, data, maxSize, d->pos, d->buffer.size(), readSoFar);
#endif
if (lastReadReturn != 1 && readSoFar == 0)
return isSequential() ? lastReadReturn : -1;
diff --git a/src/corelib/json/qjsonarray.cpp b/src/corelib/json/qjsonarray.cpp
index a993fd6ea4..77a3d0a2b8 100644
--- a/src/corelib/json/qjsonarray.cpp
+++ b/src/corelib/json/qjsonarray.cpp
@@ -47,6 +47,7 @@ QT_BEGIN_NAMESPACE
\class QJsonArray
\inmodule QtCore
\ingroup json
+ \ingroup shared
\reentrant
\since 5.0
diff --git a/src/corelib/json/qjsondocument.cpp b/src/corelib/json/qjsondocument.cpp
index 7014c146d5..f5bad32233 100644
--- a/src/corelib/json/qjsondocument.cpp
+++ b/src/corelib/json/qjsondocument.cpp
@@ -47,6 +47,7 @@ QT_BEGIN_NAMESPACE
/*! \class QJsonDocument
\inmodule QtCore
\ingroup json
+ \ingroup shared
\reentrant
\since 5.0
diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp
index 22bad6f8a2..ae44cd9ff9 100644
--- a/src/corelib/json/qjsonobject.cpp
+++ b/src/corelib/json/qjsonobject.cpp
@@ -46,6 +46,7 @@ QT_BEGIN_NAMESPACE
\class QJsonObject
\inmodule QtCore
\ingroup json
+ \ingroup shared
\reentrant
\since 5.0
diff --git a/src/corelib/json/qjsonparser.cpp b/src/corelib/json/qjsonparser.cpp
index 371a191d3f..0d62687388 100644
--- a/src/corelib/json/qjsonparser.cpp
+++ b/src/corelib/json/qjsonparser.cpp
@@ -77,6 +77,7 @@ QT_BEGIN_NAMESPACE
\class QJsonParseError
\inmodule QtCore
\ingroup json
+ \ingroup shared
\reentrant
\since 5.0
diff --git a/src/corelib/json/qjsonparser_p.h b/src/corelib/json/qjsonparser_p.h
index 98b23dc9c5..a395c0c92e 100644
--- a/src/corelib/json/qjsonparser_p.h
+++ b/src/corelib/json/qjsonparser_p.h
@@ -62,12 +62,14 @@ public:
class ParsedObject
{
public:
- ParsedObject(Parser *p, int pos) : parser(p), objectPosition(pos) {}
+ ParsedObject(Parser *p, int pos) : parser(p), objectPosition(pos) {
+ offsets.reserve(64);
+ }
void insert(uint offset);
Parser *parser;
int objectPosition;
- QVarLengthArray<uint, 64> offsets;
+ QVector<uint> offsets;
inline QJsonPrivate::Entry *entryAt(int i) const {
return reinterpret_cast<QJsonPrivate::Entry *>(parser->data + objectPosition + offsets[i]);
diff --git a/src/corelib/json/qjsonvalue.cpp b/src/corelib/json/qjsonvalue.cpp
index 4845d8c876..c8ddfbc2cc 100644
--- a/src/corelib/json/qjsonvalue.cpp
+++ b/src/corelib/json/qjsonvalue.cpp
@@ -46,6 +46,7 @@ QT_BEGIN_NAMESPACE
\class QJsonValue
\inmodule QtCore
\ingroup json
+ \ingroup shared
\reentrant
\since 5.0
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 0bde57c8b3..dbffa83cee 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -2420,16 +2420,27 @@ Q_GLOBAL_STATIC_WITH_ARGS(QMutex, libraryPathMutex, (QMutex::Recursive))
Returns a list of paths that the application will search when
dynamically loading libraries.
+ The return value of this function may change when a QCoreApplication
+ is created. It is not recommended to call it before creating a
+ QCoreApplication. The directory of the application executable (\b not
+ the working directory) is part of the list if it is known. In order
+ to make it known a QCoreApplication has to be constructed as it will
+ use \c {argv[0]} to find it.
+
Qt provides default library paths, but they can also be set using
a \l{Using qt.conf}{qt.conf} file. Paths specified in this file
- will override default values.
+ will override default values. Note that if the qt.conf file is in
+ the directory of the application executable, it may not be found
+ until a QCoreApplication is created. If it is not found when calling
+ this function, the default library paths will be used.
- This list will include the installation directory for plugins if
+ The list will include the installation directory for plugins if
it exists (the default installation directory for plugins is \c
INSTALL/plugins, where \c INSTALL is the directory where Qt was
- installed). The directory of the application executable (NOT the
- working directory) is always added, as well as the colon separated
- entries of the \c QT_PLUGIN_PATH environment variable.
+ installed). The colon separated entries of the \c QT_PLUGIN_PATH
+ environment variable are always added. The plugin installation
+ directory (and its existence) may change when the directory of
+ the application executable becomes known.
If you want to iterate over the list, you can use the \l foreach
pseudo-keyword:
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 9ae6c779c0..f7a4abbf68 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -2536,7 +2536,7 @@ QModelIndex QVariant::toModelIndex() const
\sa canConvert(), convert(), toModelIndex()
*/
-QModelIndex QVariant::toPersistentModelIndex() const
+QPersistentModelIndex QVariant::toPersistentModelIndex() const
{
return qVariantToHelper<QPersistentModelIndex>(d, handlerManager);
}
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index d9eca94391..58dfc3aab0 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -320,7 +320,7 @@ class Q_CORE_EXPORT QVariant
QEasingCurve toEasingCurve() const;
QUuid toUuid() const;
QModelIndex toModelIndex() const;
- QModelIndex toPersistentModelIndex() const;
+ QPersistentModelIndex toPersistentModelIndex() const;
QJsonValue toJsonValue() const;
QJsonObject toJsonObject() const;
QJsonArray toJsonArray() const;
diff --git a/src/corelib/plugin/qplugin.qdoc b/src/corelib/plugin/qplugin.qdoc
index 81be1df518..94f5bc8a30 100644
--- a/src/corelib/plugin/qplugin.qdoc
+++ b/src/corelib/plugin/qplugin.qdoc
@@ -44,7 +44,7 @@
to the interface class called \a ClassName. The \a Identifier must
be unique. For example:
- \snippet code/doc_src_qplugin.cpp 0
+ \snippet plugandpaint/interfaces.h 3
This macro is normally used right after the class definition for
\a ClassName, in a header file. See the
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index f119828e8e..dc231a00f8 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -711,6 +711,20 @@ QThread::Priority QThread::priority() const
\sa terminate()
*/
+/*!
+ \since 5.5
+ Returns the current event loop level for the thread.
+
+ \note This can only be called within the thread itself, i.e. when
+ it is the current thread.
+*/
+
+int QThread::loopLevel() const
+{
+ Q_D(const QThread);
+ return d->data->eventLoops.size();
+}
+
#else // QT_NO_THREAD
QThread::QThread(QObject *parent)
diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h
index 72d8f5a5f8..58755b9625 100644
--- a/src/corelib/thread/qthread.h
+++ b/src/corelib/thread/qthread.h
@@ -90,6 +90,7 @@ public:
void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher);
bool event(QEvent *event) Q_DECL_OVERRIDE;
+ int loopLevel() const;
public Q_SLOTS:
void start(Priority = InheritPriority);
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index e5fbf5af5e..505a6f863b 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -560,22 +560,6 @@ int QDate::daysInYear() const
January 2000 has week number 52 in the year 1999, and 31 December
2002 has week number 1 in the year 2003.
- \legalese
- Copyright (c) 1989 The Regents of the University of California.
- All rights reserved.
-
- Redistribution and use in source and binary forms are permitted
- provided that the above copyright notice and this paragraph are
- duplicated in all such forms and that any documentation,
- advertising materials, and other materials related to such
- distribution and use acknowledge that the software was developed
- by the University of California, Berkeley. The name of the
- University may not be used to endorse or promote products derived
- from this software without specific prior written permission.
- THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-
\sa isValid()
*/
@@ -585,46 +569,29 @@ int QDate::weekNumber(int *yearNumber) const
return 0;
int year = QDate::year();
- int yday = dayOfYear() - 1;
+ int yday = dayOfYear();
int wday = dayOfWeek();
- if (wday == 7)
- wday = 0;
- int w;
-
- for (;;) {
- int len;
- int bot;
- int top;
-
- len = isLeapYear(year) ? 366 : 365;
- /*
- ** What yday (-3 ... 3) does
- ** the ISO year begin on?
- */
- bot = ((yday + 11 - wday) % 7) - 3;
- /*
- ** What yday does the NEXT
- ** ISO year begin on?
- */
- top = bot - (len % 7);
- if (top < -3)
- top += 7;
- top += len;
- if (yday >= top) {
+
+ int week = (yday - wday + 10) / 7;
+
+ if (week == 0) {
+ // last week of previous year
+ --year;
+ week = (yday + 365 + (QDate::isLeapYear(year) ? 1 : 0) - wday + 10) / 7;
+ Q_ASSERT(week == 52 || week == 53);
+ } else if (week == 53) {
+ // maybe first week of next year
+ int w = (yday - 365 - (QDate::isLeapYear(year + 1) ? 1 : 0) - wday + 10) / 7;
+ if (w > 0) {
++year;
- w = 1;
- break;
+ week = w;
}
- if (yday >= bot) {
- w = 1 + ((yday - bot) / 7);
- break;
- }
- --year;
- yday += isLeapYear(year) ? 366 : 365;
+ Q_ASSERT(week == 53 || week == 1);
}
+
if (yearNumber != 0)
*yearNumber = year;
- return w;
+ return week;
}
#ifndef QT_NO_TEXTDATE
@@ -2473,11 +2440,12 @@ static bool epochMSecsToLocalTime(qint64 msecs, QDate *localDate, QTime *localTi
}
}
-// Convert a LocalTime expressed in local msecs encoding into a UTC epoch msecs
-// Optionally populate the returned values from mktime for the adjusted local
-// date and time and daylight status. Uses daylightStatus in calculation if populated.
-static qint64 localMSecsToEpochMSecs(qint64 localMsecs, QDate *localDate = 0, QTime *localTime = 0,
- QDateTimePrivate::DaylightStatus *daylightStatus = 0,
+// Convert a LocalTime expressed in local msecs encoding and the corresponding
+// daylight status into a UTC epoch msecs. Optionally populate the returned
+// values from mktime for the adjusted local date and time.
+static qint64 localMSecsToEpochMSecs(qint64 localMsecs,
+ QDateTimePrivate::DaylightStatus *daylightStatus,
+ QDate *localDate = 0, QTime *localTime = 0,
QString *abbreviation = 0, bool *ok = 0)
{
QDate dt;
@@ -2713,9 +2681,11 @@ qint64 QDateTimePrivate::toMSecsSinceEpoch() const
case Qt::UTC:
return (m_msecs - (m_offsetFromUtc * 1000));
- case Qt::LocalTime:
+ case Qt::LocalTime: {
// recalculate the local timezone
- return localMSecsToEpochMSecs(m_msecs);
+ DaylightStatus status = daylightStatus();
+ return localMSecsToEpochMSecs(m_msecs, &status);
+ }
case Qt::TimeZone:
#ifndef QT_BOOTSTRAPPED
@@ -2785,7 +2755,7 @@ void QDateTimePrivate::refreshDateTime()
qint64 epochMSecs = 0;
if (m_spec == Qt::LocalTime) {
DaylightStatus status = daylightStatus();
- epochMSecs = localMSecsToEpochMSecs(m_msecs, &testDate, &testTime, &status);
+ epochMSecs = localMSecsToEpochMSecs(m_msecs, &status, &testDate, &testTime);
#ifndef QT_BOOTSTRAPPED
} else {
epochMSecs = zoneMSecsToEpochMSecs(m_msecs, m_timeZone, &testDate, &testTime);
@@ -3223,7 +3193,7 @@ QString QDateTime::timeZoneAbbreviation() const
case Qt::LocalTime: {
QString abbrev;
QDateTimePrivate::DaylightStatus status = d->daylightStatus();
- localMSecsToEpochMSecs(d->m_msecs, 0, 0, &status, &abbrev);
+ localMSecsToEpochMSecs(d->m_msecs, &status, 0, 0, &abbrev);
return abbrev;
}
}
@@ -3254,7 +3224,7 @@ bool QDateTime::isDaylightTime() const
case Qt::LocalTime: {
QDateTimePrivate::DaylightStatus status = d->daylightStatus();
if (status == QDateTimePrivate::UnknownDaylightTime)
- localMSecsToEpochMSecs(d->m_msecs, 0, 0, &status, 0);
+ localMSecsToEpochMSecs(d->m_msecs, &status);
return (status == QDateTimePrivate::DaylightTime);
}
}
@@ -3469,6 +3439,7 @@ void QDateTime::setMSecsSinceEpoch(qint64 msecs)
epochMSecsToLocalTime(msecs, &dt, &tm, &status);
d->setDateTime(dt, tm);
d->setDaylightStatus(status);
+ d->refreshDateTime();
break;
}
}
@@ -3708,12 +3679,14 @@ QDateTime QDateTime::addDays(qint64 ndays) const
date = date.addDays(ndays);
// Result might fall into "missing" DaylightTime transition hour,
// so call conversion and use the adjusted returned time
- if (d->m_spec == Qt::LocalTime)
- localMSecsToEpochMSecs(timeToMSecs(date, time), &date, &time);
+ if (d->m_spec == Qt::LocalTime) {
+ QDateTimePrivate::DaylightStatus status = d->daylightStatus();
+ localMSecsToEpochMSecs(timeToMSecs(date, time), &status, &date, &time);
#ifndef QT_BOOTSTRAPPED
- else if (d->m_spec == Qt::TimeZone)
+ } else if (d->m_spec == Qt::TimeZone) {
QDateTimePrivate::zoneMSecsToEpochMSecs(timeToMSecs(date, time), d->m_timeZone, &date, &time);
#endif // QT_BOOTSTRAPPED
+ }
dt.d->setDateTime(date, time);
return dt;
}
@@ -3742,12 +3715,14 @@ QDateTime QDateTime::addMonths(int nmonths) const
date = date.addMonths(nmonths);
// Result might fall into "missing" DaylightTime transition hour,
// so call conversion and use the adjusted returned time
- if (d->m_spec == Qt::LocalTime)
- localMSecsToEpochMSecs(timeToMSecs(date, time), &date, &time);
+ if (d->m_spec == Qt::LocalTime) {
+ QDateTimePrivate::DaylightStatus status = d->daylightStatus();
+ localMSecsToEpochMSecs(timeToMSecs(date, time), &status, &date, &time);
#ifndef QT_BOOTSTRAPPED
- else if (d->m_spec == Qt::TimeZone)
+ } else if (d->m_spec == Qt::TimeZone) {
QDateTimePrivate::zoneMSecsToEpochMSecs(timeToMSecs(date, time), d->m_timeZone, &date, &time);
#endif // QT_BOOTSTRAPPED
+ }
dt.d->setDateTime(date, time);
return dt;
}
@@ -3776,12 +3751,14 @@ QDateTime QDateTime::addYears(int nyears) const
date = date.addYears(nyears);
// Result might fall into "missing" DaylightTime transition hour,
// so call conversion and use the adjusted returned time
- if (d->m_spec == Qt::LocalTime)
- localMSecsToEpochMSecs(timeToMSecs(date, time), &date, &time);
+ if (d->m_spec == Qt::LocalTime) {
+ QDateTimePrivate::DaylightStatus status = d->daylightStatus();
+ localMSecsToEpochMSecs(timeToMSecs(date, time), &status, &date, &time);
#ifndef QT_BOOTSTRAPPED
- else if (d->m_spec == Qt::TimeZone)
+ } else if (d->m_spec == Qt::TimeZone) {
QDateTimePrivate::zoneMSecsToEpochMSecs(timeToMSecs(date, time), d->m_timeZone, &date, &time);
#endif // QT_BOOTSTRAPPED
+ }
dt.d->setDateTime(date, time);
return dt;
}
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index b3bc12639e..8998b22be8 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
-** Copyright (C) 2013 Intel Corporation
+** Copyright (C) 2015 Intel Corporation
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -158,7 +158,7 @@ static inline bool qt_ends_with(const QChar *haystack, int haystackLen,
static inline bool qt_ends_with(const QChar *haystack, int haystackLen,
QLatin1String needle, Qt::CaseSensitivity cs);
-#ifdef Q_COMPILER_LAMBDA
+#if defined(Q_COMPILER_LAMBDA) && !defined(__OPTIMIZE_SIZE__)
namespace {
template <uint MaxCount> struct UnrollTailLoop
{
@@ -239,7 +239,7 @@ void qt_from_latin1(ushort *dst, const char *str, size_t size)
size = size % 16;
dst += offset;
str += offset;
-# ifdef Q_COMPILER_LAMBDA
+# if defined(Q_COMPILER_LAMBDA) && !defined(__OPTIMIZE_SIZE__)
return UnrollTailLoop<15>::exec(int(size), [=](int i) { dst[i] = (uchar)str[i]; });
# endif
#endif
@@ -332,7 +332,7 @@ static void qt_to_latin1(uchar *dst, const ushort *src, int length)
dst += offset;
src += offset;
-# ifdef Q_COMPILER_LAMBDA
+# if defined(Q_COMPILER_LAMBDA) && !defined(__OPTIMIZE_SIZE__)
return UnrollTailLoop<15>::exec(length, [=](int i) { dst[i] = (src[i]>0xff) ? '?' : (uchar) src[i]; });
# endif
#elif defined(__ARM_NEON__)
@@ -470,7 +470,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, int l)
- reinterpret_cast<const QChar *>(ptr + distance + idx)->unicode();
}
}
-# ifdef Q_COMPILER_LAMBDA
+# if defined(Q_COMPILER_LAMBDA) && !defined(__OPTIMIZE_SIZE__)
const auto &lambda = [=](int i) -> int {
return reinterpret_cast<const QChar *>(ptr)[i].unicode()
- reinterpret_cast<const QChar *>(ptr + distance)[i].unicode();
@@ -602,7 +602,7 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
uc += offset;
c += offset;
-# ifdef Q_COMPILER_LAMBDA
+# if defined(Q_COMPILER_LAMBDA) && !defined(__OPTIMIZE_SIZE__)
const auto &lambda = [=](int i) { return uc[i] - ushort(c[i]); };
return UnrollTailLoop<MaxTailLength>::exec(e - uc, 0, lambda, lambda);
# endif
@@ -684,7 +684,7 @@ static int findChar(const QChar *str, int len, QChar ch, int from,
}
}
-# ifdef Q_COMPILER_LAMBDA
+# if defined(Q_COMPILER_LAMBDA) && !defined(__OPTIMIZE_SIZE__)
return UnrollTailLoop<7>::exec(e - n, -1,
[=](int i) { return n[i] == c; },
[=](int i) { return n - s + i; });
@@ -4797,11 +4797,11 @@ QString QString::trimmed_helper(QString &str)
\overload operator[]()
Returns the character at the specified \a position in the string as a
-modifiable reference. Equivalent to \c at(position).
+modifiable reference.
*/
/*! \fn const QChar QString::operator[](uint position) const
-
+ Equivalent to \c at(position).
\overload operator[]()
*/
diff --git a/src/corelib/tools/qstringalgorithms_p.h b/src/corelib/tools/qstringalgorithms_p.h
index b4be5c7ec7..65901b0286 100644
--- a/src/corelib/tools/qstringalgorithms_p.h
+++ b/src/corelib/tools/qstringalgorithms_p.h
@@ -120,21 +120,23 @@ template <typename StringType> struct QStringAlgorithms
Char *dst = const_cast<Char *>(result.cbegin());
Char *ptr = dst;
+ bool unmodified = true;
forever {
while (src != end && isSpace(*src))
++src;
while (src != end && !isSpace(*src))
*ptr++ = *src++;
- if (src != end)
- *ptr++ = QChar::Space;
- else
+ if (src == end)
break;
+ if (*src != QChar::Space)
+ unmodified = false;
+ *ptr++ = QChar::Space;
}
if (ptr != dst && ptr[-1] == QChar::Space)
--ptr;
int newlen = ptr - dst;
- if (isConst && newlen == str.size()) {
+ if (isConst && newlen == str.size() && unmodified) {
// nothing happened, return the original
return str;
}