summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/animation/qanimationgroup.cpp2
-rw-r--r--src/corelib/animation/qvariantanimation.cpp8
-rw-r--r--src/corelib/codecs/qtextcodec.cpp26
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp8
-rw-r--r--src/corelib/doc/snippets/qstring/main.cpp8
-rw-r--r--src/corelib/doc/src/animation.qdoc9
-rw-r--r--src/corelib/doc/src/containers.qdoc22
-rw-r--r--src/corelib/doc/src/datastreamformat.qdoc2
-rw-r--r--src/corelib/doc/src/filestorage.qdoc4
-rw-r--r--src/corelib/doc/src/implicit-sharing.qdoc1
-rw-r--r--src/corelib/doc/src/objectmodel/signalsandslots.qdoc10
-rw-r--r--src/corelib/doc/src/statemachine.qdoc1
-rw-r--r--src/corelib/global/qcompilerdetection.h66
-rw-r--r--src/corelib/global/qglobal.h2
-rw-r--r--src/corelib/global/qlibraryinfo.cpp10
-rw-r--r--src/corelib/global/qlogging.cpp23
-rw-r--r--src/corelib/global/qnamespace.qdoc25
-rw-r--r--src/corelib/global/qprocessordetection.h4
-rw-r--r--src/corelib/io/io.pri5
-rw-r--r--src/corelib/io/qdatastream.cpp6
-rw-r--r--src/corelib/io/qfsfileengine.cpp41
-rw-r--r--src/corelib/io/qiodevice.cpp2
-rw-r--r--src/corelib/io/qiodevice_p.h18
-rw-r--r--src/corelib/io/qlockfile.cpp2
-rw-r--r--src/corelib/io/qlockfile_unix.cpp2
-rw-r--r--src/corelib/io/qsettings.cpp9
-rw-r--r--src/corelib/io/qsettings_mac.cpp4
-rw-r--r--src/corelib/io/qsettings_p.h2
-rw-r--r--src/corelib/io/qstandardpaths.cpp4
-rw-r--r--src/corelib/io/qstandardpaths_ios.mm2
-rw-r--r--src/corelib/io/qstandardpaths_mac.mm (renamed from src/corelib/io/qstandardpaths_mac.cpp)12
-rw-r--r--src/corelib/io/qstandardpaths_unix.cpp7
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp7
-rw-r--r--src/corelib/io/qstorageinfo_win.cpp2
-rw-r--r--src/corelib/io/qurl.cpp42
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp41
-rw-r--r--src/corelib/itemmodels/qabstractproxymodel.cpp34
-rw-r--r--src/corelib/itemmodels/qabstractproxymodel_p.h2
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.cpp2
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.cpp26
-rw-r--r--src/corelib/json/qjsonarray.cpp2
-rw-r--r--src/corelib/json/qjsonarray.h2
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp2
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp69
-rw-r--r--src/corelib/kernel/qeventdispatcher_win_p.h3
-rw-r--r--src/corelib/kernel/qjni.cpp248
-rw-r--r--src/corelib/kernel/qjni_p.h48
-rw-r--r--src/corelib/kernel/qjnihelpers.cpp38
-rw-r--r--src/corelib/kernel/qjnihelpers_p.h3
-rw-r--r--src/corelib/kernel/qmetaobject.h6
-rw-r--r--src/corelib/kernel/qsystemerror.cpp4
-rw-r--r--src/corelib/kernel/qtranslator.cpp5
-rw-r--r--src/corelib/kernel/qvariant.h26
-rw-r--r--src/corelib/mimetypes/qmimedatabase.cpp4
-rw-r--r--src/corelib/mimetypes/qmimetype.cpp4
-rw-r--r--src/corelib/plugin/qplugin.h2
-rw-r--r--src/corelib/thread/qbasicatomic.h10
-rw-r--r--src/corelib/tools/qbytearray.cpp9
-rw-r--r--src/corelib/tools/qbytearraylist.h1
-rw-r--r--src/corelib/tools/qdatetime.h3
-rw-r--r--src/corelib/tools/qelapsedtimer.h4
-rw-r--r--src/corelib/tools/qelapsedtimer_unix.cpp19
-rw-r--r--src/corelib/tools/qlist.cpp20
-rw-r--r--src/corelib/tools/qlist.h23
-rw-r--r--src/corelib/tools/qlocale.cpp4
-rw-r--r--src/corelib/tools/qlocale_p.h4
-rw-r--r--src/corelib/tools/qsimd.cpp2
-rw-r--r--src/corelib/tools/qsimd_p.h8
-rw-r--r--src/corelib/tools/qstring.cpp87
-rw-r--r--src/corelib/tools/qversionnumber.cpp3
-rw-r--r--src/corelib/tools/qversionnumber_p.h (renamed from src/corelib/tools/qversionnumber.h)0
-rw-r--r--src/corelib/tools/tools.pri2
72 files changed, 693 insertions, 475 deletions
diff --git a/src/corelib/animation/qanimationgroup.cpp b/src/corelib/animation/qanimationgroup.cpp
index 0f87d7263e..241501d60d 100644
--- a/src/corelib/animation/qanimationgroup.cpp
+++ b/src/corelib/animation/qanimationgroup.cpp
@@ -62,7 +62,7 @@
QAnimationGroup provides methods for adding and retrieving
animations. Besides that, you can remove animations by calling
- remove(), and clear the animation group by calling
+ \l removeAnimation(), and clear the animation group by calling
clear(). You may keep track of changes in the group's
animations by listening to QEvent::ChildAdded and
QEvent::ChildRemoved events.
diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp
index dcbf55f28b..f47dec6ce0 100644
--- a/src/corelib/animation/qvariantanimation.cpp
+++ b/src/corelib/animation/qvariantanimation.cpp
@@ -79,7 +79,7 @@ QT_BEGIN_NAMESPACE
There are two ways to affect how QVariantAnimation interpolates
the values. You can set an easing curve by calling
setEasingCurve(), and configure the duration by calling
- setDuration(). You can change how the QVariants are interpolated
+ setDuration(). You can change how the \l{QVariant}s are interpolated
by creating a subclass of QVariantAnimation, and reimplementing
the virtual interpolated() function.
@@ -110,7 +110,7 @@ QT_BEGIN_NAMESPACE
If you need to interpolate other variant types, including custom
types, you have to implement interpolation for these yourself.
To do this, you can register an interpolator function for a given
- type. This function takes 3 parameters: the start value, the end value
+ type. This function takes 3 parameters: the start value, the end value,
and the current progress.
Example:
@@ -378,8 +378,8 @@ QVariantAnimation::~QVariantAnimation()
keyValues are referring to this effective progress.
The easing curve is used with the interpolator, the interpolated()
- virtual function, the animation's duration, and iterationCount, to
- control how the current value changes as the animation progresses.
+ virtual function, and the animation's duration to control how the
+ current value changes as the animation progresses.
*/
QEasingCurve QVariantAnimation::easingCurve() const
{
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 9d13e1b892..d2857c03b6 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -253,9 +253,10 @@ static QTextCodec *setupLocaleMapper()
// textCodecsMutex need to be locked to enter this function
static void setup()
{
- QCoreGlobalData *globalData = QCoreGlobalData::instance();
- if (!globalData->allCodecs.isEmpty())
+ static bool initialized = false;
+ if (initialized)
return;
+ initialized = true;
#if !defined(QT_NO_CODECS) && !defined(QT_BOOTSTRAPPED)
(void)new QTsciiCodec;
@@ -441,7 +442,7 @@ QTextCodec::ConverterState::~ConverterState()
an empty list. For example, "ISO-8859-1" has "latin1",
"CP819", "IBM819", and "iso-ir-100" as aliases.
- \row \li mibEnum()
+ \row \li \l{QTextCodec::mibEnum()}{mibEnum()}
\li Return the MIB enum for the encoding if it is listed in
the \l{IANA character-sets encoding file}.
@@ -465,7 +466,11 @@ QTextCodec::QTextCodec()
{
QMutexLocker locker(textCodecsMutex());
- QCoreGlobalData::instance()->allCodecs.prepend(this);
+ QCoreGlobalData *globalInstance = QCoreGlobalData::instance();
+ if (globalInstance->allCodecs.isEmpty())
+ setup();
+
+ globalInstance->allCodecs.prepend(this);
}
@@ -503,7 +508,7 @@ QTextCodec *QTextCodec::codecForName(const QByteArray &name)
QCoreGlobalData *globalData = QCoreGlobalData::instance();
if (!globalData)
return 0;
- setup();
+ setup();
#ifndef QT_USE_ICU
QTextCodecCache *cache = &globalData->codecCache;
@@ -704,7 +709,7 @@ QTextCodec* QTextCodec::codecForLocale()
\fn int QTextCodec::mibEnum() const
Subclasses of QTextCodec must reimplement this function. It
- returns the MIBenum (see \l{IANA character-sets encoding file}
+ returns the \l{QTextCodec::mibEnum()}{MIBenum} (see \l{IANA character-sets encoding file}
for more information). It is important that each QTextCodec
subclass returns the correct unique value for this function.
*/
@@ -733,7 +738,7 @@ QList<QByteArray> QTextCodec::aliases() const
\a state can be 0, in which case the conversion is stateless and
default conversion rules should be used. If state is not 0, the
codec should save the state after the conversion in \a state, and
- adjust the remainingChars and invalidChars members of the struct.
+ adjust the \c remainingChars and \c invalidChars members of the struct.
*/
/*!
@@ -749,7 +754,7 @@ QList<QByteArray> QTextCodec::aliases() const
\a state can be 0 in which case the conversion is stateless and
default conversion rules should be used. If state is not 0, the
codec should save the state after the conversion in \a state, and
- adjust the remainingChars and invalidChars members of the struct.
+ adjust the \c remainingChars and \c invalidChars members of the struct.
*/
/*!
@@ -1049,7 +1054,10 @@ QTextCodec *QTextCodec::codecForHtml(const QByteArray &ba, QTextCodec *defaultCo
while (++pos2 < header.size()) {
char ch = header.at(pos2);
if (ch == '\"' || ch == '\'' || ch == '>') {
- c = QTextCodec::codecForName(header.mid(pos, pos2 - pos));
+ QByteArray name = header.mid(pos, pos2 - pos);
+ if (name == "unicode") // QTBUG-41998, ICU will return UTF-16.
+ name = QByteArrayLiteral("UTF-8");
+ c = QTextCodec::codecForName(name);
return c ? c : defaultCodec;
}
}
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp
index 9210d2737f..97be131203 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp
@@ -354,10 +354,10 @@ text.toBase64(); // returns "UXQgaXMgZ3JlYXQh"
//! [39bis]
QByteArray text("<p>Hello?</p>");
-text.toBase64(QByteArray::Base64 | QByteArray::OmitTrailingEquals); // returns "PHA+SGVsbG8/PC9wPg"
-text.toBase64(QByteArray::Base64); // returns "PHA+SGVsbG8/PC9wPg=="
-text.toBase64(QByteArray::Base64Url); // returns "PHA-SGVsbG8_PC9wPg=="
-text.toBase64(QByteArray::Base64Url | QByteArray::OmitTrailingEquals); // returns "PHA-SGVsbG8_PC9wPg"
+text.toBase64(QByteArray::Base64Encoding | QByteArray::OmitTrailingEquals); // returns "PHA+SGVsbG8/PC9wPg"
+text.toBase64(QByteArray::Base64Encoding); // returns "PHA+SGVsbG8/PC9wPg=="
+text.toBase64(QByteArray::Base64UrlEncoding); // returns "PHA-SGVsbG8_PC9wPg=="
+text.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); // returns "PHA-SGVsbG8_PC9wPg"
//! [39bis]
diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp
index f5c6b69695..17d0adf097 100644
--- a/src/corelib/doc/snippets/qstring/main.cpp
+++ b/src/corelib/doc/snippets/qstring/main.cpp
@@ -774,14 +774,6 @@ void Widget::splitCaseSensitiveFunction()
void Widget::sprintfFunction()
{
- //! [63]
- size_t BufSize;
- char buf[BufSize];
-
- ::snprintf(buf, BufSize, "%lld", 123456789LL);
- QString str = QString::fromUtf8(buf);
- //! [63]
-
//! [64]
QString result;
QTextStream(&result) << "pi = " << 3.14;
diff --git a/src/corelib/doc/src/animation.qdoc b/src/corelib/doc/src/animation.qdoc
index 6910b18937..9385c08995 100644
--- a/src/corelib/doc/src/animation.qdoc
+++ b/src/corelib/doc/src/animation.qdoc
@@ -27,6 +27,7 @@
/*!
\group animation
+ \brief Provides an easy way for creating animated GUIs.
\title Animation Framework
This page lists classes belonging to \l{Qt Core}'s
@@ -46,8 +47,8 @@
\keyword Animation
The animation framework aims to provide an easy way for creating animated
- and smooth GUI's. By animating Qt properties, the framework provides great
- freedom for animating widgets and other \l{QObject}s. The framework can
+ and smooth GUIs. By animating Qt properties, the framework provides great
+ freedom for animating widgets and other {QObject}s. The framework can
also be used with the Graphics View framework. Many of the concepts
available in the animation framework are also available in \l{Qt Quick},
where it offers a declarative way of defining animations. Much of the
@@ -56,7 +57,7 @@
In this overview, we explain the basics of its architecture. We
also show examples of the most common techniques that the
- framework allows for animating QObjects and graphics items.
+ framework allows for animating {QObject}s and graphics items.
\tableofcontents
@@ -84,7 +85,7 @@
over the property using an easing curve. So when you want to
animate a value, you can declare it as a property and make your
class a QObject. Note that this gives us great freedom in
- animating already existing widgets and other \l{QObject}s.
+ animating already existing widgets and other {QObject}s.
Complex animations can be constructed by building a tree structure
of \l{QAbstractAnimation}s. The tree is built by using
diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc
index 6017269272..a517ca32d3 100644
--- a/src/corelib/doc/src/containers.qdoc
+++ b/src/corelib/doc/src/containers.qdoc
@@ -386,7 +386,7 @@
\l{QMapIterator::hasPrevious()}{hasPrevious()},
\l{QMapIterator::previous()}{previous()}, and
\l{QMapIterator::peekPrevious()}{peekPrevious()}. The key and
- value components are extracted by calling key() and value() on
+ value components are extracted by calling \l{QMapIterator::key()}{key()} and \l{QMapIterator::value()}{value()} on
the object returned by next(), peekNext(), previous(), or
peekPrevious().
@@ -395,7 +395,7 @@
\snippet code/doc_src_containers.cpp 7
- QMapIterator also provides a key() and a value() function that
+ QMapIterator also provides a \l{QMapIterator::key()}{key()} and a \l{QMapIterator::value()}{value()} function that
operate directly on the iterator and that return the key and
value of the last item that the iterator jumped above. For
example, the following code copies the contents of a QMap into a
@@ -459,13 +459,13 @@
\snippet code/doc_src_containers.cpp 10
Unlike \l{Java-style iterators}, STL-style iterators point
- directly at items. The begin() function of a container returns an
+ directly at items. The \l{QList::begin()}{begin()} function of a container returns an
iterator that points to the first item in the container. The
- end() function of a container returns an iterator to the
+ \l{QList::end()}{end()} function of a container returns an iterator to the
imaginary item one position past the last item in the container.
- end() marks an invalid position; it must never be dereferenced.
+ \l {QList::end()}{end()} marks an invalid position; it must never be dereferenced.
It is typically used in a loop's break condition. If the list is
- empty, begin() equals end(), so we never execute the loop.
+ empty, \l{QList::begin}{begin()} equals \l{QList:end()}{end()}, so we never execute the loop.
The diagram below shows the valid iterator positions as red
arrows for a vector containing four items:
@@ -484,8 +484,8 @@
compilers also allow us to write \c{i->toLower()}, but some
don't.
- For read-only access, you can use const_iterator, constBegin(),
- and constEnd(). For example:
+ For read-only access, you can use const_iterator, \l{QList::constBegin}{constBegin()},
+ and \l{QList::constEnd()}{constEnd()}. For example:
\snippet code/doc_src_containers.cpp 12
@@ -759,7 +759,7 @@
QString.
QVector<T> also uses that algorithm for data types that can be
- moved around in memory using memcpy() (including the basic C++
+ moved around in memory using \c memcpy() (including the basic C++
types, the pointer types, and Qt's \l{shared classes}) but uses a
different algorithm for data types that can only be moved by
calling the copy constructor and a destructor. Since the cost of
@@ -790,7 +790,7 @@
\endlist
If you know approximately how many items you will store in a
- container, you can start by calling reserve(), and when you are
- done populating the container, you can call squeeze() to release
+ container, you can start by calling \l{QString::reserve()}{reserve()}, and when you are
+ done populating the container, you can call \l{QString::squeeze()}{squeeze()} to release
the extra preallocated memory.
*/
diff --git a/src/corelib/doc/src/datastreamformat.qdoc b/src/corelib/doc/src/datastreamformat.qdoc
index b6efe6aa33..56a6d0aafa 100644
--- a/src/corelib/doc/src/datastreamformat.qdoc
+++ b/src/corelib/doc/src/datastreamformat.qdoc
@@ -173,7 +173,7 @@
\li If the image is null a "null image" marker is saved;
otherwise the image is saved in PNG or BMP format (depending
on the stream version). If you want control of the format,
- stream the image into a QBuffer (using QImageIO) and stream
+ stream the image into a QBuffer (using QImageIOHandler/QImageIOPlugin) and stream
that.
\endlist
\row \li QKeySequence
diff --git a/src/corelib/doc/src/filestorage.qdoc b/src/corelib/doc/src/filestorage.qdoc
index 394d920923..a60c5846ff 100644
--- a/src/corelib/doc/src/filestorage.qdoc
+++ b/src/corelib/doc/src/filestorage.qdoc
@@ -86,8 +86,8 @@ read console input and write console output.
There are three general ways to use QTextStream when reading text files:
\list
- \li Chunk by chunk, by calling readLine() or readAll().
- \li Word by word. QTextStream supports streaming into QStrings, QByteArrays
+ \li Chunk by chunk, by calling \l{QBuffer::readLine()}{readLine()} or \l{QBuffer::readAll()}{readAll()}.
+ \li Word by word. QTextStream supports streaming into {QString}s, {QByteArray}s
and char* buffers. Words are delimited by space, and leading white space
is automatically skipped.
\li Character by character, by streaming into QChar or char types. This
diff --git a/src/corelib/doc/src/implicit-sharing.qdoc b/src/corelib/doc/src/implicit-sharing.qdoc
index 1185fe8348..ec8edb4b6b 100644
--- a/src/corelib/doc/src/implicit-sharing.qdoc
+++ b/src/corelib/doc/src/implicit-sharing.qdoc
@@ -30,6 +30,7 @@
/*!
\group shared
+ \brief How to maximize resource usage by implicit data sharing.
\title Implicitly Shared Classes
These \l{Qt Core} classes provides a safe and efficient way of sharing and
diff --git a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
index f79e8a7dca..b9b1874d0f 100644
--- a/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
+++ b/src/corelib/doc/src/objectmodel/signalsandslots.qdoc
@@ -242,7 +242,7 @@
By default, for every connection you make, a signal is emitted;
two signals are emitted for duplicate connections. You can break
- all of these connections with a single disconnect() call.
+ all of these connections with a single \l{QObject::disconnect()}{disconnect()} call.
If you pass the Qt::UniqueConnection \a type, the connection will only
be made if it is not a duplicate. If there is already a duplicate
(exact same signal to the exact same slot on the same objects),
@@ -251,9 +251,7 @@
This example illustrates that objects can work together without needing to
know any information about each other. To enable this, the objects only
need to be connected together, and this can be achieved with some simple
- QObject::connect() function calls, or with \c{uic}'s
- \l{Using a Designer UI File in Your Application#Automatic Connections}
- {automatic connections} feature.
+ QObject::connect() function calls, or with \c{uic}'s {automatic connections} feature.
\section1 A Real Example
@@ -354,7 +352,7 @@
connect(sender, &QObject::destroyed, this, &MyObject::objectDestroyed);
\endcode
- There are several advantages to using connect() with function pointers.
+ There are several advantages to using QObject::connect() with function pointers.
First, it allows the compiler to check that the signal's arguments are
compatible with the slot's arguments. Arguments can also be implicitly
converted by the compiler, if needed.
@@ -407,7 +405,7 @@
will open: "Tax File", "Accounts File", or "Report File".
In order to open the correct file, you use QSignalMapper::setMapping() to
- map all the clicked() signals to a QSignalMapper object. Then you connect
+ map all the QPushButton::clicked() signals to a QSignalMapper object. Then you connect
the file's QPushButton::clicked() signal to the QSignalMapper::map() slot.
\snippet signalmapper/filereader.cpp 0
diff --git a/src/corelib/doc/src/statemachine.qdoc b/src/corelib/doc/src/statemachine.qdoc
index b281eb177b..846eb7d1f0 100644
--- a/src/corelib/doc/src/statemachine.qdoc
+++ b/src/corelib/doc/src/statemachine.qdoc
@@ -27,6 +27,7 @@
/*!
\group statemachine
+ \brief How to create and execute state graphs.
\title State Machine Classes
These \l{Qt Core} classes are part of the \l{The State Machine Framework}{
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 8ac84599f2..ee396409d8 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -78,7 +78,7 @@
# define Q_NO_USING_KEYWORD
#elif defined(_MSC_VER)
-# define Q_CC_MSVC
+# define Q_CC_MSVC (_MSC_VER)
# define Q_CC_MSVC_NET
# define Q_OUTOFLINE_TEMPLATE inline
# if _MSC_VER < 1600
@@ -137,14 +137,14 @@
# endif
#elif defined(__GNUC__)
-# define Q_CC_GNU
+# define Q_CC_GNU (__GNUC__ * 100 + __GNUC_MINOR__)
# define Q_C_CALLBACKS
# if defined(__MINGW32__)
# define Q_CC_MINGW
# endif
# if defined(__INTEL_COMPILER)
/* Intel C++ also masquerades as GCC */
-# define Q_CC_INTEL
+# define Q_CC_INTEL (__INTEL_COMPILER)
# define Q_ASSUME_IMPL(expr) __assume(expr)
# define Q_UNREACHABLE_IMPL() __builtin_unreachable()
# if __INTEL_COMPILER >= 1300 && !defined(__APPLE__)
@@ -152,7 +152,26 @@
# endif
# elif defined(__clang__)
/* Clang also masquerades as GCC */
-# define Q_CC_CLANG
+# if defined(__apple_build_version__)
+# /* http://en.wikipedia.org/wiki/Xcode#Toolchain_Versions */
+# if __apple_build_version__ >= 600051
+# define Q_CC_CLANG 305
+# elif __apple_build_version__ >= 503038
+# define Q_CC_CLANG 304
+# elif __apple_build_version__ >= 500275
+# define Q_CC_CLANG 303
+# elif __apple_build_version__ >= 425024
+# define Q_CC_CLANG 302
+# elif __apple_build_version__ >= 318045
+# define Q_CC_CLANG 301
+# elif __apple_build_version__ >= 211101
+# define Q_CC_CLANG 300
+# else
+# error "Unknown Apple Clang version"
+# endif
+# else
+# define Q_CC_CLANG ((__clang_major__ * 100) + __clang_minor__)
+# endif
# define Q_ASSUME_IMPL(expr) if (expr){} else __builtin_unreachable()
# define Q_UNREACHABLE_IMPL() __builtin_unreachable()
# if !defined(__has_extension)
@@ -168,7 +187,7 @@
# endif
# else
/* Plain GCC */
-# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
+# if Q_CC_GNU >= 405
# define Q_ASSUME_IMPL(expr) if (expr){} else __builtin_unreachable()
# define Q_UNREACHABLE_IMPL() __builtin_unreachable()
# define Q_DECL_DEPRECATED_X(text) __attribute__ ((__deprecated__(text)))
@@ -202,7 +221,7 @@
# define QT_NO_ARM_EABI
# endif
# endif
-# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403 && !defined(Q_CC_CLANG)
+# if Q_CC_GNU >= 403 && !defined(Q_CC_CLANG)
# define Q_ALLOC_SIZE(x) __attribute__((alloc_size(x)))
# endif
@@ -308,7 +327,7 @@
/* Using the `using' keyword avoids Intel C++ for Linux warnings */
# elif defined(__INTEL_COMPILER)
-# define Q_CC_INTEL
+# define Q_CC_INTEL (__INTEL_COMPILER)
/* Uses CFront, make sure to read the manual how to tweak templates. */
# elif defined(__ghs)
@@ -566,7 +585,7 @@
# endif
// Variadic macros are supported for gnu++98, c++11, c99 ... since 2.9
-# if ((__clang_major__ * 100) + __clang_minor__) >= 209
+# if Q_CC_CLANG >= 209
# if !defined(__STRICT_ANSI__) || defined(__GXX_EXPERIMENTAL_CXX0X__) \
|| (defined(__cplusplus) && (__cplusplus >= 201103L)) \
|| (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
@@ -581,7 +600,7 @@
# define Q_COMPILER_ALIGNAS
# define Q_COMPILER_ALIGNOF
# endif
-# if 0 /* not implemented in clang yet */
+# if __has_feature(cxx_atomic) && __has_include(<atomic>)
# define Q_COMPILER_ATOMICS
# endif
# if __has_feature(cxx_attributes)
@@ -668,7 +687,7 @@
# define Q_COMPILER_VARIADIC_TEMPLATES
# endif
/* Features that have no __has_feature() check */
-# if ((__clang_major__ * 100) + __clang_minor__) >= 209 /* since clang 2.9 */
+# if Q_CC_CLANG >= 209 /* since clang 2.9 */
# define Q_COMPILER_EXTERN_TEMPLATES
# endif
# endif
@@ -709,7 +728,7 @@
#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_CLANG)
# define Q_COMPILER_RESTRICTED_VLA
# define Q_COMPILER_THREADSAFE_STATICS
-# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403
+# if Q_CC_GNU >= 403
// GCC supports binary literals in C, C++98 and C++11 modes
# define Q_COMPILER_BINARY_LITERALS
# endif
@@ -720,13 +739,13 @@
# define Q_COMPILER_VARIADIC_MACROS
# endif
# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
-# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403
+# if Q_CC_GNU >= 403
/* C++11 features supported in GCC 4.3: */
# define Q_COMPILER_DECLTYPE
# define Q_COMPILER_RVALUE_REFS
# define Q_COMPILER_STATIC_ASSERT
# endif
-# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404
+# if Q_CC_GNU >= 404
/* C++11 features supported in GCC 4.4: */
# define Q_COMPILER_AUTO_FUNCTION
# define Q_COMPILER_AUTO_TYPE
@@ -735,7 +754,7 @@
# define Q_COMPILER_UNICODE_STRINGS
# define Q_COMPILER_VARIADIC_TEMPLATES
# endif
-# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
+# if Q_CC_GNU >= 405
/* C++11 features supported in GCC 4.5: */
# define Q_COMPILER_EXPLICIT_CONVERSIONS
/* GCC 4.4 implements initializer_list but does not define typedefs required
@@ -745,7 +764,7 @@
# define Q_COMPILER_RAW_STRINGS
# define Q_COMPILER_CLASS_ENUM
# endif
-# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
+# if Q_CC_GNU >= 406
/* Pre-4.6 compilers implement a non-final snapshot of N2346, hence default and delete
* functions are supported only if they are public. Starting from 4.6, GCC handles
* final version - the access modifier is not relevant. */
@@ -757,7 +776,7 @@
# define Q_COMPILER_UNRESTRICTED_UNIONS
# define Q_COMPILER_RANGE_FOR
# endif
-# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407
+# if Q_CC_GNU >= 407
/* GCC 4.4 implemented <atomic> and std::atomic using its old intrinsics.
* However, the implementation is incomplete for most platforms until GCC 4.7:
* instead, std::atomic would use an external lock. Since we need an std::atomic
@@ -773,20 +792,20 @@
# define Q_COMPILER_TEMPLATE_ALIAS
# define Q_COMPILER_UDL
# endif
-# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408
+# if Q_CC_GNU >= 408
# define Q_COMPILER_ATTRIBUTES
# define Q_COMPILER_ALIGNAS
# define Q_COMPILER_ALIGNOF
# define Q_COMPILER_INHERITING_CONSTRUCTORS
# define Q_COMPILER_THREAD_LOCAL
-# if (__GNUC__ * 100 + __GNUC_MINOR__) > 408 || __GNUC_PATCHLEVEL__ >= 1
+# if Q_CC_GNU > 408 || __GNUC_PATCHLEVEL__ >= 1
# define Q_COMPILER_REF_QUALIFIERS
# endif
# endif
/* C++11 features are complete as of GCC 4.8.1 */
# endif
# if __cplusplus > 201103L
-# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409
+# if Q_CC_GNU >= 409
/* C++1y features in GCC 4.9 - deprecated, do not update this list */
//# define Q_COMPILER_BINARY_LITERALS // already supported since GCC 4.3 as an extension
# define Q_COMPILER_LAMBDA_CAPTURES
@@ -880,6 +899,15 @@
# undef Q_COMPILER_INITIALIZER_LISTS
# undef Q_COMPILER_RVALUE_REFS
# undef Q_COMPILER_REF_QUALIFIERS
+// Also disable <atomic>, since it's clearly not there
+# undef Q_COMPILER_ATOMICS
+# endif
+# if defined(_LIBCPP_VERSION)
+// libc++ uses __has_feature(cxx_atomic), so disable the feature if the compiler
+// doesn't support it. That's required for the Intel compiler on OS X, for example.
+# if !__has_feature(cxx_atomic)
+# undef Q_COMPILER_ATOMICS
+# endif
# endif
# if defined(Q_COMPILER_THREADSAFE_STATICS) && defined(Q_OS_MAC)
// Mac OS X: Apple's low-level implementation of the C++ support library
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 4a21ab88d8..4e8721f7d7 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -877,7 +877,7 @@ public:
// (http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#382).
// GCC 4.3 and 4.4 have support for decltype, but are affected by DR 382.
# if defined(Q_COMPILER_DECLTYPE) && \
- (defined(Q_CC_CLANG) || defined(Q_CC_INTEL) || !defined(Q_CC_GNU) || (__GNUC__ * 100 + __GNUC_MINOR__) >= 405)
+ (defined(Q_CC_CLANG) || defined(Q_CC_INTEL) || !defined(Q_CC_GNU) || Q_CC_GNU >= 405)
# define QT_FOREACH_DECLTYPE(x) typename QtPrivate::remove_reference<decltype(x)>::type
# else
# define QT_FOREACH_DECLTYPE(x) __typeof__((x))
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index c3ec2bc7f6..7ca0aa7f0b 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -84,14 +84,7 @@ class QLibraryInfoPrivate
{
public:
static QSettings *findConfiguration();
-#ifndef QT_BOOTSTRAPPED
- static void cleanup()
- {
- QLibrarySettings *ls = qt_library_settings();
- if (ls)
- ls->settings.reset(0);
- }
-#else
+#ifdef QT_BOOTSTRAPPED
static bool haveGroup(QLibraryInfo::PathGroup group)
{
QLibrarySettings *ls = qt_library_settings();
@@ -114,7 +107,6 @@ QLibrarySettings::QLibrarySettings()
: settings(QLibraryInfoPrivate::findConfiguration())
{
#ifndef QT_BOOTSTRAPPED
- qAddPostRoutine(QLibraryInfoPrivate::cleanup);
bool haveEffectivePaths;
bool havePaths;
#endif
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index f356bab42d..39c5ac602e 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -1101,14 +1101,9 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con
if (!pattern) {
// after destruction of static QMessagePattern instance
message.append(str);
- message.append(QLatin1Char('\n'));
return message;
}
- // don't print anything if pattern was empty
- if (pattern->tokens[0] == 0)
- return message;
-
bool skip = false;
// we do not convert file, function, line literals to local encoding due to overhead
@@ -1227,7 +1222,6 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con
message.append(QLatin1String(token));
}
}
- message.append(QLatin1Char('\n'));
return message;
}
@@ -1289,7 +1283,7 @@ static void android_default_message_handler(QtMsgType type,
case QtFatalMsg: priority = ANDROID_LOG_FATAL; break;
};
- __android_log_print(priority, "Qt", "%s:%d (%s): %s",
+ __android_log_print(priority, "Qt", "%s:%d (%s): %s\n",
context.file, context.line,
context.function, qPrintable(message));
}
@@ -1303,16 +1297,21 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con
{
QString logMessage = qFormatLogMessage(type, context, buf);
+ // print nothing if message pattern didn't apply / was empty.
+ // (still print empty lines, e.g. because message itself was empty)
+ if (logMessage.isNull())
+ return;
+
if (!qt_logging_to_console()) {
#if defined(Q_OS_WIN)
+ logMessage.append(QLatin1Char('\n'));
OutputDebugString(reinterpret_cast<const wchar_t *>(logMessage.utf16()));
return;
#elif defined(QT_USE_SLOG2)
+ logMessage.append(QLatin1Char('\n'));
slog2_default_handler(type, logMessage.toLocal8Bit().constData());
return;
#elif defined(QT_USE_JOURNALD) && !defined(QT_BOOTSTRAPPED)
- // remove trailing \n, systemd appears to want them newline-less
- logMessage.chop(1);
systemd_default_message_handler(type, context, logMessage);
return;
#elif defined(Q_OS_ANDROID)
@@ -1320,7 +1319,7 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con
return;
#endif
}
- fprintf(stderr, "%s", logMessage.toLocal8Bit().constData());
+ fprintf(stderr, "%s\n", logMessage.toLocal8Bit().constData());
fflush(stderr);
}
@@ -1380,7 +1379,7 @@ static void qt_message_print(QtMsgType msgType, const QMessageLogContext &contex
}
ungrabMessageHandler();
} else {
- fprintf(stderr, "%s", message.toLocal8Bit().constData());
+ fprintf(stderr, "%s\n", message.toLocal8Bit().constData());
}
}
@@ -1579,7 +1578,7 @@ void qErrnoWarning(int code, const char *msg, ...)
The default \a pattern is "%{if-category}%{category}: %{endif}%{message}".
The \a pattern can also be changed at runtime by setting the QT_MESSAGE_PATTERN
- environment variable; if both qSetMessagePattern() is called and QT_MESSAGE_PATTERN is
+ environment variable; if both \l qSetMessagePattern() is called and QT_MESSAGE_PATTERN is
set, the environment variable takes precedence.
Custom message handlers can use qFormatLogMessage() to take \a pattern into account.
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 4e074bcdb5..53d2b7b58b 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -134,7 +134,7 @@
\value AA_MacDontSwapCtrlAndMeta On Mac OS X by default, Qt swaps the
Control and Meta (Command) keys (i.e., whenever Control is pressed, Qt
sends Meta, and whenever Meta is pressed Control is sent). When this
- attribute is true, Qt will not do the flip. QKeySequence::StandardShortcuts
+ attribute is true, Qt will not do the flip. \l QKeySequence::StandardKey
will also flip accordingly (i.e., QKeySequence::Copy will be
Command+C on the keyboard regardless of the value set, though what is output for
QKeySequence::toString(QKeySequence::PortableText) will be different).
@@ -144,7 +144,7 @@
to be consistent in pixels-per-point across devices rather than
defining 1 point as 1/72 inch.
- \value AA_X11InitThreads Calls XInitThreads() as part of the QApplication
+ \value AA_X11InitThreads Calls \c XInitThreads() as part of the QApplication
construction in order to make Xlib calls thread-safe. This
attribute must be set before QApplication is constructed.
@@ -159,10 +159,11 @@
\value AA_UseHighDpiPixmaps Make QIcon::pixmap() generate high-dpi pixmaps
that can be larger than the requested size. Such pixmaps will have
- devicePixelRatio set to a value higher than 1. After setting this
- attribute application code that uses pixmap sizes in layout geometry
- calculations should typically divide by QPixmap::devicePixelRatio()
- to get device-independent layout geometry.
+ \l {QPixmap::devicePixelRatio}{devicePixelRatio()} set to a value higher than 1.
+
+ After setting this attribute, application code that uses pixmap
+ sizes in layout geometry calculations should typically divide by
+ \l {QPixmap::devicePixelRatio}{devicePixelRatio()} to get device-independent layout geometry.
\value AA_ForceRasterWidgets Make top-level widgets use pure raster surfaces,
and do not support non-native GL-based child widgets.
@@ -182,7 +183,7 @@
\l{http://www.mesa3d.org/llvmpipe.html}{Mesa llvmpipe}, providing
OpenGL 2.1. The value may have no effect if no such OpenGL
implementation is available. The default name of this library is
- opengl32sw.dll and can be overridden by setting the environment
+ \c opengl32sw.dll and can be overridden by setting the environment
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.
@@ -221,7 +222,7 @@
\value AllButtons This value corresponds to a mask of all
possible mouse buttons. Use to set the 'acceptedButtons'
- property of a mouseArea to accept ALL mouse buttons.
+ property of a MouseArea to accept ALL mouse buttons.
\value LeftButton The left button is pressed, or an event refers
to the left button. (The left button may be the right button on
@@ -2443,7 +2444,7 @@
\value ImhExclusiveInputMask This mask yields nonzero if any of the exclusive flags are used.
- \note If several exclusive flags are ORed together, the resulting character set will
+ \note If several exclusive flags are OR-ed together, the resulting character set will
consist of the union of the specified sets. For instance specifying \c ImhNumbersOnly and
\c ImhUppercaseOnly would yield a set consisting of numbers and uppercase letters.
@@ -2803,11 +2804,11 @@
This enum type describes the state of a gesture.
+ \value NoGesture No gesture has been detected.
\value GestureStarted A continuous gesture has started.
\value GestureUpdated A gesture continues.
\value GestureFinished A gesture has finished.
\value GestureCanceled A gesture was canceled.
- \omitvalue NoGesture
\sa QGesture
*/
@@ -2969,8 +2970,8 @@
This enum provides additional information concerning a QMouseEvent.
\value MouseEventCreatedDoubleClick Indicates that Qt has created a
- MouseButtonDblClick event from this event. The flag is set in the causing
- MouseButtonPress, and not in the resulting MouseButtonDblCLick.
+ \l {QEvent::MouseButtonDblClick}{MouseButtonDblClick} event from this event. The flag is set in the causing
+ \l {QEvent::MouseButtonPress}{MouseButtonPress}, and not in the resulting \l {QEvent::MouseButtonDblClick}{MouseButtonDblClick}.
\omitvalue MouseEventFlagMask
*/
diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h
index 26ac56396b..55cb31c62b 100644
--- a/src/corelib/global/qprocessordetection.h
+++ b/src/corelib/global/qprocessordetection.h
@@ -87,9 +87,9 @@
ARM is bi-endian, detect using __ARMEL__ or __ARMEB__, falling back to
auto-detection implemented below.
*/
-#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) || defined(__arm64__)
+#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) || defined(__aarch64__)
# define Q_PROCESSOR_ARM
-# if defined(__arm64__)
+# if defined(__aarch64__)
# define Q_PROCESSOR_ARM_64
# else
# define Q_PROCESSOR_ARM_32
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri
index bdc362ef22..77788e3cca 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -148,9 +148,8 @@ win32 {
HEADERS += io/qfilesystemwatcher_fsevents_p.h
}
macx {
- SOURCES += \
- io/qstorageinfo_mac.cpp \
- io/qstandardpaths_mac.cpp
+ SOURCES += io/qstorageinfo_mac.cpp
+ OBJECTIVE_SOURCES += io/qstandardpaths_mac.mm
LIBS += -framework DiskArbitration -framework IOKit
} else:ios {
OBJECTIVE_SOURCES += io/qstandardpaths_ios.mm
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index 8d757a7773..60f04ce4f1 100644
--- a/src/corelib/io/qdatastream.cpp
+++ b/src/corelib/io/qdatastream.cpp
@@ -261,12 +261,6 @@ QDataStream::QDataStream()
/*!
Constructs a data stream that uses the I/O device \a d.
- \warning If you use QSocket or QSocketDevice as the I/O device \a d
- for reading data, you must make sure that enough data is available
- on the socket for the operation to successfully proceed;
- QDataStream does not have any means to handle or recover from
- short-reads.
-
\sa setDevice(), device()
*/
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp
index 42250b629d..a126690240 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -73,6 +73,17 @@ QT_BEGIN_NAMESPACE
# endif
#endif
+#ifdef Q_OS_WIN
+// on Windows, read() and write() use int and unsigned int
+typedef int SignedIOType;
+typedef unsigned int UnsignedIOType;
+#else
+typedef ssize_t SignedIOType;
+typedef size_t UnsignedIOType;
+Q_STATIC_ASSERT_X(sizeof(SignedIOType) == sizeof(UnsignedIOType),
+ "Unsupported: read/write return a type with different size as the len parameter");
+#endif
+
/*! \class QFSFileEngine
\inmodule QtCore
\brief The QFSFileEngine class implements Qt's default file engine.
@@ -605,13 +616,16 @@ qint64 QFSFileEnginePrivate::readFdFh(char *data, qint64 len)
} else if (fd != -1) {
// Unbuffered stdio mode.
-#ifdef Q_OS_WIN
- int result;
-#else
- ssize_t result;
-#endif
+ SignedIOType result;
do {
- result = QT_READ(fd, data + readBytes, size_t(len - readBytes));
+ // calculate the chunk size
+ // on Windows or 32-bit no-largefile Unix, we'll need to read in chunks
+ // we limit to the size of the signed type, otherwise we could get a negative number as a result
+ quint64 wantedBytes = quint64(len) - quint64(readBytes);
+ UnsignedIOType chunkSize = std::numeric_limits<SignedIOType>::max();
+ if (chunkSize > wantedBytes)
+ chunkSize = wantedBytes;
+ result = QT_READ(fd, data + readBytes, chunkSize);
} while (result > 0 && (readBytes += result) < len);
eof = !(result == -1);
@@ -722,13 +736,16 @@ qint64 QFSFileEnginePrivate::writeFdFh(const char *data, qint64 len)
} else if (fd != -1) {
// Unbuffered stdio mode.
-#ifdef Q_OS_WIN
- int result;
-#else
- ssize_t result;
-#endif
+ SignedIOType result;
do {
- result = QT_WRITE(fd, data + writtenBytes, size_t(len - writtenBytes));
+ // calculate the chunk size
+ // on Windows or 32-bit no-largefile Unix, we'll need to read in chunks
+ // we limit to the size of the signed type, otherwise we could get a negative number as a result
+ quint64 wantedBytes = quint64(len) - quint64(writtenBytes);
+ UnsignedIOType chunkSize = std::numeric_limits<SignedIOType>::max();
+ if (chunkSize > wantedBytes)
+ chunkSize = wantedBytes;
+ result = QT_WRITE(fd, data + writtenBytes, chunkSize);
} while (result > 0 && (writtenBytes += result) < len);
}
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index 0896432837..36f88f2774 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -788,7 +788,7 @@ qint64 QIODevice::read(char *data, qint64 maxSize)
char *readPtr = data;
forever {
// Try reading from the buffer.
- int bufferReadChunkSize = d->buffer.read(data, maxSize);
+ qint64 bufferReadChunkSize = d->buffer.read(data, maxSize);
if (bufferReadChunkSize > 0) {
*d->pPos += bufferReadChunkSize;
readSoFar += bufferReadChunkSize;
diff --git a/src/corelib/io/qiodevice_p.h b/src/corelib/io/qiodevice_p.h
index 10d92a896d..d764cb0fbb 100644
--- a/src/corelib/io/qiodevice_p.h
+++ b/src/corelib/io/qiodevice_p.h
@@ -98,19 +98,19 @@ public:
first++;
return ch;
}
- int read(char* target, qint64 size) {
- int r = qMin(size, len);
+ qint64 read(char* target, qint64 size) {
+ qint64 r = qMin(size, len);
memcpy(target, first, r);
len -= r;
first += r;
return r;
}
- int peek(char* target, qint64 size) {
- int r = qMin(size, len);
+ qint64 peek(char* target, qint64 size) {
+ qint64 r = qMin(size, len);
memcpy(target, first, r);
return r;
}
- char* reserve(int size) {
+ char* reserve(qint64 size) {
makeSpace(size + len, freeSpaceAtEnd);
char* writePtr = first + len;
len += size;
@@ -128,16 +128,16 @@ public:
clear();
return retVal;
}
- int readLine(char* target, qint64 size) {
- int r = qMin(size, len);
+ qint64 readLine(char* target, qint64 size) {
+ qint64 r = qMin(size, len);
char* eol = static_cast<char*>(memchr(first, '\n', r));
if (eol)
r = 1+(eol-first);
memcpy(target, first, r);
len -= r;
first += r;
- return int(r);
- }
+ return r;
+ }
bool canReadLine() const {
return memchr(first, '\n', len);
}
diff --git a/src/corelib/io/qlockfile.cpp b/src/corelib/io/qlockfile.cpp
index 18a782a8f3..c256507430 100644
--- a/src/corelib/io/qlockfile.cpp
+++ b/src/corelib/io/qlockfile.cpp
@@ -287,7 +287,7 @@ bool QLockFilePrivate::getLockInfo(qint64 *pid, QString *hostname, QString *appn
appNameLine.chop(1);
QByteArray hostNameLine = reader.readLine();
hostNameLine.chop(1);
- if (pidLine.isEmpty() || appNameLine.isEmpty())
+ if (pidLine.isEmpty())
return false;
qint64 thePid = pidLine.toLongLong();
diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp
index 2fe93f0af6..3ed973494b 100644
--- a/src/corelib/io/qlockfile_unix.cpp
+++ b/src/corelib/io/qlockfile_unix.cpp
@@ -183,7 +183,7 @@ bool QLockFilePrivate::isApparentlyStale() const
QString hostname, appname;
if (!getLockInfo(&pid, &hostname, &appname))
return false;
- if (hostname == QString::fromLocal8Bit(localHostName())) {
+ if (hostname.isEmpty() || hostname == QString::fromLocal8Bit(localHostName())) {
if (::kill(pid, 0) == -1 && errno == ESRCH)
return true; // PID doesn't exist anymore
}
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index d896da176a..ebca7d57ff 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -1637,6 +1637,15 @@ bool QConfFileSettingsPrivate::readIniFile(const QByteArray &data,
int sectionPosition = 0;
bool ok = true;
+#ifndef QT_NO_TEXTCODEC
+ // detect utf8 BOM
+ const uchar *dd = (const uchar *)data.constData();
+ if (data.size() >= 3 && dd[0] == 0xef && dd[1] == 0xbb && dd[2] == 0xbf) {
+ iniCodec = QTextCodec::codecForName("UTF-8");
+ dataPos = 3;
+ }
+#endif
+
while (readIniLine(data, dataPos, lineStart, lineLen, equalsPos)) {
char ch = data.at(lineStart);
if (ch == '[') {
diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp
index 4752077f87..344bec0309 100644
--- a/src/corelib/io/qsettings_mac.cpp
+++ b/src/corelib/io/qsettings_mac.cpp
@@ -235,8 +235,10 @@ static QVariant qtValue(CFPropertyListRef cfvalue)
int i;
qint64 ll;
- if (CFNumberGetValue(cfnumber, kCFNumberIntType, &i))
+ if (CFNumberGetType(cfnumber) == kCFNumberIntType) {
+ CFNumberGetValue(cfnumber, kCFNumberIntType, &i);
return i;
+ }
CFNumberGetValue(cfnumber, kCFNumberLongLongType, &ll);
return ll;
}
diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h
index cb29b4c83a..715f13530a 100644
--- a/src/corelib/io/qsettings_p.h
+++ b/src/corelib/io/qsettings_p.h
@@ -282,7 +282,7 @@ public:
bool isWritable() const;
QString fileName() const;
- static bool readIniFile(const QByteArray &data, UnparsedSettingsMap *unparsedIniSections);
+ bool readIniFile(const QByteArray &data, UnparsedSettingsMap *unparsedIniSections);
static bool readIniSection(const QSettingsKey &section, const QByteArray &data,
ParsedSettingsMap *settingsMap, QTextCodec *codec);
static bool readIniLine(const QByteArray &data, int &dataPos, int &lineStart, int &lineLen,
diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp
index 2583e46ad8..6950d58fda 100644
--- a/src/corelib/io/qstandardpaths.cpp
+++ b/src/corelib/io/qstandardpaths.cpp
@@ -195,7 +195,7 @@ QT_BEGIN_NAMESPACE
\li "~/Library/Preferences"
\li "C:/Users/<USER>/AppData/Local", "C:/ProgramData"
\row \li DownloadLocation
- \li "~/Documents"
+ \li "~/Downloads"
\li "C:/Users/<USER>/Documents"
\row \li GenericCacheLocation
\li "~/Library/Caches", "/Library/Caches"
@@ -526,7 +526,7 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr
an empty QString if no relevant location can be found.
*/
-#if !defined(Q_OS_MAC) && !defined(QT_BOOTSTRAPPED)
+#if !defined(Q_OS_OSX) && !defined(QT_BOOTSTRAPPED)
QString QStandardPaths::displayName(StandardLocation type)
{
switch (type) {
diff --git a/src/corelib/io/qstandardpaths_ios.mm b/src/corelib/io/qstandardpaths_ios.mm
index cdca28b8b5..9b500f4623 100644
--- a/src/corelib/io/qstandardpaths_ios.mm
+++ b/src/corelib/io/qstandardpaths_ios.mm
@@ -92,6 +92,8 @@ QString QStandardPaths::writableLocation(StandardLocation type)
break;
case AppDataLocation:
case AppLocalDataLocation:
+ location = pathForDirectory(NSApplicationSupportDirectory);
+ break;
case GenericDataLocation:
location = pathForDirectory(NSDocumentDirectory);
break;
diff --git a/src/corelib/io/qstandardpaths_mac.cpp b/src/corelib/io/qstandardpaths_mac.mm
index 673b734d40..01d1c01f78 100644
--- a/src/corelib/io/qstandardpaths_mac.cpp
+++ b/src/corelib/io/qstandardpaths_mac.mm
@@ -33,6 +33,7 @@
#include "qstandardpaths.h"
#include <qdir.h>
+#include <qurl.h>
#include <private/qcore_mac_p.h>
#ifndef QT_BOOTSTRAPPED
@@ -55,8 +56,6 @@ OSType translateLocation(QStandardPaths::StandardLocation type)
return kPreferencesFolderType;
case QStandardPaths::DesktopLocation:
return kDesktopFolderType;
- case QStandardPaths::DownloadLocation: // needs NSSearchPathForDirectoriesInDomains with NSDownloadsDirectory
- // which needs an objective-C *.mm file...
case QStandardPaths::DocumentsLocation:
return kDocumentsFolderType;
case QStandardPaths::FontsLocation:
@@ -113,6 +112,15 @@ static void appendOrganizationAndApp(QString &path)
static QString macLocation(QStandardPaths::StandardLocation type, short domain)
{
+ // https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/index.html
+ if (type == QStandardPaths::DownloadLocation) {
+ NSFileManager *fileManager = [NSFileManager defaultManager];
+ NSURL *url = [fileManager URLForDirectory:NSDownloadsDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
+ if (!url)
+ return QString();
+ return QString::fromNSString([url path]);
+ }
+
// http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
FSRef ref;
OSErr err = FSFindFolder(domain, translateLocation(type), false, &ref);
diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp
index 469c223b00..2ad6dfa121 100644
--- a/src/corelib/io/qstandardpaths_unix.cpp
+++ b/src/corelib/io/qstandardpaths_unix.cpp
@@ -131,10 +131,13 @@ QString QStandardPaths::writableLocation(StandardLocation type)
return QString();
}
// "and he MUST be the only one having read and write access to it. Its Unix access mode MUST be 0700."
+ // since the current user is the owner, set both xxxUser and xxxOwner
QFile file(xdgRuntimeDir);
- const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser;
+ const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser
+ | QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner;
if (file.permissions() != wantedPerms && !file.setPermissions(wantedPerms)) {
- qWarning("QStandardPaths: wrong permissions on runtime directory %s", qPrintable(xdgRuntimeDir));
+ qWarning("QStandardPaths: could not set correct permissions on runtime directory %s: %s",
+ qPrintable(xdgRuntimeDir), qPrintable(file.errorString()));
return QString();
}
return xdgRuntimeDir;
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp
index ca5903ae36..bec7420dc7 100644
--- a/src/corelib/io/qstorageinfo_unix.cpp
+++ b/src/corelib/io/qstorageinfo_unix.cpp
@@ -90,17 +90,16 @@ static bool isPseudoFs(const QString &mountDir, const QByteArray &type)
{
if (mountDir.startsWith(QLatin1String("/dev"))
|| mountDir.startsWith(QLatin1String("/proc"))
- || mountDir.startsWith(QLatin1String("/run"))
|| mountDir.startsWith(QLatin1String("/sys"))
|| mountDir.startsWith(QLatin1String("/var/run"))
|| mountDir.startsWith(QLatin1String("/var/lock"))) {
return true;
}
+ if (type == "tmpfs")
+ return true;
#if defined(Q_OS_LINUX)
- if (type == "rootfs")
+ if (type == "rootfs" || type == "rpc_pipefs")
return true;
-#else
- Q_UNUSED(type);
#endif
return false;
diff --git a/src/corelib/io/qstorageinfo_win.cpp b/src/corelib/io/qstorageinfo_win.cpp
index 1ab34e56d4..51a268f58c 100644
--- a/src/corelib/io/qstorageinfo_win.cpp
+++ b/src/corelib/io/qstorageinfo_win.cpp
@@ -45,7 +45,7 @@
#include <QtCore/qfileinfo.h>
#include <QtCore/qvarlengtharray.h>
-#include <Windows.h>
+#include <qt_windows.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index d4c5e03058..b21e9b51e1 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -403,6 +403,7 @@
#include "qdebug.h"
#include "qhash.h"
#include "qdir.h" // for QDir::fromNativeSeparators
+#include "qdatastream.h"
#include "qtldurl_p.h"
#include "private/qipaddress_p.h"
#include "qurlquery.h"
@@ -429,6 +430,16 @@ static inline QString fileScheme()
return QStringLiteral("file");
}
+static inline QString webDavScheme()
+{
+ return QStringLiteral("webdavs");
+}
+
+static inline QString webDavSslTag()
+{
+ return QStringLiteral("@SSL");
+}
+
#ifdef Q_COMPILER_CLASS_ENUM
# define colon_uchar : uchar
#else
@@ -992,10 +1003,15 @@ inline bool QUrlPrivate::setScheme(const QString &value, int len, bool doSetErro
}
// did we set to the file protocol?
- if (scheme == fileScheme())
+ if (scheme == fileScheme()
+#ifdef Q_OS_WIN
+ || scheme == webDavScheme()
+#endif
+ ) {
flags |= IsLocalFile;
- else
+ } else {
flags &= ~IsLocalFile;
+ }
return true;
}
@@ -3738,7 +3754,7 @@ QUrl QUrl::fromLocalFile(const QString &localFile)
QUrl url;
if (localFile.isEmpty())
return url;
- url.setScheme(fileScheme());
+ QString scheme = fileScheme();
QString deslashified = QDir::fromNativeSeparators(localFile);
// magic for drives on windows
@@ -3747,13 +3763,21 @@ QUrl QUrl::fromLocalFile(const QString &localFile)
} else if (deslashified.startsWith(QLatin1String("//"))) {
// magic for shared drive on windows
int indexOfPath = deslashified.indexOf(QLatin1Char('/'), 2);
- url.setHost(deslashified.mid(2, indexOfPath - 2));
+ QString hostSpec = deslashified.mid(2, indexOfPath - 2);
+ // Check for Windows-specific WebDAV specification: "//host@SSL/path".
+ if (hostSpec.endsWith(webDavSslTag(), Qt::CaseInsensitive)) {
+ hostSpec.chop(4);
+ scheme = webDavScheme();
+ }
+ url.setHost(hostSpec);
+
if (indexOfPath > 2)
deslashified = deslashified.right(deslashified.length() - indexOfPath);
else
deslashified.clear();
}
+ url.setScheme(scheme);
url.setPath(deslashified, DecodedMode);
return url;
}
@@ -3783,8 +3807,14 @@ QString QUrl::toLocalFile() const
// magic for shared drive on windows
if (!d->host.isEmpty()) {
- tmp = QStringLiteral("//") + host() + (ourPath.length() > 0 && ourPath.at(0) != QLatin1Char('/')
- ? QLatin1Char('/') + ourPath : ourPath);
+ tmp = QStringLiteral("//") + host();
+#ifdef Q_OS_WIN // QTBUG-42346, WebDAV is visible as local file on Windows only.
+ if (scheme() == webDavScheme())
+ tmp += webDavSslTag();
+#endif
+ if (!ourPath.isEmpty() && !ourPath.startsWith(QLatin1Char('/')))
+ tmp += QLatin1Char('/');
+ tmp += ourPath;
} else {
tmp = ourPath;
#ifdef Q_OS_WIN
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp
index 74a7ea1988..a9cfa3e7ca 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -1552,13 +1552,13 @@ QAbstractItemModel::~QAbstractItemModel()
*/
/*!
- \fn void QAbstractItemModel::rowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
+ \fn void QAbstractItemModel::rowsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row)
\since 4.6
This signal is emitted after rows have been moved within the
- model. The items between \a sourceStart and \a sourceEnd
- inclusive, under the given \a sourceParent item have been moved to \a destinationParent
- starting at the row \a destinationRow.
+ model. The items between \a start and \a end
+ inclusive, under the given \a parent item have been moved to \a destination
+ starting at the row \a row.
\b{Note:} Components connected to this signal use it to adapt to changes
in the model's dimensions. It can only be emitted by the QAbstractItemModel
@@ -1584,13 +1584,13 @@ QAbstractItemModel::~QAbstractItemModel()
*/
/*!
- \fn void QAbstractItemModel::columnsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn)
+ \fn void QAbstractItemModel::columnsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column)
\since 4.6
This signal is emitted after columns have been moved within the
- model. The items between \a sourceStart and \a sourceEnd
- inclusive, under the given \a sourceParent item have been moved to \a destinationParent
- starting at the column \a destinationColumn.
+ model. The items between \a start and \a end
+ inclusive, under the given \a parent item have been moved to \a destination
+ starting at the column \a column.
\b{Note:} Components connected to this signal use it to adapt to changes
in the model's dimensions. It can only be emitted by the QAbstractItemModel
@@ -1842,7 +1842,9 @@ QMimeData *QAbstractItemModel::mimeData(const QModelIndexList &indexes) const
/*!
Returns \c{true} if a model can accept a drop of the \a data. This
- default implementation always returns \c{true}.
+ default implementation only checks if \a data has at least one format
+ in the list of mimeTypes() and if \a action is among the
+ model's supportedDropActions().
Reimplement this function in your custom model, if you want to
test whether the \a data can be dropped at \a row, \a column,
@@ -1855,12 +1857,19 @@ bool QAbstractItemModel::canDropMimeData(const QMimeData *data, Qt::DropAction a
int row, int column,
const QModelIndex &parent) const
{
- Q_UNUSED(data)
- Q_UNUSED(action)
Q_UNUSED(row)
Q_UNUSED(column)
Q_UNUSED(parent)
- return true;
+
+ if (!(action & supportedDropActions()))
+ return false;
+
+ const QStringList modelTypes = mimeTypes();
+ for (int i = 0; i < modelTypes.count(); ++i) {
+ if (data->hasFormat(modelTypes.at(i)))
+ return true;
+ }
+ return false;
}
/*!
@@ -2711,7 +2720,7 @@ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int star
persistent indexes in the model, which you would otherwise be
required to do yourself. Using beginMoveRows and endMoveRows
is an alternative to emitting layoutAboutToBeChanged and
- layoutChanged directly along with changePersistentIndexes.
+ layoutChanged directly along with changePersistentIndex.
The \a sourceParent index corresponds to the parent from which the
rows are moved; \a sourceFirst and \a sourceLast are the first and last
@@ -2978,7 +2987,7 @@ void QAbstractItemModel::endRemoveColumns()
persistent indexes in the model, which you would otherwise be
required to do yourself. Using beginMoveRows and endMoveRows
is an alternative to emitting layoutAboutToBeChanged and
- layoutChanged directly along with changePersistentIndexes.
+ layoutChanged directly along with changePersistentIndex.
The \a sourceParent index corresponds to the parent from which the
columns are moved; \a sourceFirst and \a sourceLast are the first and last
@@ -3165,11 +3174,11 @@ void QAbstractItemModel::changePersistentIndex(const QModelIndex &from, const QM
/*!
\since 4.1
- Changes the QPersistentModelIndexes that is equal to the indexes in the
+ Changes the {QPersistentModelIndex}es that are equal to the indexes in the
given \a from model index list to the given \a to model index list.
If no persistent model indexes equal to the indexes in the given \a from
- model index list was found, nothing is changed.
+ model index list are found, nothing is changed.
\sa persistentIndexList(), changePersistentIndex()
*/
diff --git a/src/corelib/itemmodels/qabstractproxymodel.cpp b/src/corelib/itemmodels/qabstractproxymodel.cpp
index ce26293183..b7f988ef7c 100644
--- a/src/corelib/itemmodels/qabstractproxymodel.cpp
+++ b/src/corelib/itemmodels/qabstractproxymodel.cpp
@@ -384,6 +384,26 @@ QMimeData* QAbstractProxyModel::mimeData(const QModelIndexList &indexes) const
return d->model->mimeData(list);
}
+void QAbstractProxyModelPrivate::mapDropCoordinatesToSource(int row, int column, const QModelIndex &parent,
+ int *sourceRow, int *sourceColumn, QModelIndex *sourceParent) const
+{
+ Q_Q(const QAbstractProxyModel);
+ *sourceRow = -1;
+ *sourceColumn = -1;
+ if (row == -1 && column == -1) {
+ *sourceParent = q->mapToSource(parent);
+ } else if (row == q->rowCount(parent)) {
+ *sourceParent = q->mapToSource(parent);
+ *sourceRow = model->rowCount(*sourceParent);
+ } else {
+ QModelIndex proxyIndex = q->index(row, column, parent);
+ QModelIndex sourceIndex = q->mapToSource(proxyIndex);
+ *sourceRow = sourceIndex.row();
+ *sourceColumn = sourceIndex.column();
+ *sourceParent = sourceIndex.parent();
+ }
+}
+
/*!
\reimp
\since 5.4
@@ -392,8 +412,11 @@ bool QAbstractProxyModel::canDropMimeData(const QMimeData *data, Qt::DropAction
int row, int column, const QModelIndex &parent) const
{
Q_D(const QAbstractProxyModel);
- const QModelIndex source = mapToSource(index(row, column, parent));
- return d->model->canDropMimeData(data, action, source.row(), source.column(), source.parent());
+ int sourceDestinationRow;
+ int sourceDestinationColumn;
+ QModelIndex sourceParent;
+ d->mapDropCoordinatesToSource(row, column, parent, &sourceDestinationRow, &sourceDestinationColumn, &sourceParent);
+ return d->model->canDropMimeData(data, action, sourceDestinationRow, sourceDestinationColumn, sourceParent);
}
/*!
@@ -404,8 +427,11 @@ bool QAbstractProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction act
int row, int column, const QModelIndex &parent)
{
Q_D(QAbstractProxyModel);
- const QModelIndex source = mapToSource(index(row, column, parent));
- return d->model->dropMimeData(data, action, source.row(), source.column(), source.parent());
+ int sourceDestinationRow;
+ int sourceDestinationColumn;
+ QModelIndex sourceParent;
+ d->mapDropCoordinatesToSource(row, column, parent, &sourceDestinationRow, &sourceDestinationColumn, &sourceParent);
+ return d->model->dropMimeData(data, action, sourceDestinationRow, sourceDestinationColumn, sourceParent);
}
/*!
diff --git a/src/corelib/itemmodels/qabstractproxymodel_p.h b/src/corelib/itemmodels/qabstractproxymodel_p.h
index 9402092fa8..24af5afc64 100644
--- a/src/corelib/itemmodels/qabstractproxymodel_p.h
+++ b/src/corelib/itemmodels/qabstractproxymodel_p.h
@@ -59,6 +59,8 @@ public:
QAbstractProxyModelPrivate() : QAbstractItemModelPrivate(), model(0) {}
QAbstractItemModel *model;
virtual void _q_sourceModelDestroyed();
+ void mapDropCoordinatesToSource(int row, int column, const QModelIndex &parent,
+ int *source_row, int *source_column, QModelIndex *source_parent) const;
};
QT_END_NAMESPACE
diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp
index db78af8cf8..5395fd5d09 100644
--- a/src/corelib/itemmodels/qitemselectionmodel.cpp
+++ b/src/corelib/itemmodels/qitemselectionmodel.cpp
@@ -1076,7 +1076,7 @@ void QItemSelectionModelPrivate::_q_layoutChanged(const QList<QPersistentModelIn
If you omit the QItemSelectionModel::Current command, a new current
selection will be created, and the previous one added to the whole
selection. All functions operate on both layers; for example,
- selectedItems() will return items from both layers.
+ \l {QTableWidget::selectedItems()}{selecteditems()} will return items from both layers.
\sa {Model/View Programming}, QAbstractItemModel, {Chart Example}
*/
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
index a95c7dc8b3..0b2b0e4188 100644
--- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
@@ -1196,11 +1196,7 @@ void QSortFilterProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &sourc
parents << q->mapFromSource(source_parent);
emit q->layoutAboutToBeChanged(parents, QAbstractItemModel::VerticalSortHint);
QModelIndexPairList source_indexes = store_persistent_indexes();
- remove_source_items(m->proxy_rows, m->source_rows, source_rows_resort,
- source_parent, Qt::Vertical, false);
- sort_source_rows(source_rows_resort, source_parent);
- insert_source_items(m->proxy_rows, m->source_rows, source_rows_resort,
- source_parent, Qt::Vertical, false);
+ sort_source_rows(m->source_rows, source_parent);
update_persistent_indexes(source_indexes);
emit q->layoutChanged(parents, QAbstractItemModel::VerticalSortHint);
// Make sure we also emit dataChanged for the rows
@@ -2034,30 +2030,14 @@ Qt::DropActions QSortFilterProxyModel::supportedDropActions() const
return d->model->supportedDropActions();
}
+// Qt6: remove unnecessary reimplementation
/*!
\reimp
*/
bool QSortFilterProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
int row, int column, const QModelIndex &parent)
{
- Q_D(QSortFilterProxyModel);
- if ((row == -1) && (column == -1))
- return d->model->dropMimeData(data, action, -1, -1, mapToSource(parent));
- int source_destination_row = -1;
- int source_destination_column = -1;
- QModelIndex source_parent;
- if (row == rowCount(parent)) {
- source_parent = mapToSource(parent);
- source_destination_row = d->model->rowCount(source_parent);
- } else {
- QModelIndex proxy_index = index(row, column, parent);
- QModelIndex source_index = mapToSource(proxy_index);
- source_destination_row = source_index.row();
- source_destination_column = source_index.column();
- source_parent = source_index.parent();
- }
- return d->model->dropMimeData(data, action, source_destination_row,
- source_destination_column, source_parent);
+ return QAbstractProxyModel::dropMimeData(data, action, row, column, parent);
}
/*!
diff --git a/src/corelib/json/qjsonarray.cpp b/src/corelib/json/qjsonarray.cpp
index fd407af2cd..73c53ea649 100644
--- a/src/corelib/json/qjsonarray.cpp
+++ b/src/corelib/json/qjsonarray.cpp
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
removing QJsonValue's from the array.
A QJsonArray can be converted to and from a QVariantList. You can query the
- number of entries with size(), insert(), and remove() entries from it
+ number of entries with size(), insert(), and removeAt() entries from it
and iterate over its content using the standard C++ iterator pattern.
QJsonArray is an implicitly shared class and shares the data with the document
diff --git a/src/corelib/json/qjsonarray.h b/src/corelib/json/qjsonarray.h
index 87d14a7703..a8307ae5aa 100644
--- a/src/corelib/json/qjsonarray.h
+++ b/src/corelib/json/qjsonarray.h
@@ -105,6 +105,7 @@ public:
typedef int difference_type;
typedef QJsonValue value_type;
typedef QJsonValueRef reference;
+ typedef QJsonValueRefPtr pointer;
inline iterator() : a(0), i(0) { }
explicit inline iterator(QJsonArray *array, int index) : a(array), i(index) { }
@@ -149,6 +150,7 @@ public:
typedef qptrdiff difference_type;
typedef QJsonValue value_type;
typedef QJsonValue reference;
+ typedef QJsonValuePtr pointer;
inline const_iterator() : a(0), i(0) { }
explicit inline const_iterator(const QJsonArray *array, int index) : a(array), i(index) { }
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 45647f2056..77900ba906 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -714,9 +714,7 @@ void QCoreApplication::init()
Q_ASSERT_X(!self, "QCoreApplication", "there should be only one application object");
QCoreApplication::self = this;
-#ifndef QT_BOOTSTRAPPED
QLoggingRegistry::instance()->init();
-#endif
#ifndef QT_NO_QOBJECT
// use the event dispatcher created by the app programmer (if any)
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index a3d00faf31..1a8bb381aa 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -307,8 +307,9 @@ static void resolveTimerAPI()
}
QEventDispatcherWin32Private::QEventDispatcherWin32Private()
- : threadId(GetCurrentThreadId()), interrupt(false), internalHwnd(0), getMessageHook(0),
- serialNumber(0), lastSerialNumber(0), sendPostedEventsWindowsTimerId(0), wakeUps(0)
+ : threadId(GetCurrentThreadId()), interrupt(false), closingDown(false), internalHwnd(0),
+ getMessageHook(0), serialNumber(0), lastSerialNumber(0), sendPostedEventsWindowsTimerId(0),
+ wakeUps(0)
{
resolveTimerAPI();
}
@@ -434,9 +435,10 @@ static inline UINT inputTimerMask()
LRESULT QT_WIN_CALLBACK qt_GetMessageHook(int code, WPARAM wp, LPARAM lp)
{
+ QEventDispatcherWin32 *q = qobject_cast<QEventDispatcherWin32 *>(QAbstractEventDispatcher::instance());
+ Q_ASSERT(q != 0);
+
if (wp == PM_REMOVE) {
- QEventDispatcherWin32 *q = qobject_cast<QEventDispatcherWin32 *>(QAbstractEventDispatcher::instance());
- Q_ASSERT(q != 0);
if (q) {
MSG *msg = (MSG *) lp;
QEventDispatcherWin32Private *d = q->d_func();
@@ -472,7 +474,7 @@ LRESULT QT_WIN_CALLBACK qt_GetMessageHook(int code, WPARAM wp, LPARAM lp)
#ifdef Q_OS_WINCE
return 0;
#else
- return CallNextHookEx(0, code, wp, lp);
+ return q->d_func()->getMessageHook ? CallNextHookEx(0, code, wp, lp) : 0;
#endif
}
@@ -643,15 +645,7 @@ void QEventDispatcherWin32::createInternalHwnd()
return;
d->internalHwnd = qt_create_internal_window(this);
-#ifndef Q_OS_WINCE
- // setup GetMessage hook needed to drive our posted events
- d->getMessageHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC) qt_GetMessageHook, NULL, GetCurrentThreadId());
- if (!d->getMessageHook) {
- int errorCode = GetLastError();
- qFatal("Qt: INTERNAL ERROR: failed to install GetMessage hook: %d, %s",
- errorCode, qPrintable(qt_error_string(errorCode)));
- }
-#endif
+ installMessageHook();
// register all socket notifiers
QList<int> sockets = (d->sn_read.keys().toSet()
@@ -665,6 +659,35 @@ void QEventDispatcherWin32::createInternalHwnd()
d->registerTimer(d->timerVec.at(i));
}
+void QEventDispatcherWin32::installMessageHook()
+{
+ Q_D(QEventDispatcherWin32);
+
+ if (d->getMessageHook)
+ return;
+
+#ifndef Q_OS_WINCE
+ // setup GetMessage hook needed to drive our posted events
+ d->getMessageHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC) qt_GetMessageHook, NULL, GetCurrentThreadId());
+ if (!d->getMessageHook) {
+ int errorCode = GetLastError();
+ qFatal("Qt: INTERNAL ERROR: failed to install GetMessage hook: %d, %s",
+ errorCode, qPrintable(qt_error_string(errorCode)));
+ }
+#endif
+}
+
+void QEventDispatcherWin32::uninstallMessageHook()
+{
+ Q_D(QEventDispatcherWin32);
+
+#ifndef Q_OS_WINCE
+ if (d->getMessageHook)
+ UnhookWindowsHookEx(d->getMessageHook);
+#endif
+ d->getMessageHook = 0;
+}
+
QEventDispatcherWin32::QEventDispatcherWin32(QObject *parent)
: QAbstractEventDispatcher(*new QEventDispatcherWin32Private, parent)
{
@@ -750,10 +773,9 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)
}
}
if (haveMessage) {
-#ifdef Q_OS_WINCE
// WinCE doesn't support hooks at all, so we have to call this by hand :(
- (void) qt_GetMessageHook(0, PM_REMOVE, (LPARAM) &msg);
-#endif
+ if (!d->getMessageHook)
+ (void) qt_GetMessageHook(0, PM_REMOVE, (LPARAM) &msg);
if (d->internalHwnd == msg.hwnd && msg.message == WM_QT_SENDPOSTEDEVENTS) {
if (seenWM_QT_SENDPOSTEDEVENTS) {
@@ -910,6 +932,11 @@ void QEventDispatcherWin32::registerTimer(int timerId, int interval, Qt::TimerTy
Q_D(QEventDispatcherWin32);
+ // exiting ... do not register new timers
+ // (QCoreApplication::closingDown() is set too late to be used here)
+ if (d->closingDown)
+ return;
+
WinTimerInfo *t = new WinTimerInfo;
t->dispatcher = this;
t->timerId = timerId;
@@ -1134,11 +1161,9 @@ void QEventDispatcherWin32::closingDown()
d->timerVec.clear();
d->timerDict.clear();
-#ifndef Q_OS_WINCE
- if (d->getMessageHook)
- UnhookWindowsHookEx(d->getMessageHook);
- d->getMessageHook = 0;
-#endif
+ d->closingDown = true;
+
+ uninstallMessageHook();
}
bool QEventDispatcherWin32::event(QEvent *e)
diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h
index 369c276615..8022299a76 100644
--- a/src/corelib/kernel/qeventdispatcher_win_p.h
+++ b/src/corelib/kernel/qeventdispatcher_win_p.h
@@ -67,6 +67,8 @@ class Q_CORE_EXPORT QEventDispatcherWin32 : public QAbstractEventDispatcher
protected:
void createInternalHwnd();
+ void installMessageHook();
+ void uninstallMessageHook();
public:
explicit QEventDispatcherWin32(QObject *parent = 0);
@@ -145,6 +147,7 @@ public:
DWORD threadId;
bool interrupt;
+ bool closingDown;
// internal window handle used for socketnotifiers/timers/etc
HWND internalHwnd;
diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp
index 452e3464d6..b179323fdc 100644
--- a/src/corelib/kernel/qjni.cpp
+++ b/src/corelib/kernel/qjni.cpp
@@ -311,7 +311,7 @@ QJNIObjectPrivate::QJNIObjectPrivate(const char *className, const char *sig, ...
}
}
-QJNIObjectPrivate::QJNIObjectPrivate(const char *className, const char *sig, va_list args)
+QJNIObjectPrivate::QJNIObjectPrivate(const char *className, const char *sig, const QVaListPrivate &args)
: d(new QJNIObjectData())
{
QJNIEnvironmentPrivate env;
@@ -369,7 +369,7 @@ QJNIObjectPrivate::QJNIObjectPrivate(jclass clazz, const char *sig, ...)
}
}
-QJNIObjectPrivate::QJNIObjectPrivate(jclass clazz, const char *sig, va_list args)
+QJNIObjectPrivate::QJNIObjectPrivate(jclass clazz, const char *sig, const QVaListPrivate &args)
: d(new QJNIObjectData())
{
QJNIEnvironmentPrivate env;
@@ -402,7 +402,7 @@ QJNIObjectPrivate::QJNIObjectPrivate(jobject obj)
}
template <>
-void QJNIObjectPrivate::callMethod<void>(const char *methodName, const char *sig, va_list args) const
+void QJNIObjectPrivate::callMethodV<void>(const char *methodName, const char *sig, va_list args) const
{
QJNIEnvironmentPrivate env;
jmethodID id = getCachedMethodID(env, d->m_jclass, methodName, sig);
@@ -416,12 +416,12 @@ void QJNIObjectPrivate::callMethod<void>(const char *methodName, const char *sig
{
va_list args;
va_start(args, sig);
- callMethod<void>(methodName, sig, args);
+ callMethodV<void>(methodName, sig, args);
va_end(args);
}
template <>
-jboolean QJNIObjectPrivate::callMethod<jboolean>(const char *methodName, const char *sig, va_list args) const
+jboolean QJNIObjectPrivate::callMethodV<jboolean>(const char *methodName, const char *sig, va_list args) const
{
QJNIEnvironmentPrivate env;
jboolean res = 0;
@@ -437,13 +437,13 @@ jboolean QJNIObjectPrivate::callMethod<jboolean>(const char *methodName, const c
{
va_list args;
va_start(args, sig);
- jboolean res = callMethod<jboolean>(methodName, sig, args);
+ jboolean res = callMethodV<jboolean>(methodName, sig, args);
va_end(args);
return res;
}
template <>
-jbyte QJNIObjectPrivate::callMethod<jbyte>(const char *methodName, const char *sig, va_list args) const
+jbyte QJNIObjectPrivate::callMethodV<jbyte>(const char *methodName, const char *sig, va_list args) const
{
QJNIEnvironmentPrivate env;
jbyte res = 0;
@@ -459,13 +459,13 @@ jbyte QJNIObjectPrivate::callMethod<jbyte>(const char *methodName, const char *s
{
va_list args;
va_start(args, sig);
- jbyte res = callMethod<jbyte>(methodName, sig, args);
+ jbyte res = callMethodV<jbyte>(methodName, sig, args);
va_end(args);
return res;
}
template <>
-jchar QJNIObjectPrivate::callMethod<jchar>(const char *methodName, const char *sig, va_list args) const
+jchar QJNIObjectPrivate::callMethodV<jchar>(const char *methodName, const char *sig, va_list args) const
{
QJNIEnvironmentPrivate env;
jchar res = 0;
@@ -481,13 +481,13 @@ jchar QJNIObjectPrivate::callMethod<jchar>(const char *methodName, const char *s
{
va_list args;
va_start(args, sig);
- jchar res = callMethod<jchar>(methodName, sig, args);
+ jchar res = callMethodV<jchar>(methodName, sig, args);
va_end(args);
return res;
}
template <>
-jshort QJNIObjectPrivate::callMethod<jshort>(const char *methodName, const char *sig, va_list args) const
+jshort QJNIObjectPrivate::callMethodV<jshort>(const char *methodName, const char *sig, va_list args) const
{
QJNIEnvironmentPrivate env;
jshort res = 0;
@@ -503,13 +503,13 @@ jshort QJNIObjectPrivate::callMethod<jshort>(const char *methodName, const char
{
va_list args;
va_start(args, sig);
- jshort res = callMethod<jshort>(methodName, sig, args);
+ jshort res = callMethodV<jshort>(methodName, sig, args);
va_end(args);
return res;
}
template <>
-jint QJNIObjectPrivate::callMethod<jint>(const char *methodName, const char *sig, va_list args) const
+jint QJNIObjectPrivate::callMethodV<jint>(const char *methodName, const char *sig, va_list args) const
{
QJNIEnvironmentPrivate env;
jint res = 0;
@@ -525,13 +525,13 @@ jint QJNIObjectPrivate::callMethod<jint>(const char *methodName, const char *sig
{
va_list args;
va_start(args, sig);
- jint res = callMethod<jint>(methodName, sig, args);
+ jint res = callMethodV<jint>(methodName, sig, args);
va_end(args);
return res;
}
template <>
-jlong QJNIObjectPrivate::callMethod<jlong>(const char *methodName, const char *sig, va_list args) const
+jlong QJNIObjectPrivate::callMethodV<jlong>(const char *methodName, const char *sig, va_list args) const
{
QJNIEnvironmentPrivate env;
jlong res = 0;
@@ -547,13 +547,13 @@ jlong QJNIObjectPrivate::callMethod<jlong>(const char *methodName, const char *s
{
va_list args;
va_start(args, sig);
- jlong res = callMethod<jlong>(methodName, sig, args);
+ jlong res = callMethodV<jlong>(methodName, sig, args);
va_end(args);
return res;
}
template <>
-jfloat QJNIObjectPrivate::callMethod<jfloat>(const char *methodName, const char *sig, va_list args) const
+jfloat QJNIObjectPrivate::callMethodV<jfloat>(const char *methodName, const char *sig, va_list args) const
{
QJNIEnvironmentPrivate env;
jfloat res = 0.f;
@@ -569,13 +569,13 @@ jfloat QJNIObjectPrivate::callMethod<jfloat>(const char *methodName, const char
{
va_list args;
va_start(args, sig);
- jfloat res = callMethod<jfloat>(methodName, sig, args);
+ jfloat res = callMethodV<jfloat>(methodName, sig, args);
va_end(args);
return res;
}
template <>
-jdouble QJNIObjectPrivate::callMethod<jdouble>(const char *methodName, const char *sig, va_list args) const
+jdouble QJNIObjectPrivate::callMethodV<jdouble>(const char *methodName, const char *sig, va_list args) const
{
QJNIEnvironmentPrivate env;
jdouble res = 0.;
@@ -591,7 +591,7 @@ jdouble QJNIObjectPrivate::callMethod<jdouble>(const char *methodName, const cha
{
va_list args;
va_start(args, sig);
- jdouble res = callMethod<jdouble>(methodName, sig, args);
+ jdouble res = callMethodV<jdouble>(methodName, sig, args);
va_end(args);
return res;
}
@@ -651,10 +651,10 @@ jdouble QJNIObjectPrivate::callMethod<jdouble>(const char *methodName) const
}
template <>
-void QJNIObjectPrivate::callStaticMethod<void>(const char *className,
- const char *methodName,
- const char *sig,
- va_list args)
+void QJNIObjectPrivate::callStaticMethodV<void>(const char *className,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jclass clazz = loadClass(className, env);
@@ -674,15 +674,15 @@ void QJNIObjectPrivate::callStaticMethod<void>(const char *className,
{
va_list args;
va_start(args, sig);
- callStaticMethod<void>(className, methodName, sig, args);
+ callStaticMethodV<void>(className, methodName, sig, args);
va_end(args);
}
template <>
-void QJNIObjectPrivate::callStaticMethod<void>(jclass clazz,
- const char *methodName,
- const char *sig,
- va_list args)
+void QJNIObjectPrivate::callStaticMethodV<void>(jclass clazz,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jmethodID id = getCachedMethodID(env, clazz, methodName, sig, true);
@@ -699,15 +699,15 @@ void QJNIObjectPrivate::callStaticMethod<void>(jclass clazz,
{
va_list args;
va_start(args, sig);
- callStaticMethod<void>(clazz, methodName, sig, args);
+ callStaticMethodV<void>(clazz, methodName, sig, args);
va_end(args);
}
template <>
-jboolean QJNIObjectPrivate::callStaticMethod<jboolean>(const char *className,
- const char *methodName,
- const char *sig,
- va_list args)
+jboolean QJNIObjectPrivate::callStaticMethodV<jboolean>(const char *className,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jboolean res = 0;
@@ -730,16 +730,16 @@ jboolean QJNIObjectPrivate::callStaticMethod<jboolean>(const char *className,
{
va_list args;
va_start(args, sig);
- jboolean res = callStaticMethod<jboolean>(className, methodName, sig, args);
+ jboolean res = callStaticMethodV<jboolean>(className, methodName, sig, args);
va_end(args);
return res;
}
template <>
-jboolean QJNIObjectPrivate::callStaticMethod<jboolean>(jclass clazz,
- const char *methodName,
- const char *sig,
- va_list args)
+jboolean QJNIObjectPrivate::callStaticMethodV<jboolean>(jclass clazz,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jboolean res = 0;
@@ -759,16 +759,16 @@ jboolean QJNIObjectPrivate::callStaticMethod<jboolean>(jclass clazz,
{
va_list args;
va_start(args, sig);
- jboolean res = callStaticMethod<jboolean>(clazz, methodName, sig, args);
+ jboolean res = callStaticMethodV<jboolean>(clazz, methodName, sig, args);
va_end(args);
return res;
}
template <>
-jbyte QJNIObjectPrivate::callStaticMethod<jbyte>(const char *className,
- const char *methodName,
- const char *sig,
- va_list args)
+jbyte QJNIObjectPrivate::callStaticMethodV<jbyte>(const char *className,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jbyte res = 0;
@@ -791,16 +791,16 @@ jbyte QJNIObjectPrivate::callStaticMethod<jbyte>(const char *className,
{
va_list args;
va_start(args, sig);
- jbyte res = callStaticMethod<jbyte>(className, methodName, sig, args);
+ jbyte res = callStaticMethodV<jbyte>(className, methodName, sig, args);
va_end(args);
return res;
}
template <>
-jbyte QJNIObjectPrivate::callStaticMethod<jbyte>(jclass clazz,
- const char *methodName,
- const char *sig,
- va_list args)
+jbyte QJNIObjectPrivate::callStaticMethodV<jbyte>(jclass clazz,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jbyte res = 0;
@@ -820,16 +820,16 @@ jbyte QJNIObjectPrivate::callStaticMethod<jbyte>(jclass clazz,
{
va_list args;
va_start(args, sig);
- jbyte res = callStaticMethod<jbyte>(clazz, methodName, sig, args);
+ jbyte res = callStaticMethodV<jbyte>(clazz, methodName, sig, args);
va_end(args);
return res;
}
template <>
-jchar QJNIObjectPrivate::callStaticMethod<jchar>(const char *className,
- const char *methodName,
- const char *sig,
- va_list args)
+jchar QJNIObjectPrivate::callStaticMethodV<jchar>(const char *className,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jchar res = 0;
@@ -852,16 +852,16 @@ jchar QJNIObjectPrivate::callStaticMethod<jchar>(const char *className,
{
va_list args;
va_start(args, sig);
- jchar res = callStaticMethod<jchar>(className, methodName, sig, args);
+ jchar res = callStaticMethodV<jchar>(className, methodName, sig, args);
va_end(args);
return res;
}
template <>
-jchar QJNIObjectPrivate::callStaticMethod<jchar>(jclass clazz,
- const char *methodName,
- const char *sig,
- va_list args)
+jchar QJNIObjectPrivate::callStaticMethodV<jchar>(jclass clazz,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jchar res = 0;
@@ -881,16 +881,16 @@ jchar QJNIObjectPrivate::callStaticMethod<jchar>(jclass clazz,
{
va_list args;
va_start(args, sig);
- jchar res = callStaticMethod<jchar>(clazz, methodName, sig, args);
+ jchar res = callStaticMethodV<jchar>(clazz, methodName, sig, args);
va_end(args);
return res;
}
template <>
-jshort QJNIObjectPrivate::callStaticMethod<jshort>(const char *className,
- const char *methodName,
- const char *sig,
- va_list args)
+jshort QJNIObjectPrivate::callStaticMethodV<jshort>(const char *className,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jshort res = 0;
@@ -913,16 +913,16 @@ jshort QJNIObjectPrivate::callStaticMethod<jshort>(const char *className,
{
va_list args;
va_start(args, sig);
- jshort res = callStaticMethod<jshort>(className, methodName, sig, args);
+ jshort res = callStaticMethodV<jshort>(className, methodName, sig, args);
va_end(args);
return res;
}
template <>
-jshort QJNIObjectPrivate::callStaticMethod<jshort>(jclass clazz,
- const char *methodName,
- const char *sig,
- va_list args)
+jshort QJNIObjectPrivate::callStaticMethodV<jshort>(jclass clazz,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jshort res = 0;
@@ -942,16 +942,16 @@ jshort QJNIObjectPrivate::callStaticMethod<jshort>(jclass clazz,
{
va_list args;
va_start(args, sig);
- jshort res = callStaticMethod<jshort>(clazz, methodName, sig, args);
+ jshort res = callStaticMethodV<jshort>(clazz, methodName, sig, args);
va_end(args);
return res;
}
template <>
-jint QJNIObjectPrivate::callStaticMethod<jint>(const char *className,
- const char *methodName,
- const char *sig,
- va_list args)
+jint QJNIObjectPrivate::callStaticMethodV<jint>(const char *className,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jint res = 0;
@@ -974,16 +974,16 @@ jint QJNIObjectPrivate::callStaticMethod<jint>(const char *className,
{
va_list args;
va_start(args, sig);
- jint res = callStaticMethod<jint>(className, methodName, sig, args);
+ jint res = callStaticMethodV<jint>(className, methodName, sig, args);
va_end(args);
return res;
}
template <>
-jint QJNIObjectPrivate::callStaticMethod<jint>(jclass clazz,
- const char *methodName,
- const char *sig,
- va_list args)
+jint QJNIObjectPrivate::callStaticMethodV<jint>(jclass clazz,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jint res = 0;
@@ -1003,16 +1003,16 @@ jint QJNIObjectPrivate::callStaticMethod<jint>(jclass clazz,
{
va_list args;
va_start(args, sig);
- jint res = callStaticMethod<jint>(clazz, methodName, sig, args);
+ jint res = callStaticMethodV<jint>(clazz, methodName, sig, args);
va_end(args);
return res;
}
template <>
-jlong QJNIObjectPrivate::callStaticMethod<jlong>(const char *className,
- const char *methodName,
- const char *sig,
- va_list args)
+jlong QJNIObjectPrivate::callStaticMethodV<jlong>(const char *className,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jlong res = 0;
@@ -1035,16 +1035,16 @@ jlong QJNIObjectPrivate::callStaticMethod<jlong>(const char *className,
{
va_list args;
va_start(args, sig);
- jlong res = callStaticMethod<jlong>(className, methodName, sig, args);
+ jlong res = callStaticMethodV<jlong>(className, methodName, sig, args);
va_end(args);
return res;
}
template <>
-jlong QJNIObjectPrivate::callStaticMethod<jlong>(jclass clazz,
- const char *methodName,
- const char *sig,
- va_list args)
+jlong QJNIObjectPrivate::callStaticMethodV<jlong>(jclass clazz,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jlong res = 0;
@@ -1064,16 +1064,16 @@ jlong QJNIObjectPrivate::callStaticMethod<jlong>(jclass clazz,
{
va_list args;
va_start(args, sig);
- jlong res = callStaticMethod<jlong>(clazz, methodName, sig, args);
+ jlong res = callStaticMethodV<jlong>(clazz, methodName, sig, args);
va_end(args);
return res;
}
template <>
-jfloat QJNIObjectPrivate::callStaticMethod<jfloat>(const char *className,
- const char *methodName,
- const char *sig,
- va_list args)
+jfloat QJNIObjectPrivate::callStaticMethodV<jfloat>(const char *className,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jfloat res = 0.f;
@@ -1096,16 +1096,16 @@ jfloat QJNIObjectPrivate::callStaticMethod<jfloat>(const char *className,
{
va_list args;
va_start(args, sig);
- jfloat res = callStaticMethod<jfloat>(className, methodName, sig, args);
+ jfloat res = callStaticMethodV<jfloat>(className, methodName, sig, args);
va_end(args);
return res;
}
template <>
-jfloat QJNIObjectPrivate::callStaticMethod<jfloat>(jclass clazz,
- const char *methodName,
- const char *sig,
- va_list args)
+jfloat QJNIObjectPrivate::callStaticMethodV<jfloat>(jclass clazz,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jfloat res = 0.f;
@@ -1125,16 +1125,16 @@ jfloat QJNIObjectPrivate::callStaticMethod<jfloat>(jclass clazz,
{
va_list args;
va_start(args, sig);
- jfloat res = callStaticMethod<jfloat>(clazz, methodName, sig, args);
+ jfloat res = callStaticMethodV<jfloat>(clazz, methodName, sig, args);
va_end(args);
return res;
}
template <>
-jdouble QJNIObjectPrivate::callStaticMethod<jdouble>(const char *className,
- const char *methodName,
- const char *sig,
- va_list args)
+jdouble QJNIObjectPrivate::callStaticMethodV<jdouble>(const char *className,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jdouble res = 0.;
@@ -1157,16 +1157,16 @@ jdouble QJNIObjectPrivate::callStaticMethod<jdouble>(const char *className,
{
va_list args;
va_start(args, sig);
- jdouble res = callStaticMethod<jdouble>(className, methodName, sig, args);
+ jdouble res = callStaticMethodV<jdouble>(className, methodName, sig, args);
va_end(args);
return res;
}
template <>
-jdouble QJNIObjectPrivate::callStaticMethod<jdouble>(jclass clazz,
- const char *methodName,
- const char *sig,
- va_list args)
+jdouble QJNIObjectPrivate::callStaticMethodV<jdouble>(jclass clazz,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jdouble res = 0.;
@@ -1186,7 +1186,7 @@ jdouble QJNIObjectPrivate::callStaticMethod<jdouble>(jclass clazz,
{
va_list args;
va_start(args, sig);
- jdouble res = callStaticMethod<jdouble>(clazz, methodName, sig, args);
+ jdouble res = callStaticMethodV<jdouble>(clazz, methodName, sig, args);
va_end(args);
return res;
}
@@ -1299,9 +1299,9 @@ jdouble QJNIObjectPrivate::callStaticMethod<jdouble>(jclass clazz, const char *m
return callStaticMethod<jdouble>(clazz, methodName, "()D");
}
-QJNIObjectPrivate QJNIObjectPrivate::callObjectMethod(const char *methodName,
- const char *sig,
- va_list args) const
+QJNIObjectPrivate QJNIObjectPrivate::callObjectMethodV(const char *methodName,
+ const char *sig,
+ va_list args) const
{
QJNIEnvironmentPrivate env;
jobject res = 0;
@@ -1323,7 +1323,7 @@ QJNIObjectPrivate QJNIObjectPrivate::callObjectMethod(const char *methodName,
{
va_list args;
va_start(args, sig);
- QJNIObjectPrivate res = callObjectMethod(methodName, sig, args);
+ QJNIObjectPrivate res = callObjectMethodV(methodName, sig, args);
va_end(args);
return res;
}
@@ -1376,10 +1376,10 @@ QJNIObjectPrivate QJNIObjectPrivate::callObjectMethod<jdoubleArray>(const char *
return callObjectMethod(methodName, "()[D");
}
-QJNIObjectPrivate QJNIObjectPrivate::callStaticObjectMethod(const char *className,
- const char *methodName,
- const char *sig,
- va_list args)
+QJNIObjectPrivate QJNIObjectPrivate::callStaticObjectMethodV(const char *className,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jobject res = 0;
@@ -1405,15 +1405,15 @@ QJNIObjectPrivate QJNIObjectPrivate::callStaticObjectMethod(const char *classNam
{
va_list args;
va_start(args, sig);
- QJNIObjectPrivate res = callStaticObjectMethod(className, methodName, sig, args);
+ QJNIObjectPrivate res = callStaticObjectMethodV(className, methodName, sig, args);
va_end(args);
return res;
}
-QJNIObjectPrivate QJNIObjectPrivate::callStaticObjectMethod(jclass clazz,
- const char *methodName,
- const char *sig,
- va_list args)
+QJNIObjectPrivate QJNIObjectPrivate::callStaticObjectMethodV(jclass clazz,
+ const char *methodName,
+ const char *sig,
+ va_list args)
{
QJNIEnvironmentPrivate env;
jobject res = 0;
@@ -1436,7 +1436,7 @@ QJNIObjectPrivate QJNIObjectPrivate::callStaticObjectMethod(jclass clazz,
{
va_list args;
va_start(args, sig);
- QJNIObjectPrivate res = callStaticObjectMethod(clazz, methodName, sig, args);
+ QJNIObjectPrivate res = callStaticObjectMethodV(clazz, methodName, sig, args);
va_end(args);
return res;
}
diff --git a/src/corelib/kernel/qjni_p.h b/src/corelib/kernel/qjni_p.h
index 19f2cf7601..5f573624c6 100644
--- a/src/corelib/kernel/qjni_p.h
+++ b/src/corelib/kernel/qjni_p.h
@@ -186,31 +186,37 @@ public:
private:
friend class QAndroidJniObject;
- QJNIObjectPrivate(const char *className, const char *sig, va_list args);
- QJNIObjectPrivate(jclass clazz, const char *sig, va_list args);
+ struct QVaListPrivate { operator va_list &() const { return m_args; } va_list &m_args; };
+
+ QJNIObjectPrivate(const char *className, const char *sig, const QVaListPrivate &args);
+ QJNIObjectPrivate(jclass clazz, const char *sig, const QVaListPrivate &args);
template <typename T>
- T callMethod(const char *methodName,
- const char *sig,
- va_list args) const;
- QJNIObjectPrivate callObjectMethod(const char *methodName,
- const char *sig,
- va_list args) const;
+ T callMethodV(const char *methodName,
+ const char *sig,
+ va_list args) const;
+ QJNIObjectPrivate callObjectMethodV(const char *methodName,
+ const char *sig,
+ va_list args) const;
template <typename T>
- static T callStaticMethod(const char *className,
- const char *methodName,
- const char *sig, va_list args);
+ static T callStaticMethodV(const char *className,
+ const char *methodName,
+ const char *sig,
+ va_list args);
template <typename T>
- static T callStaticMethod(jclass clazz,
- const char *methodName,
- const char *sig, va_list args);
- static QJNIObjectPrivate callStaticObjectMethod(const char *className,
- const char *methodName,
- const char *sig, va_list args);
-
- static QJNIObjectPrivate callStaticObjectMethod(jclass clazz,
- const char *methodName,
- const char *sig, va_list args);
+ static T callStaticMethodV(jclass clazz,
+ const char *methodName,
+ const char *sig,
+ va_list args);
+ static QJNIObjectPrivate callStaticObjectMethodV(const char *className,
+ const char *methodName,
+ const char *sig,
+ va_list args);
+
+ static QJNIObjectPrivate callStaticObjectMethodV(jclass clazz,
+ const char *methodName,
+ const char *sig,
+ va_list args);
bool isSameObject(jobject obj) const;
bool isSameObject(const QJNIObjectPrivate &other) const;
diff --git a/src/corelib/kernel/qjnihelpers.cpp b/src/corelib/kernel/qjnihelpers.cpp
index c82b5ca033..d3bbce305a 100644
--- a/src/corelib/kernel/qjnihelpers.cpp
+++ b/src/corelib/kernel/qjnihelpers.cpp
@@ -34,6 +34,7 @@
#include "qjnihelpers_p.h"
#include "qmutex.h"
#include "qlist.h"
+#include <QtCore/qrunnable.h>
QT_BEGIN_NAMESPACE
@@ -41,6 +42,19 @@ static JavaVM *g_javaVM = Q_NULLPTR;
static jobject g_jActivity = Q_NULLPTR;
static jobject g_jClassLoader = Q_NULLPTR;
static jint g_androidSdkVersion = 0;
+static jclass g_jNativeClass = Q_NULLPTR;
+static jmethodID g_runQtOnUiThreadMethodID = Q_NULLPTR;
+
+static void onAndroidUiThread(JNIEnv *, jclass, jlong thiz)
+{
+ QRunnable *runnable = reinterpret_cast<QRunnable *>(thiz);
+ if (runnable == 0)
+ return;
+
+ runnable->run();
+ if (runnable->autoDelete())
+ delete runnable;
+}
namespace {
class ActivityResultListeners
@@ -140,6 +154,22 @@ jint QtAndroidPrivate::initJNI(JavaVM *vm, JNIEnv *env)
env->DeleteLocalRef(activity);
g_javaVM = vm;
+ static const JNINativeMethod methods[] = {
+ {"onAndroidUiThread", "(J)V", reinterpret_cast<void *>(onAndroidUiThread)}
+ };
+
+ const bool regOk = (env->RegisterNatives(jQtNative, methods, sizeof(methods) / sizeof(methods[0])) == JNI_OK);
+
+ if (!regOk && exceptionCheck(env))
+ return JNI_ERR;
+
+ g_runQtOnUiThreadMethodID = env->GetStaticMethodID(jQtNative,
+ "runQtOnUiThread",
+ "(J)V");
+
+ g_jNativeClass = static_cast<jclass>(env->NewGlobalRef(jQtNative));
+ env->DeleteLocalRef(jQtNative);
+
return JNI_OK;
}
@@ -164,4 +194,12 @@ jint QtAndroidPrivate::androidSdkVersion()
return g_androidSdkVersion;
}
+void QtAndroidPrivate::runOnUiThread(QRunnable *runnable, JNIEnv *env)
+{
+ Q_ASSERT(runnable != 0);
+ env->CallStaticVoidMethod(g_jNativeClass, g_runQtOnUiThreadMethodID, reinterpret_cast<jlong>(runnable));
+ if (exceptionCheck(env) && runnable != 0 && runnable->autoDelete())
+ delete runnable;
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qjnihelpers_p.h b/src/corelib/kernel/qjnihelpers_p.h
index 80c50ba611..6456dce4c4 100644
--- a/src/corelib/kernel/qjnihelpers_p.h
+++ b/src/corelib/kernel/qjnihelpers_p.h
@@ -50,6 +50,8 @@
QT_BEGIN_NAMESPACE
+class QRunnable;
+
namespace QtAndroidPrivate
{
class Q_CORE_EXPORT ActivityResultListener
@@ -64,6 +66,7 @@ namespace QtAndroidPrivate
Q_CORE_EXPORT jint initJNI(JavaVM *vm, JNIEnv *env);
jobject classLoader();
Q_CORE_EXPORT jint androidSdkVersion();
+ Q_CORE_EXPORT void runOnUiThread(QRunnable *runnable, JNIEnv *env);
Q_CORE_EXPORT void handleActivityResult(jint requestCode, jint resultCode, jobject data);
Q_CORE_EXPORT void registerActivityResultListener(ActivityResultListener *listener);
diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h
index e68b899280..1faead8495 100644
--- a/src/corelib/kernel/qmetaobject.h
+++ b/src/corelib/kernel/qmetaobject.h
@@ -48,7 +48,7 @@ template <typename T> class QList;
class Q_CORE_EXPORT QMetaMethod
{
public:
- inline QMetaMethod() : mobj(0),handle(0) {}
+ Q_DECL_CONSTEXPR inline QMetaMethod() : mobj(0),handle(0) {}
QByteArray methodSignature() const;
QByteArray name() const;
@@ -204,7 +204,7 @@ inline bool operator!=(const QMetaMethod &m1, const QMetaMethod &m2)
class Q_CORE_EXPORT QMetaEnum
{
public:
- inline QMetaEnum() : mobj(0),handle(0) {}
+ Q_DECL_CONSTEXPR inline QMetaEnum() : mobj(0),handle(0) {}
const char *name() const;
bool isFlag() const;
@@ -286,7 +286,7 @@ private:
class Q_CORE_EXPORT QMetaClassInfo
{
public:
- inline QMetaClassInfo() : mobj(0),handle(0) {}
+ Q_DECL_CONSTEXPR inline QMetaClassInfo() : mobj(0),handle(0) {}
const char *name() const;
const char *value() const;
inline const QMetaObject *enclosingMetaObject() const { return mobj; }
diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp
index 5c185e1d62..3b1d808520 100644
--- a/src/corelib/kernel/qsystemerror.cpp
+++ b/src/corelib/kernel/qsystemerror.cpp
@@ -61,11 +61,11 @@ namespace {
// version in portable code. However, it's impossible to do that if
// _GNU_SOURCE is defined so we use C++ overloading to decide what to do
// depending on the return type
- static inline QString fromstrerror_helper(int, const QByteArray &buf)
+ static inline Q_DECL_UNUSED QString fromstrerror_helper(int, const QByteArray &buf)
{
return QString::fromLocal8Bit(buf);
}
- static inline QString fromstrerror_helper(const char *str, const QByteArray &)
+ static inline Q_DECL_UNUSED QString fromstrerror_helper(const char *str, const QByteArray &)
{
return QString::fromLocal8Bit(str);
}
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index 5687a6c3a3..a2cf4a7813 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -427,9 +427,8 @@ QTranslator::~QTranslator()
directory. Returns \c true if the translation is successfully loaded;
otherwise returns \c false.
- If \a directory is not specified, the directory of the
- application's executable is used (i.e., as
- \l{QCoreApplication::}{applicationDirPath()}).
+ If \a directory is not specified, the current directory is used
+ (i.e., as \l{QDir::}{currentPath()}).
The previous contents of this translator object are discarded.
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index 57e0523f7c..7dce813bb5 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -703,14 +703,15 @@ namespace QtPrivate {
{
static QSequentialIterable invoke(const QVariant &v)
{
- if (v.userType() == qMetaTypeId<QVariantList>()) {
+ const int typeId = v.userType();
+ if (typeId == qMetaTypeId<QVariantList>()) {
return QSequentialIterable(QtMetaTypePrivate::QSequentialIterableImpl(reinterpret_cast<const QVariantList*>(v.constData())));
}
- if (v.userType() == qMetaTypeId<QStringList>()) {
+ if (typeId == qMetaTypeId<QStringList>()) {
return QSequentialIterable(QtMetaTypePrivate::QSequentialIterableImpl(reinterpret_cast<const QStringList*>(v.constData())));
}
#ifndef QT_BOOTSTRAPPED
- if (v.userType() == qMetaTypeId<QByteArrayList>()) {
+ if (typeId == qMetaTypeId<QByteArrayList>()) {
return QSequentialIterable(QtMetaTypePrivate::QSequentialIterableImpl(reinterpret_cast<const QByteArrayList*>(v.constData())));
}
#endif
@@ -722,10 +723,11 @@ namespace QtPrivate {
{
static QAssociativeIterable invoke(const QVariant &v)
{
- if (v.userType() == qMetaTypeId<QVariantMap>()) {
+ const int typeId = v.userType();
+ if (typeId == qMetaTypeId<QVariantMap>()) {
return QAssociativeIterable(QtMetaTypePrivate::QAssociativeIterableImpl(reinterpret_cast<const QVariantMap*>(v.constData())));
}
- if (v.userType() == qMetaTypeId<QVariantHash>()) {
+ if (typeId == qMetaTypeId<QVariantHash>()) {
return QAssociativeIterable(QtMetaTypePrivate::QAssociativeIterableImpl(reinterpret_cast<const QVariantHash*>(v.constData())));
}
return QAssociativeIterable(v.value<QtMetaTypePrivate::QAssociativeIterableImpl>());
@@ -736,7 +738,8 @@ namespace QtPrivate {
{
static QVariantList invoke(const QVariant &v)
{
- if (QtMetaTypePrivate::isBuiltinSequentialType(v.userType()) || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>())) {
+ const int typeId = v.userType();
+ if (QtMetaTypePrivate::isBuiltinSequentialType(typeId) || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>())) {
QSequentialIterable iter = QVariantValueHelperInterface<QSequentialIterable>::invoke(v);
QVariantList l;
l.reserve(iter.size());
@@ -752,7 +755,8 @@ namespace QtPrivate {
{
static QVariantHash invoke(const QVariant &v)
{
- if (QtMetaTypePrivate::isBuiltinAssociativeType(v.userType()) || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>())) {
+ const int typeId = v.userType();
+ if (QtMetaTypePrivate::isBuiltinAssociativeType(typeId) || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>())) {
QAssociativeIterable iter = QVariantValueHelperInterface<QAssociativeIterable>::invoke(v);
QVariantHash l;
l.reserve(iter.size());
@@ -768,7 +772,8 @@ namespace QtPrivate {
{
static QVariantMap invoke(const QVariant &v)
{
- if (QtMetaTypePrivate::isBuiltinAssociativeType(v.userType()) || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>())) {
+ const int typeId = v.userType();
+ if (QtMetaTypePrivate::isBuiltinAssociativeType(typeId) || QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>())) {
QAssociativeIterable iter = QVariantValueHelperInterface<QAssociativeIterable>::invoke(v);
QVariantMap l;
for (QAssociativeIterable::const_iterator it = iter.begin(), end = iter.end(); it != end; ++it)
@@ -783,10 +788,11 @@ namespace QtPrivate {
{
static QPair<QVariant, QVariant> invoke(const QVariant &v)
{
- if (v.userType() == qMetaTypeId<QPair<QVariant, QVariant> >())
+ const int typeId = v.userType();
+ if (typeId == qMetaTypeId<QPair<QVariant, QVariant> >())
return QVariantValueHelper<QPair<QVariant, QVariant> >::invoke(v);
- if (QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QPairVariantInterfaceImpl>())) {
+ if (QMetaType::hasRegisteredConverterFunction(typeId, qMetaTypeId<QtMetaTypePrivate::QPairVariantInterfaceImpl>())) {
QtMetaTypePrivate::QPairVariantInterfaceImpl pi = v.value<QtMetaTypePrivate::QPairVariantInterfaceImpl>();
const QtMetaTypePrivate::VariantData d1 = pi.first();
diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp
index 9d14e5f90b..c5103ebe59 100644
--- a/src/corelib/mimetypes/qmimedatabase.cpp
+++ b/src/corelib/mimetypes/qmimedatabase.cpp
@@ -248,7 +248,7 @@ bool QMimeDatabasePrivate::inherits(const QString &mime, const QString &parent)
\endcode
On a typical Unix system, this will be /usr/share/mime/packages/, but it is also
possible to extend the list of directories by setting the environment variable
- XDG_DATA_DIRS. For instance adding /opt/myapp/share to XDG_DATA_DIRS will result
+ \c XDG_DATA_DIRS. For instance adding /opt/myapp/share to \c XDG_DATA_DIRS will result
in /opt/myapp/share/mime/packages/ being searched for MIME definitions.
Here is an example of MIME XML:
@@ -575,7 +575,7 @@ QMimeType QMimeDatabase::mimeTypeForFileNameAndData(const QString &fileName, con
This can be useful for showing all MIME types to the user, for instance
in a MIME type editor. Do not use unless really necessary in other cases
- though, prefer using the mimeTypeFor* methods for performance reasons.
+ though, prefer using the \l {mimeTypeForData()}{mimeTypeForXxx()} methods for performance reasons.
*/
QList<QMimeType> QMimeDatabase::allMimeTypes() const
{
diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp
index d1bf27eae0..1ad2a449c1 100644
--- a/src/corelib/mimetypes/qmimetype.cpp
+++ b/src/corelib/mimetypes/qmimetype.cpp
@@ -89,8 +89,8 @@ void QMimeTypePrivate::addGlobPattern(const QString &pattern)
Determining the MIME type of a file can be useful to make sure your
application supports it. It is also useful in file-manager-like applications
- or widgets, in order to display an appropriate icon() for the file, or even
- the descriptive comment() in detailed views.
+ or widgets, in order to display an appropriate \l {QMimeType::iconName}{icon} for the file, or even
+ the descriptive \l {QMimeType::comment()}{comment} in detailed views.
To check if a file has the expected MIME type, you should use inherits()
rather than a simple string comparison based on the name(). This is because
diff --git a/src/corelib/plugin/qplugin.h b/src/corelib/plugin/qplugin.h
index 4e9a60504a..c424344c3a 100644
--- a/src/corelib/plugin/qplugin.h
+++ b/src/corelib/plugin/qplugin.h
@@ -71,7 +71,7 @@ Q_DECLARE_TYPEINFO(QStaticPlugin, Q_PRIMITIVE_TYPE);
void Q_CORE_EXPORT qRegisterStaticPluginFunction(QStaticPlugin staticPlugin);
-#if defined (Q_OF_ELF) && (defined (Q_CC_GNU) || defined(Q_CC_CLANG))
+#if (defined(Q_OF_ELF) || defined(Q_OS_WIN)) && (defined (Q_CC_GNU) || defined(Q_CC_CLANG))
# define QT_PLUGIN_METADATA_SECTION \
__attribute__ ((section (".qtmetadata"))) __attribute__((used))
#elif defined(Q_OS_MAC)
diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h
index 09500e92d7..be293f58e3 100644
--- a/src/corelib/thread/qbasicatomic.h
+++ b/src/corelib/thread/qbasicatomic.h
@@ -84,13 +84,9 @@ QT_END_NAMESPACE
// New atomics
#if defined(Q_COMPILER_CONSTEXPR) && defined(Q_COMPILER_DEFAULT_MEMBERS) && defined(Q_COMPILER_DELETE_MEMBERS)
-# if defined(Q_CC_CLANG) && ((((__clang_major__ * 100) + __clang_minor__) < 303) \
- || defined(__apple_build_version__) \
- )
- /* Do not define QT_BASIC_ATOMIC_HAS_CONSTRUCTORS for "stock" clang before version 3.3.
- Apple's version has different (higher!) version numbers, so disable it for all of them for now.
- (The only way to distinguish between them seems to be a check for __apple_build_version__ .)
-
+# if defined(Q_CC_CLANG) && Q_CC_CLANG < 303
+ /*
+ Do not define QT_BASIC_ATOMIC_HAS_CONSTRUCTORS for Clang before version 3.3.
For details about the bug: see http://llvm.org/bugs/show_bug.cgi?id=12670
*/
# else
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 625b78d001..36acfc4c09 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -785,7 +785,7 @@ static inline char qToLower(char c)
occurrences of a particular value with another, use one of the
two-parameter replace() overloads.
- QByteArrays can be compared using overloaded operators such as
+ {QByteArray}s can be compared using overloaded operators such as
operator<(), operator<=(), operator==(), operator>=(), and so on.
The comparison is based exclusively on the numeric values
of the characters and is very fast, but is not what a human would
@@ -830,7 +830,7 @@ static inline char qToLower(char c)
lastIndexOf(), operator<(), operator<=(), operator>(),
operator>=(), toLower() and toUpper().
- This issue does not apply to QStrings since they represent
+ This issue does not apply to {QString}s since they represent
characters using Unicode.
\sa QString, QBitArray
@@ -3203,6 +3203,7 @@ QDataStream &operator>>(QDataStream &in, QByteArray &ba)
replaced with a single space.
Whitespace means any character for which the standard C++
+ \c isspace() function returns \c true in the C locale. This includes the ASCII
isspace() function returns \c true in the C locale. This includes the ASCII
characters '\\t', '\\n', '\\v', '\\f', '\\r', and ' '.
@@ -3228,13 +3229,13 @@ QByteArray QByteArray::simplified_helper(QByteArray &a)
and the end.
Whitespace means any character for which the standard C++
- isspace() function returns \c true in the C locale. This includes the ASCII
+ \c isspace() function returns \c true in the C locale. This includes the ASCII
characters '\\t', '\\n', '\\v', '\\f', '\\r', and ' '.
Example:
\snippet code/src_corelib_tools_qbytearray.cpp 33
- Unlike simplified(), trimmed() leaves internal whitespace alone.
+ Unlike simplified(), \l {QByteArray::trimmed()}{trimmed()} leaves internal whitespace alone.
\sa simplified()
*/
diff --git a/src/corelib/tools/qbytearraylist.h b/src/corelib/tools/qbytearraylist.h
index 9d7e776028..dd84ec642c 100644
--- a/src/corelib/tools/qbytearraylist.h
+++ b/src/corelib/tools/qbytearraylist.h
@@ -63,6 +63,7 @@ class QByteArrayList : public QList<QByteArray>
template <> struct QListSpecialMethods<QByteArray>
#endif
{
+public:
inline QByteArray join() const
{ return QtPrivate::QByteArrayList_join(self(), 0, 0); }
inline QByteArray join(const QByteArray &sep) const
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index ec1e78c358..5bcd01a587 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -118,7 +118,8 @@ QT_DEPRECATED inline bool setYMD(int y, int m, int d)
inline qint64 toJulianDay() const { return jd; }
private:
- static inline qint64 nullJd() { return std::numeric_limits<qint64>::min(); }
+ // using extra parentheses around min to avoid expanding it if it is a macro
+ static inline qint64 nullJd() { return (std::numeric_limits<qint64>::min)(); }
static inline qint64 minJd() { return Q_INT64_C(-784350574879); }
static inline qint64 maxJd() { return Q_INT64_C( 784354017364); }
diff --git a/src/corelib/tools/qelapsedtimer.h b/src/corelib/tools/qelapsedtimer.h
index d72a50f127..d21081f815 100644
--- a/src/corelib/tools/qelapsedtimer.h
+++ b/src/corelib/tools/qelapsedtimer.h
@@ -51,8 +51,8 @@ public:
};
Q_DECL_CONSTEXPR QElapsedTimer()
- : t1(Q_INT64_C(0x8000000000000000))
- , t2(Q_INT64_C(0x8000000000000000))
+ : t1(Q_INT64_C(0x8000000000000000)),
+ t2(Q_INT64_C(0x8000000000000000))
{
}
diff --git a/src/corelib/tools/qelapsedtimer_unix.cpp b/src/corelib/tools/qelapsedtimer_unix.cpp
index 02d60cc60c..61bd7f1f21 100644
--- a/src/corelib/tools/qelapsedtimer_unix.cpp
+++ b/src/corelib/tools/qelapsedtimer_unix.cpp
@@ -35,8 +35,12 @@
#define _POSIX_C_SOURCE 200809L
#include "qelapsedtimer.h"
-#ifdef Q_OS_VXWORKS
+#if defined(Q_OS_VXWORKS)
#include "qfunctions_vxworks.h"
+#elif defined(Q_OS_QNX)
+#include <sys/neutrino.h>
+#include <sys/syspage.h>
+#include <inttypes.h>
#else
#include <sys/time.h>
#include <time.h>
@@ -84,7 +88,18 @@ QT_BEGIN_NAMESPACE
* see http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html
*/
-#ifndef CLOCK_REALTIME
+#if defined(Q_OS_QNX)
+static inline void qt_clock_gettime(clockid_t clock, struct timespec *ts)
+{
+ // The standard POSIX clock calls only have 1ms accuracy on QNX. To get
+ // higher accuracy, this platform-specific function must be used instead
+ quint64 cycles_per_sec = SYSPAGE_ENTRY(qtime)->cycles_per_sec;
+ quint64 cycles = ClockCycles();
+ ts->tv_sec = cycles / cycles_per_sec;
+ quint64 mod = cycles % cycles_per_sec;
+ ts->tv_nsec = mod * Q_INT64_C(1000000000) / cycles_per_sec;
+}
+#elif !defined(CLOCK_REALTIME)
# define CLOCK_REALTIME 0
static inline void qt_clock_gettime(int, struct timespec *ts)
{
diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp
index f32cd78801..b91fd38a5f 100644
--- a/src/corelib/tools/qlist.cpp
+++ b/src/corelib/tools/qlist.cpp
@@ -1365,7 +1365,7 @@ void **QListData::erase(void **xi)
\sa operator*()
*/
-/*! \fn T &QList::iterator::operator[](int j) const
+/*! \fn T &QList::iterator::operator[](difference_type j) const
Returns a modifiable reference to the item at position *this +
\a{j}.
@@ -1466,7 +1466,7 @@ void **QListData::erase(void **xi)
current and returns an iterator to the previously current item.
*/
-/*! \fn QList::iterator &QList::iterator::operator+=(int j)
+/*! \fn QList::iterator &QList::iterator::operator+=(difference_type j)
Advances the iterator by \a j items. (If \a j is negative, the
iterator goes backward.)
@@ -1474,7 +1474,7 @@ void **QListData::erase(void **xi)
\sa operator-=(), operator+()
*/
-/*! \fn QList::iterator &QList::iterator::operator-=(int j)
+/*! \fn QList::iterator &QList::iterator::operator-=(difference_type j)
Makes the iterator go back by \a j items. (If \a j is negative,
the iterator goes forward.)
@@ -1482,7 +1482,7 @@ void **QListData::erase(void **xi)
\sa operator+=(), operator-()
*/
-/*! \fn QList::iterator QList::iterator::operator+(int j) const
+/*! \fn QList::iterator QList::iterator::operator+(difference_type j) const
Returns an iterator to the item at \a j positions forward from
this iterator. (If \a j is negative, the iterator goes backward.)
@@ -1490,7 +1490,7 @@ void **QListData::erase(void **xi)
\sa operator-(), operator+=()
*/
-/*! \fn QList::iterator QList::iterator::operator-(int j) const
+/*! \fn QList::iterator QList::iterator::operator-(difference_type j) const
Returns an iterator to the item at \a j positions backward from
this iterator. (If \a j is negative, the iterator goes forward.)
@@ -1620,7 +1620,7 @@ void **QListData::erase(void **xi)
\sa operator*()
*/
-/*! \fn const T &QList::const_iterator::operator[](int j) const
+/*! \fn const T &QList::const_iterator::operator[](difference_type j) const
Returns the item at position *this + \a{j}.
@@ -1712,7 +1712,7 @@ void **QListData::erase(void **xi)
current and returns an iterator to the previously current item.
*/
-/*! \fn QList::const_iterator &QList::const_iterator::operator+=(int j)
+/*! \fn QList::const_iterator &QList::const_iterator::operator+=(difference_type j)
Advances the iterator by \a j items. (If \a j is negative, the
iterator goes backward.)
@@ -1720,7 +1720,7 @@ void **QListData::erase(void **xi)
\sa operator-=(), operator+()
*/
-/*! \fn QList::const_iterator &QList::const_iterator::operator-=(int j)
+/*! \fn QList::const_iterator &QList::const_iterator::operator-=(difference_type j)
Makes the iterator go back by \a j items. (If \a j is negative,
the iterator goes forward.)
@@ -1728,7 +1728,7 @@ void **QListData::erase(void **xi)
\sa operator+=(), operator-()
*/
-/*! \fn QList::const_iterator QList::const_iterator::operator+(int j) const
+/*! \fn QList::const_iterator QList::const_iterator::operator+(difference_type j) const
Returns an iterator to the item at \a j positions forward from
this iterator. (If \a j is negative, the iterator goes backward.)
@@ -1736,7 +1736,7 @@ void **QListData::erase(void **xi)
\sa operator-(), operator+=()
*/
-/*! \fn QList::const_iterator QList::const_iterator::operator-(int j) const
+/*! \fn QList::const_iterator QList::const_iterator::operator-(difference_type j) const
Returns an iterator to the item at \a j positions backward from
this iterator. (If \a j is negative, the iterator goes forward.)
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 9704c7b953..5b459269c1 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -188,6 +188,7 @@ public:
public:
Node *i;
typedef std::random_access_iterator_tag iterator_category;
+ // ### Qt6: use int
typedef qptrdiff difference_type;
typedef T value_type;
typedef T *pointer;
@@ -198,7 +199,7 @@ public:
inline iterator(const iterator &o): i(o.i){}
inline T &operator*() const { return i->t(); }
inline T *operator->() const { return &i->t(); }
- inline T &operator[](int j) const { return i[j].t(); }
+ inline T &operator[](difference_type j) const { return i[j].t(); }
inline bool operator==(const iterator &o) const { return i == o.i; }
inline bool operator!=(const iterator &o) const { return i != o.i; }
inline bool operator<(const iterator& other) const { return i < other.i; }
@@ -223,10 +224,10 @@ public:
inline iterator operator++(int) { Node *n = i; ++i; return n; }
inline iterator &operator--() { i--; return *this; }
inline iterator operator--(int) { Node *n = i; i--; return n; }
- inline iterator &operator+=(int j) { i+=j; return *this; }
- inline iterator &operator-=(int j) { i-=j; return *this; }
- inline iterator operator+(int j) const { return iterator(i+j); }
- inline iterator operator-(int j) const { return iterator(i-j); }
+ inline iterator &operator+=(difference_type j) { i+=j; return *this; }
+ inline iterator &operator-=(difference_type j) { i-=j; return *this; }
+ inline iterator operator+(difference_type j) const { return iterator(i+j); }
+ inline iterator operator-(difference_type j) const { return iterator(i-j); }
inline int operator-(iterator j) const { return int(i - j.i); }
};
friend class iterator;
@@ -235,6 +236,7 @@ public:
public:
Node *i;
typedef std::random_access_iterator_tag iterator_category;
+ // ### Qt6: use int
typedef qptrdiff difference_type;
typedef T value_type;
typedef const T *pointer;
@@ -250,7 +252,7 @@ public:
#endif
inline const T &operator*() const { return i->t(); }
inline const T *operator->() const { return &i->t(); }
- inline const T &operator[](int j) const { return i[j].t(); }
+ inline const T &operator[](difference_type j) const { return i[j].t(); }
inline bool operator==(const const_iterator &o) const { return i == o.i; }
inline bool operator!=(const const_iterator &o) const { return i != o.i; }
inline bool operator<(const const_iterator& other) const { return i < other.i; }
@@ -261,10 +263,10 @@ public:
inline const_iterator operator++(int) { Node *n = i; ++i; return n; }
inline const_iterator &operator--() { i--; return *this; }
inline const_iterator operator--(int) { Node *n = i; i--; return n; }
- inline const_iterator &operator+=(int j) { i+=j; return *this; }
- inline const_iterator &operator-=(int j) { i-=j; return *this; }
- inline const_iterator operator+(int j) const { return const_iterator(i+j); }
- inline const_iterator operator-(int j) const { return const_iterator(i-j); }
+ inline const_iterator &operator+=(difference_type j) { i+=j; return *this; }
+ inline const_iterator &operator-=(difference_type j) { i-=j; return *this; }
+ inline const_iterator operator+(difference_type j) const { return const_iterator(i+j); }
+ inline const_iterator operator-(difference_type j) const { return const_iterator(i-j); }
inline int operator-(const_iterator j) const { return int(i - j.i); }
};
friend class const_iterator;
@@ -316,6 +318,7 @@ public:
typedef const value_type *const_pointer;
typedef value_type &reference;
typedef const value_type &const_reference;
+ // ### Qt6: use int
typedef qptrdiff difference_type;
// comfort
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index a253057435..a923be50c0 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -3144,7 +3144,7 @@ bool QLocaleData::numberToCLocale(const QChar *str, int len,
}
bool QLocaleData::validateChars(const QString &str, NumberMode numMode, QByteArray *buff,
- int decDigits) const
+ int decDigits, bool rejectGroupSeparators) const
{
buff->clear();
buff->reserve(str.length());
@@ -3205,7 +3205,7 @@ bool QLocaleData::validateChars(const QString &str, NumberMode numMode, QByteArr
case ',':
//it can only be placed after a digit which is before the decimal point
- if (!lastWasDigit || decPointCnt > 0)
+ if (rejectGroupSeparators || !lastWasDigit || decPointCnt > 0)
return false;
break;
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h
index c33ced35d5..c5e62027c4 100644
--- a/src/corelib/tools/qlocale_p.h
+++ b/src/corelib/tools/qlocale_p.h
@@ -251,7 +251,9 @@ public:
inline char digitToCLocale(QChar c) const;
// this function is used in QIntValidator (QtGui)
- Q_CORE_EXPORT bool validateChars(const QString &str, NumberMode numMode, QByteArray *buff, int decDigits = -1) const;
+ Q_CORE_EXPORT bool validateChars(const QString &str, NumberMode numMode,
+ QByteArray *buff, int decDigits = -1,
+ bool rejectGroupSeparators = false) const;
public:
quint16 m_language_id, m_script_id, m_country_id;
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
index 0b3bbc0ad0..5281723c5d 100644
--- a/src/corelib/tools/qsimd.cpp
+++ b/src/corelib/tools/qsimd.cpp
@@ -519,7 +519,7 @@ QBasicAtomicInt qt_cpu_features = Q_BASIC_ATOMIC_INITIALIZER(0);
void qDetectCpuFeatures()
{
#if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
-# if (__GNUC__ * 100 + __GNUC_MINOR__) < 403
+# if Q_CC_GNU < 403
// GCC 4.2 (at least the one that comes with Apple's XCode, on Mac) is
// known to be broken beyond repair in dealing with the inline assembly
// above. It will generate bad code that could corrupt important registers
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index ee2ff99a80..891a3ff053 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -218,8 +218,8 @@
#endif
// other x86 intrinsics
-#if defined(Q_PROCESSOR_X86) && ((defined(Q_CC_GNU) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 404)) \
- || (defined(Q_CC_CLANG) && (__clang_major__ * 100 + __clang_minor__ >= 208)) \
+#if defined(Q_PROCESSOR_X86) && ((defined(Q_CC_GNU) && (Q_CC_GNU >= 404)) \
+ || (defined(Q_CC_CLANG) && (Q_CC_CLANG >= 208)) \
|| defined(Q_CC_INTEL))
# define QT_COMPILER_SUPPORTS_X86INTRIN
# ifdef Q_CC_INTEL
@@ -318,7 +318,7 @@ static inline uint qCpuFeatures()
#ifdef Q_PROCESSOR_X86
// Bit scan functions for x86
-# ifdef Q_CC_MSVC
+# if defined(Q_CC_MSVC) && !defined(Q_OS_WINCE)
// MSVC calls it _BitScanReverse and returns the carry flag, which we don't need
static __forceinline unsigned long _bit_scan_reverse(uint val)
{
@@ -332,7 +332,7 @@ static __forceinline unsigned long _bit_scan_forward(uint val)
_BitScanForward(&result, val);
return result;
}
-# elif (defined(Q_CC_CLANG) || (defined(Q_CC_GNU) && __GNUC__ * 100 + __GNUC_MINOR__ < 405)) \
+# elif (defined(Q_CC_CLANG) || (defined(Q_CC_GNU) && Q_CC_GNU < 405)) \
&& !defined(Q_CC_INTEL)
// Clang is missing the intrinsic for _bit_scan_reverse
// GCC only added it in version 4.5
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 0d13cccbec..76069225eb 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -3938,28 +3938,31 @@ QString QString::section(const QString &sep, int start, int end, SectionFlags fl
{
QStringList sections = split(sep, KeepEmptyParts,
(flags & SectionCaseInsensitiveSeps) ? Qt::CaseInsensitive : Qt::CaseSensitive);
- if (sections.isEmpty())
- return QString();
+ const int sectionsSize = sections.size();
+
if (!(flags & SectionSkipEmpty)) {
if (start < 0)
- start += sections.count();
+ start += sectionsSize;
if (end < 0)
- end += sections.count();
+ end += sectionsSize;
} else {
int skip = 0;
- for (int k=0; k<sections.size(); ++k) {
+ for (int k = 0; k < sectionsSize; ++k) {
if (sections.at(k).isEmpty())
skip++;
}
if (start < 0)
- start += sections.count() - skip;
+ start += sectionsSize - skip;
if (end < 0)
- end += sections.count() - skip;
+ end += sectionsSize - skip;
}
+ if (start >= sectionsSize || end < 0 || start > end)
+ return QString();
+
int x = 0;
QString ret;
int first_i = start, last_i = end;
- for (int i = 0; x <= end && i < sections.size(); ++i) {
+ for (int i = 0; x <= end && i < sectionsSize; ++i) {
QString section = sections.at(i);
const bool empty = section.isEmpty();
if (x >= start) {
@@ -3967,16 +3970,16 @@ QString QString::section(const QString &sep, int start, int end, SectionFlags fl
first_i = i;
if(x == end)
last_i = i;
- if(x > start)
+ if (x > start && i > 0)
ret += sep;
ret += section;
}
if (!empty || !(flags & SectionSkipEmpty))
x++;
}
- if((flags & SectionIncludeLeadingSep) && first_i)
+ if ((flags & SectionIncludeLeadingSep) && first_i > 0)
ret.prepend(sep);
- if((flags & SectionIncludeTrailingSep) && last_i < sections.size()-1)
+ if ((flags & SectionIncludeTrailingSep) && last_i < sectionsSize - 1)
ret += sep;
return ret;
}
@@ -3996,15 +3999,32 @@ static QString extractSections(const QVector<qt_section_chunk> &sections,
int end,
QString::SectionFlags flags)
{
- if (start < 0)
- start += sections.count();
- if (end < 0)
- end += sections.count();
+ const int sectionsSize = sections.size();
+
+ if (!(flags & QString::SectionSkipEmpty)) {
+ if (start < 0)
+ start += sectionsSize;
+ if (end < 0)
+ end += sectionsSize;
+ } else {
+ int skip = 0;
+ for (int k = 0; k < sectionsSize; ++k) {
+ const qt_section_chunk &section = sections.at(k);
+ if (section.length == section.string.length())
+ skip++;
+ }
+ if (start < 0)
+ start += sectionsSize - skip;
+ if (end < 0)
+ end += sectionsSize - skip;
+ }
+ if (start >= sectionsSize || end < 0 || start > end)
+ return QString();
QString ret;
int x = 0;
int first_i = start, last_i = end;
- for (int i = 0; x <= end && i < sections.size(); ++i) {
+ for (int i = 0; x <= end && i < sectionsSize; ++i) {
const qt_section_chunk &section = sections.at(i);
const bool empty = (section.length == section.string.length());
if (x >= start) {
@@ -4021,12 +4041,13 @@ static QString extractSections(const QVector<qt_section_chunk> &sections,
x++;
}
- if ((flags & QString::SectionIncludeLeadingSep) && first_i < sections.size()) {
+ if ((flags & QString::SectionIncludeLeadingSep) && first_i >= 0) {
const qt_section_chunk &section = sections.at(first_i);
ret.prepend(section.string.left(section.length));
}
- if ((flags & QString::SectionIncludeTrailingSep) && last_i+1 <= sections.size()-1) {
+ if ((flags & QString::SectionIncludeTrailingSep)
+ && last_i < sectionsSize - 1) {
const qt_section_chunk &section = sections.at(last_i+1);
ret += section.string.left(section.length);
}
@@ -5650,21 +5671,18 @@ QString QString::toUpper_helper(QString &str)
Safely builds a formatted string from the format string \a cformat
and an arbitrary list of arguments.
- The %lc escape sequence expects a unicode character of type ushort
- (as returned by QChar::unicode()). The %ls escape sequence expects
- a pointer to a zero-terminated array of unicode characters of type
- ushort (as returned by QString::utf16()).
-
- \note This function expects a UTF-8 string for %s and Latin-1 for
- the format string.
+ The format string supports the conversion specifiers, length modifiers,
+ and flags provided by printf() in the standard C++ library. The \a cformat
+ string and \c{%s} arguments must be UTF-8 encoded.
- The format string supports most of the conversion specifiers
- provided by printf() in the standard C++ library. It doesn't
- honor the length modifiers (e.g. \c h for \c short, \c ll for
- \c{long long}). If you need those, use the standard snprintf()
- function instead:
-
- \snippet qstring/main.cpp 63
+ \note The \c{%lc} escape sequence expects a unicode character of type
+ \c char16_t, or \c ushort (as returned by QChar::unicode()).
+ The \c{%ls} escape sequence expects a pointer to a zero-terminated array
+ of unicode characters of type \c char16_t, or ushort (as returned by
+ QString::utf16()). This is at odds with the printf() in the standard C++
+ library, which defines \c {%lc} to print a wchar_t and \c{%ls} to print
+ a \c{wchar_t*}, and might also produce compiler warnings on platforms
+ where the size of \c {wchar_t} is not 16 bits.
\warning We do not recommend using QString::sprintf() in new Qt
code. Instead, consider using QTextStream or arg(), both of
@@ -6284,8 +6302,7 @@ ushort QString::toUShort(bool *ok, int base) const
\snippet qstring/main.cpp 66
- Various string formats for floating point numbers can be converted
- to double values:
+ \warning The QString content may only contain valid numerical characters which includes the plus/minus sign, the characters g and e used in scientific notation, and the decimal point. Including the unit or additional characters leads to a conversion error.
\snippet qstring/main.cpp 67
@@ -6294,7 +6311,7 @@ ushort QString::toUShort(bool *ok, int base) const
\snippet qstring/main.cpp 68
- For historic reasons, this function does not handle
+ For historical reasons, this function does not handle
thousands group separators. If you need to convert such numbers,
use QLocale::toDouble().
diff --git a/src/corelib/tools/qversionnumber.cpp b/src/corelib/tools/qversionnumber.cpp
index 4d148249c0..3c8a9db086 100644
--- a/src/corelib/tools/qversionnumber.cpp
+++ b/src/corelib/tools/qversionnumber.cpp
@@ -40,7 +40,7 @@
**
****************************************************************************/
-#include <QtCore/qversionnumber.h>
+#include <QtCore/private/qversionnumber_p.h>
#include <QtCore/qhash.h>
#include <QtCore/private/qlocale_tools_p.h>
#include <QtCore/qcollator.h>
@@ -61,6 +61,7 @@ QT_BEGIN_NAMESPACE
/*!
\class QVersionNumber
\inmodule QtCore
+ \internal
\since 5.4
\brief The QVersionNumber class contains a version number with an arbitrary
number of segments.
diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber_p.h
index a951b2f1a0..a951b2f1a0 100644
--- a/src/corelib/tools/qversionnumber.h
+++ b/src/corelib/tools/qversionnumber_p.h
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index 2e77f683a4..6f6404f83c 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -72,7 +72,7 @@ HEADERS += \
tools/qunicodetools_p.h \
tools/qvarlengtharray.h \
tools/qvector.h \
- tools/qversionnumber.h
+ tools/qversionnumber_p.h
SOURCES += \