summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/arch/qatomic_ia64.h8
-rw-r--r--src/corelib/codecs/qutfcodec_p.h2
-rw-r--r--src/corelib/doc/qtcore.qdocconf3
-rw-r--r--src/corelib/doc/snippets/code/doc_src_containers.cpp6
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp6
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp6
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp6
-rw-r--r--src/corelib/doc/snippets/qstring/main.cpp4
-rw-r--r--src/corelib/doc/snippets/qstringlist/main.cpp2
-rw-r--r--src/corelib/doc/src/eventsandfilters.qdoc2
-rw-r--r--src/corelib/doc/src/objectmodel/metaobjects.qdoc2
-rw-r--r--src/corelib/doc/src/objectmodel/properties.qdoc2
-rw-r--r--src/corelib/doc/src/statemachine.qdoc2
-rw-r--r--src/corelib/global/qcompilerdetection.h5
-rw-r--r--src/corelib/global/qglobal.cpp4
-rw-r--r--src/corelib/global/qglobal.h2
-rw-r--r--src/corelib/global/qhooks_p.h11
-rw-r--r--src/corelib/global/qnamespace.qdoc17
-rw-r--r--src/corelib/io/qdebug.cpp56
-rw-r--r--src/corelib/io/qdebug.h16
-rw-r--r--src/corelib/io/qdir.cpp2
-rw-r--r--src/corelib/io/qfilesystemengine.cpp2
-rw-r--r--src/corelib/io/qfilesystementry.cpp3
-rw-r--r--src/corelib/io/qfilesystemwatcher.cpp6
-rw-r--r--src/corelib/io/qfilesystemwatcher_win.cpp2
-rw-r--r--src/corelib/io/qfsfileengine_p.h1
-rw-r--r--src/corelib/io/qiodevice.cpp6
-rw-r--r--src/corelib/io/qlockfile_unix.cpp37
-rw-r--r--src/corelib/io/qprocess.cpp12
-rw-r--r--src/corelib/io/qresource.cpp6
-rw-r--r--src/corelib/io/qsettings.cpp9
-rw-r--r--src/corelib/io/qsettings_mac.cpp6
-rw-r--r--src/corelib/io/qstandardpaths_win.cpp2
-rw-r--r--src/corelib/io/qtemporarydir.cpp4
-rw-r--r--src/corelib/io/qtextstream.cpp2
-rw-r--r--src/corelib/io/qtldurl.cpp15
-rw-r--r--src/corelib/io/qurl.cpp2
-rw-r--r--src/corelib/io/qwindowspipereader.cpp2
-rw-r--r--src/corelib/io/qwindowspipewriter.cpp54
-rw-r--r--src/corelib/json/qjsondocument.cpp2
-rw-r--r--src/corelib/json/qjsonvalue.cpp10
-rw-r--r--src/corelib/json/qjsonwriter.cpp4
-rw-r--r--src/corelib/kernel/qcore_unix_p.h14
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp12
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h2
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp112
-rw-r--r--src/corelib/kernel/qeventdispatcher_win_p.h11
-rw-r--r--src/corelib/kernel/qmetaobject.cpp23
-rw-r--r--src/corelib/kernel/qobject.cpp4
-rw-r--r--src/corelib/kernel/qsharedmemory_systemv.cpp2
-rw-r--r--src/corelib/kernel/qsocketnotifier.cpp36
-rw-r--r--src/corelib/kernel/qsystemsemaphore_systemv.cpp2
-rw-r--r--src/corelib/kernel/qtimer.cpp9
-rw-r--r--src/corelib/kernel/qvariant.cpp2
-rw-r--r--src/corelib/mimetypes/qmimedatabase.cpp1
-rw-r--r--src/corelib/mimetypes/qmimedatabase.h1
-rw-r--r--src/corelib/mimetypes/qmimedatabase_p.h1
-rw-r--r--src/corelib/mimetypes/qmimemagicrule.cpp68
-rw-r--r--src/corelib/mimetypes/qmimemagicrule_p.h3
-rw-r--r--src/corelib/mimetypes/qmimeprovider.cpp1
-rw-r--r--src/corelib/mimetypes/qmimeprovider_p.h1
-rw-r--r--src/corelib/mimetypes/qmimetype.cpp1
-rw-r--r--src/corelib/mimetypes/qmimetype.h2
-rw-r--r--src/corelib/mimetypes/qmimetypeparser.cpp40
-rw-r--r--src/corelib/mimetypes/qmimetypeparser_p.h2
-rw-r--r--src/corelib/plugin/qelfparser_p.cpp2
-rw-r--r--src/corelib/plugin/qplugin.qdoc2
-rw-r--r--src/corelib/plugin/qpluginloader.cpp6
-rw-r--r--src/corelib/statemachine/qhistorystate.cpp13
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp6
-rw-r--r--src/corelib/statemachine/qstatemachine_p.h12
-rw-r--r--src/corelib/thread/qfuturewatcher.cpp24
-rw-r--r--src/corelib/thread/qmutex.cpp15
-rw-r--r--src/corelib/thread/qthread_p.h2
-rw-r--r--src/corelib/thread/qthread_unix.cpp2
-rw-r--r--src/corelib/thread/qthread_win.cpp2
-rw-r--r--src/corelib/thread/qthreadstorage.cpp6
-rw-r--r--[-rwxr-xr-x]src/corelib/tools/qalgorithms.qdoc0
-rw-r--r--src/corelib/tools/qbitarray.h2
-rw-r--r--src/corelib/tools/qbytearray.cpp4
-rw-r--r--src/corelib/tools/qcommandlineparser.cpp4
-rw-r--r--src/corelib/tools/qdatetime.cpp1
-rw-r--r--src/corelib/tools/qhash.h7
-rw-r--r--src/corelib/tools/qlinkedlist.cpp78
-rw-r--r--src/corelib/tools/qlinkedlist.h32
-rw-r--r--src/corelib/tools/qlist.h7
-rw-r--r--src/corelib/tools/qlocale.cpp12
-rw-r--r--src/corelib/tools/qmap.h15
-rw-r--r--src/corelib/tools/qqueue.h2
-rw-r--r--src/corelib/tools/qregularexpression.cpp10
-rw-r--r--src/corelib/tools/qset.h29
-rw-r--r--src/corelib/tools/qset.qdoc78
-rw-r--r--src/corelib/tools/qsimd_p.h7
-rw-r--r--src/corelib/tools/qstack.h2
-rw-r--r--src/corelib/tools/qstring.cpp2
-rw-r--r--src/corelib/tools/qstring.h8
-rw-r--r--src/corelib/tools/qstringalgorithms_p.h2
-rw-r--r--src/corelib/tools/qversionnumber.cpp2
-rw-r--r--src/corelib/xml/qxmlstream.cpp3
99 files changed, 748 insertions, 352 deletions
diff --git a/src/corelib/arch/qatomic_ia64.h b/src/corelib/arch/qatomic_ia64.h
index c880e85209..2ba6d127d9 100644
--- a/src/corelib/arch/qatomic_ia64.h
+++ b/src/corelib/arch/qatomic_ia64.h
@@ -1035,16 +1035,16 @@ bool QBasicAtomicOps<size>::deref(T &_q_value) Q_DECL_NOTHROW
}
template<int size> template <typename T> inline
-bool QBasicAtomicOps<size>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
+bool QBasicAtomicOps<size>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW
{
- return testAndSetAcquire(_q_value, expectedValue, newValue);
+ return testAndSetAcquire(_q_value, expectedValue, newValue, currentValue);
}
template<int size> template <typename T> inline
-bool QBasicAtomicOps<size>::testAndSetOrdered(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
+bool QBasicAtomicOps<size>::testAndSetOrdered(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW
{
orderedMemoryFence(_q_value);
- return testAndSetAcquire(_q_value, expectedValue, newValue);
+ return testAndSetAcquire(_q_value, expectedValue, newValue, currentValue);
}
template<int size> template <typename T> inline
diff --git a/src/corelib/codecs/qutfcodec_p.h b/src/corelib/codecs/qutfcodec_p.h
index 99887352c9..d97145c6fc 100644
--- a/src/corelib/codecs/qutfcodec_p.h
+++ b/src/corelib/codecs/qutfcodec_p.h
@@ -217,8 +217,6 @@ namespace QUtf8Functions
return Traits::Error;
if (bytesAvailable > 1 && !isContinuationByte(Traits::peekByte(src, 1)))
return Traits::Error;
- if (bytesAvailable > 2 && !isContinuationByte(Traits::peekByte(src, 2)))
- return Traits::Error;
return Traits::EndOfString;
}
diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf
index 502689e4c2..3d64708def 100644
--- a/src/corelib/doc/qtcore.qdocconf
+++ b/src/corelib/doc/qtcore.qdocconf
@@ -25,8 +25,7 @@ qhp.QtCore.subprojects.classes.sortPages = true
tagfile = ../../../doc/qtcore/qtcore.tags
-depends += activeqt qtdbus qtgui qtwidgets qtnetwork qtdoc qtmacextras qtquick qtlinguist qtdesigner qtconcurrent qtxml qmake qtwinextras
-# depends += qtqml # Qt namespace collides with QtQml::Qt, see QTBUG-38630
+depends += activeqt qtdbus qtgui qtwidgets qtnetwork qtdoc qtmacextras qtquick qtlinguist qtdesigner qtconcurrent qtxml qmake qtwinextras qtqml
headerdirs += ..
diff --git a/src/corelib/doc/snippets/code/doc_src_containers.cpp b/src/corelib/doc/snippets/code/doc_src_containers.cpp
index 00971d69b9..395e48bc89 100644
--- a/src/corelib/doc/snippets/code/doc_src_containers.cpp
+++ b/src/corelib/doc/snippets/code/doc_src_containers.cpp
@@ -176,7 +176,7 @@ QMap<int, int> map;
...
QMap<int, int>::const_iterator i;
for (i = map.constBegin(); i != map.constEnd(); ++i)
- qDebug() << i.key() << ":" << i.value();
+ qDebug() << i.key() << ':' << i.value();
//! [13]
@@ -236,7 +236,7 @@ foreach (const QString &str, list) {
QMap<QString, int> map;
...
foreach (const QString &str, map.keys())
- qDebug() << str << ":" << map.value(str);
+ qDebug() << str << ':' << map.value(str);
//! [19]
@@ -245,7 +245,7 @@ QMultiMap<QString, int> map;
...
foreach (const QString &str, map.uniqueKeys()) {
foreach (int i, map.values(str))
- qDebug() << str << ":" << i;
+ qDebug() << str << ':' << i;
}
//! [20]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp
index 0ac7cb5769..0976488a48 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp
@@ -220,7 +220,7 @@ for (i = hash.begin(); i != hash.end(); ++i)
//! [19]
QHash<QString, int>::iterator i = hash.begin();
while (i != hash.end()) {
- if (i.key().startsWith("_"))
+ if (i.key().startsWith('_'))
i = hash.erase(i);
else
++i;
@@ -233,7 +233,7 @@ QHash<QString, int>::iterator i = hash.begin();
while (i != hash.end()) {
QHash<QString, int>::iterator prev = i;
++i;
- if (prev.key().startsWith("_"))
+ if (prev.key().startsWith('_'))
hash.erase(prev);
}
//! [20]
@@ -242,7 +242,7 @@ while (i != hash.end()) {
//! [21]
// WRONG
while (i != hash.end()) {
- if (i.key().startsWith("_"))
+ if (i.key().startsWith('_'))
hash.erase(i);
++i;
}
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp
index 014af8b0ee..f1cf644df6 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp
@@ -128,7 +128,7 @@ QLinkedList<QString> list;
...
QLinkedList<QString>::iterator i = list.begin();
while (i != list.end()) {
- if ((*i).startsWith("_"))
+ if ((*i).startsWith('_'))
i = list.erase(i);
else
++i;
@@ -141,7 +141,7 @@ QLinkedList<QString>::iterator i = list.begin();
while (i != list.end()) {
QLinkedList<QString>::iterator previous = i;
++i;
- if ((*previous).startsWith("_"))
+ if ((*previous).startsWith('_'))
list.erase(previous);
}
//! [11]
@@ -150,7 +150,7 @@ while (i != list.end()) {
//! [12]
// WRONG
while (i != list.end()) {
- if ((*i).startsWith("_"))
+ if ((*i).startsWith('_'))
list.erase(i);
++i;
}
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp
index 29e53fc700..3241991129 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qmap.cpp
@@ -234,7 +234,7 @@ for (i = map.begin(); i != map.end(); ++i)
//! [20]
QMap<QString, int>::iterator i = map.begin();
while (i != map.end()) {
- if (i.key().startsWith("_"))
+ if (i.key().startsWith('_'))
i = map.erase(i);
else
++i;
@@ -247,7 +247,7 @@ QMap<QString, int>::iterator i = map.begin();
while (i != map.end()) {
QMap<QString, int>::iterator prev = i;
++i;
- if (prev.key().startsWith("_"))
+ if (prev.key().startsWith('_'))
map.erase(prev);
}
//! [21]
@@ -256,7 +256,7 @@ while (i != map.end()) {
//! [22]
// WRONG
while (i != map.end()) {
- if (i.key().startsWith("_"))
+ if (i.key().startsWith('_'))
map.erase(i);
++i;
}
diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp
index e03e705a0b..d0b5fb00f3 100644
--- a/src/corelib/doc/snippets/qstring/main.cpp
+++ b/src/corelib/doc/snippets/qstring/main.cpp
@@ -777,10 +777,10 @@ void Widget::splitCaseSensitiveFunction()
//! [62]
QString str = "a,,b,c";
- QStringList list1 = str.split(",");
+ QStringList list1 = str.split(',');
// list1: [ "a", "", "b", "c" ]
- QStringList list2 = str.split(",", QString::SkipEmptyParts);
+ QStringList list2 = str.split(',', QString::SkipEmptyParts);
// list2: [ "a", "b", "c" ]
//! [62]
}
diff --git a/src/corelib/doc/snippets/qstringlist/main.cpp b/src/corelib/doc/snippets/qstringlist/main.cpp
index 64f2061786..04d4dc8a89 100644
--- a/src/corelib/doc/snippets/qstringlist/main.cpp
+++ b/src/corelib/doc/snippets/qstringlist/main.cpp
@@ -82,7 +82,7 @@ Widget::Widget(QWidget *parent)
//! [5] //! [6]
QStringList list;
//! [5]
- list = str.split(",");
+ list = str.split(',');
// list: ["Arial", "Helvetica", "Times", "Courier"]
//! [6]
diff --git a/src/corelib/doc/src/eventsandfilters.qdoc b/src/corelib/doc/src/eventsandfilters.qdoc
index a4710eb288..99a40bb1b8 100644
--- a/src/corelib/doc/src/eventsandfilters.qdoc
+++ b/src/corelib/doc/src/eventsandfilters.qdoc
@@ -100,7 +100,7 @@
event delivery mechanisms are flexible. The documentation for
QCoreApplication::notify() concisely tells the whole story; the
\e{Qt Quarterly} article
- \l{http://doc.qt.digia.com/qq/qq11-events.html}{Another Look at Events}
+ \l{http://doc.qt.io/archives/qq/qq11-events.html}{Another Look at Events}
rehashes it less concisely. Here we will explain enough for 95%
of applications.
diff --git a/src/corelib/doc/src/objectmodel/metaobjects.qdoc b/src/corelib/doc/src/objectmodel/metaobjects.qdoc
index a482c5cc8b..52c134c517 100644
--- a/src/corelib/doc/src/objectmodel/metaobjects.qdoc
+++ b/src/corelib/doc/src/objectmodel/metaobjects.qdoc
@@ -32,7 +32,7 @@
\ingroup qt-basic-concepts
\keyword meta-object
- \target Meta-Object System
+ \keyword Meta-Object System
Qt's meta-object system provides the signals and slots mechanism for
inter-object communication, run-time type information, and the dynamic
diff --git a/src/corelib/doc/src/objectmodel/properties.qdoc b/src/corelib/doc/src/objectmodel/properties.qdoc
index 55622dd56b..28be328e3a 100644
--- a/src/corelib/doc/src/objectmodel/properties.qdoc
+++ b/src/corelib/doc/src/objectmodel/properties.qdoc
@@ -31,7 +31,7 @@
\brief An overview of Qt's property system.
\ingroup qt-basic-concepts
- \target Qt's Property System
+ \keyword Qt's Property System
Qt provides a sophisticated property system similar to the ones
supplied by some compiler vendors. However, as a compiler- and
diff --git a/src/corelib/doc/src/statemachine.qdoc b/src/corelib/doc/src/statemachine.qdoc
index e44a603959..d50851d816 100644
--- a/src/corelib/doc/src/statemachine.qdoc
+++ b/src/corelib/doc/src/statemachine.qdoc
@@ -71,6 +71,8 @@
which are currently active. All the states in a valid configuration of the state machine will
have a common ancestor.
+ \sa {The Declarative State Machine Framework}
+
\section1 Classes in the State Machine Framework
These classes are provided by qt for creating event-driven state machines.
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 4828d8596a..8595c51368 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -572,6 +572,9 @@
# if _MSC_VER < 1900
// ICC disables unicode string support when compatibility mode with MSVC 2013 or lower is active
# undef Q_COMPILER_UNICODE_STRINGS
+// Even though ICC knows about ref-qualified members, MSVC 2013 or lower doesn't, so
+// certain member functions (like QString::toUpper) may be missing from the DLLs.
+# undef Q_COMPILER_REF_QUALIFIERS
// Disable constexpr unless the MS headers have constexpr in all the right places too
// (like std::numeric_limits<T>::max())
# undef Q_COMPILER_CONSTEXPR
@@ -1140,7 +1143,7 @@
# define QT_WARNING_PUSH QT_DO_PRAGMA(clang diagnostic push)
# define QT_WARNING_POP QT_DO_PRAGMA(clang diagnostic pop)
# define QT_WARNING_DISABLE_CLANG(text) QT_DO_PRAGMA(clang diagnostic ignored text)
-# define QT_WARNING_DISABLE_GCC(text) QT_DO_PRAGMA(GCC diagnostic ignored text) // GCC directives work in Clang too
+# define QT_WARNING_DISABLE_GCC(text)
# define QT_WARNING_DISABLE_INTEL(number)
# define QT_WARNING_DISABLE_MSVC(number)
#elif defined(Q_CC_GNU) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 9019676d24..62308aec9d 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -120,7 +120,9 @@ Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);
// (if this list becomes too long, consider factoring into a separate file)
Q_STATIC_ASSERT_X(sizeof(int) == 4, "Qt assumes that int is 32 bits");
Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits");
-
+#ifndef QT_BOOTSTRAPPED
+Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "configure test ptrsize failed to correctly determine QT_POINTER_SIZE");
+#endif
/*!
\class QFlag
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 41580598c7..d4bbbe833c 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -602,7 +602,7 @@ public:
QMacAutoReleasePool();
~QMacAutoReleasePool();
private:
- Q_DISABLE_COPY(QMacAutoReleasePool);
+ Q_DISABLE_COPY(QMacAutoReleasePool)
NSAutoreleasePool *pool;
};
diff --git a/src/corelib/global/qhooks_p.h b/src/corelib/global/qhooks_p.h
index 28e0c1ed37..2beb58f8a7 100644
--- a/src/corelib/global/qhooks_p.h
+++ b/src/corelib/global/qhooks_p.h
@@ -35,6 +35,17 @@
#ifndef QHOOKS_H
#define QHOOKS_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <QtCore/qglobal.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 3edee03a2a..8568dfd97c 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -28,7 +28,7 @@
/*!
\namespace Qt
\inmodule QtCore
- \target Qt Namespace
+ \keyword Qt Namespace
\brief The Qt namespace contains miscellaneous identifiers
used throughout the Qt library.
@@ -1729,6 +1729,17 @@
\value Key_Zoom
\value Key_Exit
\value Key_Cancel
+ \value Key_MicVolumeUp
+ \value Key_Find
+ \value Key_Open
+ \value Key_MicVolumeDown
+ \value Key_New
+ \value Key_Settings
+ \value Key_Redo
+ \value Key_Exit
+ \value Key_Info
+ \value Key_Undo
+ \value Key_Guide
\sa QKeyEvent::key()
*/
@@ -2420,7 +2431,7 @@
\value WhatsThisCursor \inlineimage cursor-whatsthis.png
An arrow with a question mark, typically used to indicate
the presence of What's This? help for a widget.
- \value BusyCursor \inlineimage cursor-wait.png
+ \value BusyCursor \inlineimage cursor-busy.png
An hourglass or watch cursor, usually shown during
operations that allow the user to interact with
the application while they are performed in the
@@ -2730,7 +2741,7 @@
"\l{http://bugreports.qt.io/browse/QTWEBSITE-13}{http://bugreports.qt.../QTWEBSITE-13/}"),
whereas Qt::ElideRight is appropriate
for other strings (e.g.,
- "\l{http://doc.qt.digia.com/qq/qq09-mac-deployment.html}{Deploying Applications on Ma...}").
+ "\l{http://doc.qt.io/archives/qq/qq09-mac-deployment.html}{Deploying Applications on Ma...}").
\sa QAbstractItemView::textElideMode, QFontMetrics::elidedText(), AlignmentFlag, QTabBar::elideMode
*/
diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp
index 13eccce9da..81af96b96b 100644
--- a/src/corelib/io/qdebug.cpp
+++ b/src/corelib/io/qdebug.cpp
@@ -696,6 +696,62 @@ QDebug &QDebug::resetFormat()
*/
/*!
+ \fn QDebug operator<<(QDebug stream, const QList<T> &list)
+ \relates QDebug
+
+ Writes the contents of \a list to \a stream. \c T needs to
+ support streaming into QDebug.
+*/
+
+/*!
+ \fn QDebug operator<<(QDebug stream, const QVector<T> &vector)
+ \relates QDebug
+
+ Writes the contents of \a vector to \a stream. \c T needs to
+ support streaming into QDebug.
+*/
+
+/*!
+ \fn QDebug operator<<(QDebug stream, const QSet<T> &set)
+ \relates QDebug
+
+ Writes the contents of \a set to \a stream. \c T needs to
+ support streaming into QDebug.
+*/
+
+/*!
+ \fn QDebug operator<<(QDebug stream, const QMap<Key, T> &map)
+ \relates QDebug
+
+ Writes the contents of \a map to \a stream. Both \c Key and
+ \c T need to support streaming into QDebug.
+*/
+
+/*!
+ \fn QDebug operator<<(QDebug stream, const QHash<Key, T> &hash)
+ \relates QDebug
+
+ Writes the contents of \a hash to \a stream. Both \c Key and
+ \c T need to support streaming into QDebug.
+*/
+
+/*!
+ \fn QDebug operator<<(QDebug stream, const QPair<T1, T2> &pair)
+ \relates QDebug
+
+ Writes the contents of \a pair to \a stream. Both \c T1 and
+ \c T2 need to support streaming into QDebug.
+*/
+
+/*!
+ \fn QDebug operator<<(QDebug stream, const QFlags<T> &flag)
+ \relates QDebug
+ \since 4.7
+
+ Writes \a flag to \a stream.
+*/
+
+/*!
\class QDebugStateSaver
\inmodule QtCore
\brief Convenience class for custom QDebug operators
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h
index 2f626dfc1f..b1a0396f35 100644
--- a/src/corelib/io/qdebug.h
+++ b/src/corelib/io/qdebug.h
@@ -216,12 +216,12 @@ inline QDebug operator<<(QDebug debug, const QVector<T> &vec)
return operator<<(debug, vec.toList());
}
-template <class aKey, class aT>
-inline QDebug operator<<(QDebug debug, const QMap<aKey, aT> &map)
+template <class Key, class T>
+inline QDebug operator<<(QDebug debug, const QMap<Key, T> &map)
{
const bool oldSetting = debug.autoInsertSpaces();
debug.nospace() << "QMap(";
- for (typename QMap<aKey, aT>::const_iterator it = map.constBegin();
+ for (typename QMap<Key, T>::const_iterator it = map.constBegin();
it != map.constEnd(); ++it) {
debug << '(' << it.key() << ", " << it.value() << ')';
}
@@ -230,12 +230,12 @@ inline QDebug operator<<(QDebug debug, const QMap<aKey, aT> &map)
return debug.maybeSpace();
}
-template <class aKey, class aT>
-inline QDebug operator<<(QDebug debug, const QHash<aKey, aT> &hash)
+template <class Key, class T>
+inline QDebug operator<<(QDebug debug, const QHash<Key, T> &hash)
{
const bool oldSetting = debug.autoInsertSpaces();
debug.nospace() << "QHash(";
- for (typename QHash<aKey, aT>::const_iterator it = hash.constBegin();
+ for (typename QHash<Key, T>::const_iterator it = hash.constBegin();
it != hash.constEnd(); ++it)
debug << '(' << it.key() << ", " << it.value() << ')';
debug << ')';
@@ -276,7 +276,7 @@ inline QDebug operator<<(QDebug debug, const QContiguousCache<T> &cache)
return debug.maybeSpace();
}
-#ifndef QT_NO_QOBJECT
+#if !defined(QT_NO_QOBJECT) && !defined(Q_QDOC)
Q_CORE_EXPORT QDebug qt_QMetaEnum_debugOperator(QDebug&, int value, const QMetaObject *meta, const char *name);
Q_CORE_EXPORT QDebug qt_QMetaEnum_flagDebugOperator(QDebug &dbg, quint64 value, const QMetaObject *meta, const char *name);
@@ -305,7 +305,7 @@ inline typename QtPrivate::QEnableIf<
!QtPrivate::IsQEnumHelper<T>::Value && !QtPrivate::IsQEnumHelper<QFlags<T> >::Value,
QDebug>::Type
qt_QMetaEnum_flagDebugOperator_helper(QDebug debug, const QFlags<T> &flags)
-#else // !QT_NO_QOBJECT
+#else // !QT_NO_QOBJECT && !Q_QDOC
template <class T>
inline QDebug qt_QMetaEnum_flagDebugOperator_helper(QDebug debug, const QFlags<T> &flags)
#endif
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index e1d9858a66..4d2b36632f 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -138,7 +138,7 @@ inline QChar QDirPrivate::getFilterSepChar(const QString &nameFilter)
// static
inline QStringList QDirPrivate::splitFilters(const QString &nameFilter, QChar sep)
{
- if (sep == 0)
+ if (sep.isNull())
sep = getFilterSepChar(nameFilter);
QStringList ret = nameFilter.split(sep);
for (int i = 0; i < ret.count(); ++i)
diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp
index e4dec2b7fb..a49d69d447 100644
--- a/src/corelib/io/qfilesystemengine.cpp
+++ b/src/corelib/io/qfilesystemengine.cpp
@@ -152,7 +152,7 @@ static bool _q_resolveEntryAndCreateLegacyEngine_recursive(QFileSystemEntry &ent
const QStringList &paths = QDir::searchPaths(filePath.left(prefixSeparator));
for (int i = 0; i < paths.count(); i++) {
- entry = QFileSystemEntry(QDir::cleanPath(paths.at(i) % QLatin1Char('/') % filePath.mid(prefixSeparator + 1)));
+ entry = QFileSystemEntry(QDir::cleanPath(paths.at(i) % QLatin1Char('/') % filePath.midRef(prefixSeparator + 1)));
// Recurse!
if (_q_resolveEntryAndCreateLegacyEngine_recursive(entry, data, engine, true))
return true;
diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp
index 79f16a0839..709970e3ac 100644
--- a/src/corelib/io/qfilesystementry.cpp
+++ b/src/corelib/io/qfilesystementry.cpp
@@ -53,8 +53,7 @@ static bool isUncRoot(const QString &server)
if (idx == -1 || idx + 1 == localPath.length())
return true;
- localPath = localPath.right(localPath.length() - idx - 1).trimmed();
- return localPath.isEmpty();
+ return localPath.rightRef(localPath.length() - idx - 1).trimmed().isEmpty();
}
static inline QString fixIfRelativeUncPath(const QString &path)
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index 7fc3049f46..23a2fbecdb 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -296,7 +296,9 @@ QStringList QFileSystemWatcher::addPaths(const QStringList &paths)
QFileSystemWatcherEngine *engine = 0;
- if(!objectName().startsWith(QLatin1String("_qt_autotest_force_engine_"))) {
+ const QString on = objectName();
+
+ if (!on.startsWith(QLatin1String("_qt_autotest_force_engine_"))) {
// Normal runtime case - search intelligently for best engine
if(d->native) {
engine = d->native;
@@ -307,7 +309,7 @@ QStringList QFileSystemWatcher::addPaths(const QStringList &paths)
} else {
// Autotest override case - use the explicitly selected engine only
- QString forceName = objectName().mid(26);
+ const QStringRef forceName = on.midRef(26);
if(forceName == QLatin1String("poller")) {
qDebug() << "QFileSystemWatcher: skipping native engine, using only polling engine";
d_func()->initPollerEngine();
diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp
index 4907a20a5f..410753868e 100644
--- a/src/corelib/io/qfilesystemwatcher_win.cpp
+++ b/src/corelib/io/qfilesystemwatcher_win.cpp
@@ -186,7 +186,7 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths,
}
if (!found) {
QWindowsFileSystemWatcherEngineThread *thread = new QWindowsFileSystemWatcherEngineThread();
- DEBUG() << " ###Creating new thread" << thread << "(" << (threads.count()+1) << "threads)";
+ DEBUG() << " ###Creating new thread" << thread << '(' << (threads.count()+1) << "threads)";
thread->handles.append(handle.handle);
thread->handleForDir.insert(QFileSystemWatcherPathKey(absolutePath), handle);
diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h
index 8ba05fa8b9..0a7f551672 100644
--- a/src/corelib/io/qfsfileengine_p.h
+++ b/src/corelib/io/qfsfileengine_p.h
@@ -199,7 +199,6 @@ public:
bool closeFileHandle;
mutable uint is_sequential : 2;
- mutable uint could_stat : 1;
mutable uint tried_stat : 1;
#if !defined(Q_OS_WINCE)
mutable uint need_lstat : 1;
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index 84a6a1d9cb..c80c78bd3b 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -83,6 +83,7 @@ void debugBinaryString(const char *data, qint64 maxlen)
static void checkWarnMessage(const QIODevice *device, const char *function, const char *what)
{
+#ifndef QT_NO_WARNING_OUTPUT
QDebug d = qWarning();
d.noquote();
d.nospace();
@@ -98,6 +99,11 @@ static void checkWarnMessage(const QIODevice *device, const char *function, cons
Q_UNUSED(device)
#endif // !QT_NO_QOBJECT
d << ": " << what;
+#else
+ Q_UNUSED(device);
+ Q_UNUSED(function);
+ Q_UNUSED(what);
+#endif // QT_NO_WARNING_OUTPUT
}
#define CHECK_MAXLEN(function, returnType) \
diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp
index 27f8a97fd4..365f3e07ab 100644
--- a/src/corelib/io/qlockfile_unix.cpp
+++ b/src/corelib/io/qlockfile_unix.cpp
@@ -56,7 +56,13 @@
# include <cstdio>
#elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS)
# include <sys/user.h>
+# if defined(__GLIBC__) && defined(__FreeBSD_kernel__)
+# include <sys/cdefs.h>
+# include <sys/param.h>
+# include <sys/sysctl.h>
+# else
# include <libutil.h>
+# endif
#endif
QT_BEGIN_NAMESPACE
@@ -165,8 +171,10 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys()
}
}
// Ensure nobody else can delete the file while we have it
- if (!setNativeLocks(fd))
- qWarning() << "setNativeLocks failed:" << strerror(errno);
+ if (!setNativeLocks(fd)) {
+ const int errnoSaved = errno;
+ qWarning() << "setNativeLocks failed:" << qt_error_string(errnoSaved);
+ }
if (qt_write_loop(fd, fileData.constData(), fileData.size()) < fileData.size()) {
close(fd);
@@ -178,6 +186,13 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys()
// We hold the lock, continue.
fileHandle = fd;
+ // Sync to disk if possible. Ignore errors (e.g. not supported).
+#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
+ fdatasync(fileHandle);
+#else
+ fsync(fileHandle);
+#endif
+
return QLockFile::NoError;
}
@@ -234,9 +249,27 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
buf[len] = 0;
return QFileInfo(QFile::decodeName(buf)).fileName();
#elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS)
+# if defined(__GLIBC__) && defined(__FreeBSD_kernel__)
+ int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid };
+ size_t len = 0;
+ if (sysctl(mib, 4, NULL, &len, NULL, 0) < 0)
+ return QString();
+ kinfo_proc *proc = static_cast<kinfo_proc *>(malloc(len));
+# else
kinfo_proc *proc = kinfo_getproc(pid);
+# endif
if (!proc)
return QString();
+# if defined(__GLIBC__) && defined(__FreeBSD_kernel__)
+ if (sysctl(mib, 4, proc, &len, NULL, 0) < 0) {
+ free(proc);
+ return QString();
+ }
+ if (proc->ki_pid != pid) {
+ free(proc);
+ return QString();
+ }
+# endif
QString name = QFile::decodeName(proc->ki_comm);
free(proc);
return name;
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index ecda86a91d..3539c75548 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -156,16 +156,8 @@ QStringList QProcessEnvironmentPrivate::toList() const
{
QStringList result;
result.reserve(hash.size());
- Hash::ConstIterator it = hash.constBegin(),
- end = hash.constEnd();
- for ( ; it != end; ++it) {
- QString data = nameToString(it.key());
- QString value = valueToString(it.value());
- data.reserve(data.length() + value.length() + 1);
- data.append(QLatin1Char('='));
- data.append(value);
- result << data;
- }
+ for (Hash::const_iterator it = hash.cbegin(), end = hash.cend(); it != end; ++it)
+ result << nameToString(it.key()) + QLatin1Char('=') + valueToString(it.value());
return result;
}
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index 4e6079306b..0674ef34e0 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -800,8 +800,8 @@ bool QResourceRoot::mappingRootSubdir(const QString &path, QString *match) const
{
const QString root = mappingRoot();
if(!root.isEmpty()) {
- const QStringList root_segments = root.split(QLatin1Char('/'), QString::SkipEmptyParts),
- path_segments = path.split(QLatin1Char('/'), QString::SkipEmptyParts);
+ const QVector<QStringRef> root_segments = root.splitRef(QLatin1Char('/'), QString::SkipEmptyParts),
+ path_segments = path.splitRef(QLatin1Char('/'), QString::SkipEmptyParts);
if(path_segments.size() <= root_segments.size()) {
int matched = 0;
for(int i = 0; i < path_segments.size(); ++i) {
@@ -811,7 +811,7 @@ bool QResourceRoot::mappingRootSubdir(const QString &path, QString *match) const
}
if(matched == path_segments.size()) {
if(match && root_segments.size() > matched)
- *match = root_segments.at(matched);
+ *match = root_segments.at(matched).toString();
return true;
}
}
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 654d688c53..3460753fbe 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -488,7 +488,7 @@ QVariant QSettingsPrivate::stringToVariant(const QString &s)
if (s.startsWith(QLatin1Char('@'))) {
if (s.endsWith(QLatin1Char(')'))) {
if (s.startsWith(QLatin1String("@ByteArray("))) {
- return QVariant(s.toLatin1().mid(11, s.size() - 12));
+ return QVariant(s.midRef(11, s.size() - 12).toLatin1());
} else if (s.startsWith(QLatin1String("@Variant("))
|| s.startsWith(QLatin1String("@DateTime("))) {
#ifndef QT_NO_DATASTREAM
@@ -501,7 +501,7 @@ QVariant QSettingsPrivate::stringToVariant(const QString &s)
version = QDataStream::Qt_4_0;
offset = 9;
}
- QByteArray a(s.toLatin1().mid(offset));
+ QByteArray a = s.midRef(offset).toLatin1();
QDataStream stream(&a, QIODevice::ReadOnly);
stream.setVersion(version);
QVariant result;
@@ -632,8 +632,9 @@ void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result,
int startPos = result.size();
result.reserve(startPos + str.size() * 3 / 2);
+ const QChar *unicode = str.unicode();
for (i = 0; i < str.size(); ++i) {
- uint ch = str.at(i).unicode();
+ uint ch = unicode[i].unicode();
if (ch == ';' || ch == ',' || ch == '=')
needsQuotes = true;
@@ -687,7 +688,7 @@ void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result,
#ifndef QT_NO_TEXTCODEC
} else if (useCodec) {
// slow
- result += codec->fromUnicode(str.at(i));
+ result += codec->fromUnicode(&unicode[i], 1);
#endif
} else {
result += (char)ch;
diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp
index 1ad198b990..e0b317b4c2 100644
--- a/src/corelib/io/qsettings_mac.cpp
+++ b/src/corelib/io/qsettings_mac.cpp
@@ -386,7 +386,7 @@ QMacSettingsPrivate::QMacSettingsPrivate(QSettings::Scope scope, const QString &
if (main_bundle_identifier != NULL) {
QString bundle_identifier(qtKey(main_bundle_identifier));
// CFBundleGetIdentifier returns identifier separated by slashes rather than periods.
- QStringList bundle_identifier_components = bundle_identifier.split(QLatin1String("/"));
+ QStringList bundle_identifier_components = bundle_identifier.split(QLatin1Char('/'));
// pre-reverse them so that when they get reversed again below, they are in the com.company.product format.
QStringList bundle_identifier_components_reversed;
for (int i=0; i<bundle_identifier_components.size(); ++i) {
@@ -403,11 +403,11 @@ QMacSettingsPrivate::QMacSettingsPrivate(QSettings::Scope scope, const QString &
}
while ((nextDot = domainName.indexOf(QLatin1Char('.'), curPos)) != -1) {
- javaPackageName.prepend(domainName.mid(curPos, nextDot - curPos));
+ javaPackageName.prepend(domainName.midRef(curPos, nextDot - curPos));
javaPackageName.prepend(QLatin1Char('.'));
curPos = nextDot + 1;
}
- javaPackageName.prepend(domainName.mid(curPos));
+ javaPackageName.prepend(domainName.midRef(curPos));
javaPackageName = javaPackageName.toLower();
if (curPos == 0)
javaPackageName.prepend(QLatin1String("com."));
diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp
index 0a13f94f05..ed1c14ad8a 100644
--- a/src/corelib/io/qstandardpaths_win.cpp
+++ b/src/corelib/io/qstandardpaths_win.cpp
@@ -200,7 +200,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
case AppDataLocation:
case AppLocalDataLocation:
case GenericDataLocation:
- if (SHGetSpecialFolderPath(0, path, clsidForAppDataLocation(type), FALSE)) {
+ if (SHGetSpecialFolderPath(0, path, CSIDL_COMMON_APPDATA, FALSE)) {
QString result = convertCharArray(path);
if (type != GenericDataLocation && type != GenericConfigLocation) {
#ifndef QT_BOOTSTRAPPED
diff --git a/src/corelib/io/qtemporarydir.cpp b/src/corelib/io/qtemporarydir.cpp
index c7150d7b33..71436c6497 100644
--- a/src/corelib/io/qtemporarydir.cpp
+++ b/src/corelib/io/qtemporarydir.cpp
@@ -49,6 +49,10 @@
#include <private/qfilesystemengine_p.h>
#endif
+#if !defined(Q_OS_WIN)
+#include <errno.h>
+#endif
+
QT_BEGIN_NAMESPACE
//************* QTemporaryDirPrivate
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index ca3be9b7e0..ccf832e2e8 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -2858,7 +2858,7 @@ QTextStream &endl(QTextStream &stream)
/*!
\relates QTextStream
- Calls \l{QTextStream::flush()}{flush()} on \a stream and returns \a stream.
+ Calls QTextStream::flush() on \a stream and returns \a stream.
\sa endl(), reset(), {QTextStream manipulators}
*/
diff --git a/src/corelib/io/qtldurl.cpp b/src/corelib/io/qtldurl.cpp
index d68d0ddf46..265055083e 100644
--- a/src/corelib/io/qtldurl.cpp
+++ b/src/corelib/io/qtldurl.cpp
@@ -99,19 +99,14 @@ Q_CORE_EXPORT bool qIsEffectiveTLD(const QString &domain)
if (containsTLDEntry(domain))
return true;
- if (domain.contains(QLatin1Char('.'))) {
- int count = domain.size() - domain.indexOf(QLatin1Char('.'));
- QString wildCardDomain;
- wildCardDomain.reserve(count + 1);
- wildCardDomain.append(QLatin1Char('*'));
- wildCardDomain.append(domain.right(count));
+ const int dot = domain.indexOf(QLatin1Char('.'));
+ if (dot >= 0) {
+ int count = domain.size() - dot;
+ QString wildCardDomain = QLatin1Char('*') + domain.rightRef(count);
// 2. if table contains '*.bar.com',
// test if table contains '!foo.bar.com'
if (containsTLDEntry(wildCardDomain)) {
- QString exceptionDomain;
- exceptionDomain.reserve(domain.size() + 1);
- exceptionDomain.append(QLatin1Char('!'));
- exceptionDomain.append(domain);
+ QString exceptionDomain = QLatin1Char('!') + domain;
return (! containsTLDEntry(exceptionDomain));
}
}
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 89f5aad97f..9bf359222a 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -2411,8 +2411,8 @@ void QUrl::setPort(int port)
d->clearError();
if (port < -1 || port > 65535) {
- port = -1;
d->setError(QUrlPrivate::InvalidPortError, QString::number(port), 0);
+ port = -1;
}
d->port = port;
diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp
index 2cc5741250..a49fcdaf9f 100644
--- a/src/corelib/io/qwindowspipereader.cpp
+++ b/src/corelib/io/qwindowspipereader.cpp
@@ -187,7 +187,7 @@ void QWindowsPipeReader::notified(quint32 numberOfBytesRead, quint32 errorCode,
pipeBroken = true;
break;
default:
- emit winError(errorCode, QLatin1String("QWindowsPipeReader::completeAsyncRead"));
+ emit winError(errorCode, QLatin1String("QWindowsPipeReader::notified"));
pipeBroken = true;
break;
}
diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp
index 57053f129a..fd14523d45 100644
--- a/src/corelib/io/qwindowspipewriter.cpp
+++ b/src/corelib/io/qwindowspipewriter.cpp
@@ -90,11 +90,38 @@ qint64 QWindowsPipeWriter::write(const char *ptr, qint64 maxlen)
return maxlen;
}
+class QPipeWriterOverlapped
+{
+public:
+ QPipeWriterOverlapped()
+ {
+ overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ }
+
+ ~QPipeWriterOverlapped()
+ {
+ CloseHandle(overlapped.hEvent);
+ }
+
+ void prepare()
+ {
+ const HANDLE hEvent = overlapped.hEvent;
+ ZeroMemory(&overlapped, sizeof overlapped);
+ overlapped.hEvent = hEvent;
+ }
+
+ OVERLAPPED *operator&()
+ {
+ return &overlapped;
+ }
+
+private:
+ OVERLAPPED overlapped;
+};
+
void QWindowsPipeWriter::run()
{
- OVERLAPPED overl;
- memset(&overl, 0, sizeof overl);
- overl.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ QPipeWriterOverlapped overl;
forever {
lock.lock();
while(data.isEmpty() && (!quitNow)) {
@@ -115,26 +142,24 @@ void QWindowsPipeWriter::run()
const char *ptrData = copy.data();
qint64 maxlen = copy.size();
qint64 totalWritten = 0;
- overl.Offset = 0;
- overl.OffsetHigh = 0;
+ overl.prepare();
while ((!quitNow) && totalWritten < maxlen) {
DWORD written = 0;
if (!WriteFile(writePipe, ptrData + totalWritten,
maxlen - totalWritten, &written, &overl)) {
-
- if (GetLastError() == 0xE8/*NT_STATUS_INVALID_USER_BUFFER*/) {
+ const DWORD writeError = GetLastError();
+ if (writeError == 0xE8/*NT_STATUS_INVALID_USER_BUFFER*/) {
// give the os a rest
msleep(100);
continue;
}
#ifndef Q_OS_WINCE
- if (GetLastError() == ERROR_IO_PENDING) {
- if (!GetOverlappedResult(writePipe, &overl, &written, TRUE)) {
- CloseHandle(overl.hEvent);
- return;
- }
- } else {
- CloseHandle(overl.hEvent);
+ if (writeError != ERROR_IO_PENDING) {
+ qErrnoWarning(writeError, "QWindowsPipeWriter: async WriteFile failed.");
+ return;
+ }
+ if (!GetOverlappedResult(writePipe, &overl, &written, TRUE)) {
+ qErrnoWarning(GetLastError(), "QWindowsPipeWriter: GetOverlappedResult failed.");
return;
}
#else
@@ -154,7 +179,6 @@ void QWindowsPipeWriter::run()
emit bytesWritten(totalWritten);
emit canWrite();
}
- CloseHandle(overl.hEvent);
}
#endif //QT_NO_THREAD
diff --git a/src/corelib/json/qjsondocument.cpp b/src/corelib/json/qjsondocument.cpp
index f5bad32233..3ef006d82d 100644
--- a/src/corelib/json/qjsondocument.cpp
+++ b/src/corelib/json/qjsondocument.cpp
@@ -574,7 +574,7 @@ QDebug operator<<(QDebug dbg, const QJsonDocument &o)
QJsonPrivate::Writer::objectToJson(static_cast<QJsonPrivate::Object *>(o.d->header->root()), json, 0, true);
dbg.nospace() << "QJsonDocument("
<< json.constData() // print as utf-8 string without extra quotation marks
- << ")";
+ << ')';
return dbg;
}
#endif
diff --git a/src/corelib/json/qjsonvalue.cpp b/src/corelib/json/qjsonvalue.cpp
index ae6a3678bd..4c7a44b4a0 100644
--- a/src/corelib/json/qjsonvalue.cpp
+++ b/src/corelib/json/qjsonvalue.cpp
@@ -738,23 +738,23 @@ QDebug operator<<(QDebug dbg, const QJsonValue &o)
dbg << "QJsonValue(null)";
break;
case QJsonValue::Bool:
- dbg.nospace() << "QJsonValue(bool, " << o.toBool() << ")";
+ dbg.nospace() << "QJsonValue(bool, " << o.toBool() << ')';
break;
case QJsonValue::Double:
- dbg.nospace() << "QJsonValue(double, " << o.toDouble() << ")";
+ dbg.nospace() << "QJsonValue(double, " << o.toDouble() << ')';
break;
case QJsonValue::String:
- dbg.nospace() << "QJsonValue(string, " << o.toString() << ")";
+ dbg.nospace() << "QJsonValue(string, " << o.toString() << ')';
break;
case QJsonValue::Array:
dbg.nospace() << "QJsonValue(array, ";
dbg << o.toArray();
- dbg << ")";
+ dbg << ')';
break;
case QJsonValue::Object:
dbg.nospace() << "QJsonValue(object, ";
dbg << o.toObject();
- dbg << ")";
+ dbg << ')';
break;
}
return dbg;
diff --git a/src/corelib/json/qjsonwriter.cpp b/src/corelib/json/qjsonwriter.cpp
index 99f83554c2..45a05e93a3 100644
--- a/src/corelib/json/qjsonwriter.cpp
+++ b/src/corelib/json/qjsonwriter.cpp
@@ -137,13 +137,13 @@ static void valueToJson(const QJsonPrivate::Base *b, const QJsonPrivate::Value &
json += compact ? "[" : "[\n";
arrayContentToJson(static_cast<QJsonPrivate::Array *>(v.base(b)), json, indent + (compact ? 0 : 1), compact);
json += QByteArray(4*indent, ' ');
- json += "]";
+ json += ']';
break;
case QJsonValue::Object:
json += compact ? "{" : "{\n";
objectContentToJson(static_cast<QJsonPrivate::Object *>(v.base(b)), json, indent + (compact ? 0 : 1), compact);
json += QByteArray(4*indent, ' ');
- json += "}";
+ json += '}';
break;
case QJsonValue::Null:
default:
diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h
index c744873fce..f80dcb5a50 100644
--- a/src/corelib/kernel/qcore_unix_p.h
+++ b/src/corelib/kernel/qcore_unix_p.h
@@ -47,6 +47,7 @@
#include "qplatformdefs.h"
#include "qatomic.h"
+#include "qhash.h"
#ifndef Q_OS_UNIX
# error "qcore_unix_p.h included on a non-Unix system"
@@ -322,6 +323,19 @@ union qt_semun {
unsigned short *array; /* array for GETALL, SETALL */
};
+#ifndef QT_POSIX_IPC
+#ifndef QT_NO_SHAREDMEMORY
+#ifndef Q_OS_ANDROID
+static inline key_t qt_safe_ftok(const QByteArray &filename, int proj_id)
+{
+ // Unfortunately ftok can return colliding keys even for different files.
+ // Try to add some more entropy via qHash.
+ return ::ftok(filename.constData(), qHash(filename, proj_id));
+}
+#endif // !Q_OS_ANDROID
+#endif // !QT_NO_SHAREDMEMORY
+#endif // !QT_POSIX_IPC
+
QT_END_NAMESPACE
#endif
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 3013db8b2e..53725c7f90 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -455,8 +455,8 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint
qt_application_thread_id = QThread::currentThreadId();
# endif
- // note: this call to QThread::currentThread() may end up setting theMainThread!
- if (QThread::currentThread() != theMainThread)
+ QThread *cur = QThread::currentThread(); // note: this may end up setting theMainThread!
+ if (cur != theMainThread)
qWarning("WARNING: QApplication was not created in the main() thread.");
#endif
}
@@ -526,11 +526,11 @@ void QCoreApplicationPrivate::eventDispatcherReady()
{
}
-QThread *QCoreApplicationPrivate::theMainThread = 0;
+QBasicAtomicPointer<QThread> QCoreApplicationPrivate::theMainThread = Q_BASIC_ATOMIC_INITIALIZER(0);
QThread *QCoreApplicationPrivate::mainThread()
{
- Q_ASSERT(theMainThread != 0);
- return theMainThread;
+ Q_ASSERT(theMainThread.load() != 0);
+ return theMainThread.load();
}
bool QCoreApplicationPrivate::threadRequiresCoreApplication()
@@ -2759,7 +2759,7 @@ bool QCoreApplication::hasPendingEvents()
QAbstractEventDispatcher *QCoreApplication::eventDispatcher()
{
if (QCoreApplicationPrivate::theMainThread)
- return QCoreApplicationPrivate::theMainThread->eventDispatcher();
+ return QCoreApplicationPrivate::theMainThread.load()->eventDispatcher();
return 0;
}
diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h
index 21f59d8197..9a9e8dd09a 100644
--- a/src/corelib/kernel/qcoreapplication_p.h
+++ b/src/corelib/kernel/qcoreapplication_p.h
@@ -105,7 +105,7 @@ public:
}
void maybeQuit();
- static QThread *theMainThread;
+ static QBasicAtomicPointer<QThread> theMainThread;
static QThread *mainThread();
static bool threadRequiresCoreApplication();
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index e8ff8a7936..ecaa78cbbc 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -390,6 +390,8 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA
QSockNot *sn = dict ? dict->value(wp) : 0;
if (sn) {
+ d->doWsaAsyncSelect(sn->fd, 0);
+ d->active_fd[sn->fd].selected = false;
if (type < 3) {
QEvent event(QEvent::SockAct);
QCoreApplication::sendEvent(sn->obj, &event);
@@ -632,19 +634,12 @@ void QEventDispatcherWin32Private::sendTimerEvent(int timerId)
}
}
-void QEventDispatcherWin32Private::doWsaAsyncSelect(int socket)
+void QEventDispatcherWin32Private::doWsaAsyncSelect(int socket, long event)
{
Q_ASSERT(internalHwnd);
- int sn_event = 0;
- if (sn_read.contains(socket))
- sn_event |= FD_READ | FD_CLOSE | FD_ACCEPT;
- if (sn_write.contains(socket))
- sn_event |= FD_WRITE | FD_CONNECT;
- if (sn_except.contains(socket))
- sn_event |= FD_OOB;
- // BoundsChecker may emit a warning for WSAAsyncSelect when sn_event == 0
+ // BoundsChecker may emit a warning for WSAAsyncSelect when event == 0
// This is a BoundsChecker bug and not a Qt bug
- WSAAsyncSelect(socket, internalHwnd, sn_event ? int(WM_QT_SOCKETNOTIFIER) : 0, sn_event);
+ WSAAsyncSelect(socket, internalHwnd, event ? int(WM_QT_SOCKETNOTIFIER) : 0, event);
}
void QEventDispatcherWin32::createInternalHwnd()
@@ -657,13 +652,6 @@ void QEventDispatcherWin32::createInternalHwnd()
installMessageHook();
- // register all socket notifiers
- QList<int> sockets = (d->sn_read.keys().toSet()
- + d->sn_write.keys().toSet()
- + d->sn_except.keys().toSet()).toList();
- for (int i = 0; i < sockets.count(); ++i)
- d->doWsaAsyncSelect(sockets.at(i));
-
// start all normal timers
for (int i = 0; i < d->timerVec.count(); ++i)
d->registerTimer(d->timerVec.at(i));
@@ -748,28 +736,40 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)
msg = d->queuedSocketEvents.takeFirst();
} else {
haveMessage = PeekMessage(&msg, 0, 0, 0, PM_REMOVE);
- if (haveMessage && (flags & QEventLoop::ExcludeUserInputEvents)
- && ((msg.message >= WM_KEYFIRST
- && msg.message <= WM_KEYLAST)
- || (msg.message >= WM_MOUSEFIRST
- && msg.message <= WM_MOUSELAST)
- || msg.message == WM_MOUSEWHEEL
- || msg.message == WM_MOUSEHWHEEL
- || msg.message == WM_TOUCH
+ if (haveMessage) {
+ if ((flags & QEventLoop::ExcludeUserInputEvents)
+ && ((msg.message >= WM_KEYFIRST
+ && msg.message <= WM_KEYLAST)
+ || (msg.message >= WM_MOUSEFIRST
+ && msg.message <= WM_MOUSELAST)
+ || msg.message == WM_MOUSEWHEEL
+ || msg.message == WM_MOUSEHWHEEL
+ || msg.message == WM_TOUCH
#ifndef QT_NO_GESTURES
- || msg.message == WM_GESTURE
- || msg.message == WM_GESTURENOTIFY
+ || msg.message == WM_GESTURE
+ || msg.message == WM_GESTURENOTIFY
#endif
- || msg.message == WM_CLOSE)) {
- // queue user input events for later processing
- haveMessage = false;
- d->queuedUserInputEvents.append(msg);
- }
- if (haveMessage && (flags & QEventLoop::ExcludeSocketNotifiers)
- && (msg.message == WM_QT_SOCKETNOTIFIER && msg.hwnd == d->internalHwnd)) {
- // queue socket events for later processing
- haveMessage = false;
- d->queuedSocketEvents.append(msg);
+ || msg.message == WM_CLOSE)) {
+ // queue user input events for later processing
+ d->queuedUserInputEvents.append(msg);
+ continue;
+ }
+ if ((flags & QEventLoop::ExcludeSocketNotifiers)
+ && (msg.message == WM_QT_SOCKETNOTIFIER && msg.hwnd == d->internalHwnd)) {
+ // queue socket events for later processing
+ d->queuedSocketEvents.append(msg);
+ continue;
+ }
+ } else if (!(flags & QEventLoop::ExcludeSocketNotifiers)) {
+ // register all socket notifiers
+ for (QSFDict::iterator it = d->active_fd.begin(), end = d->active_fd.end();
+ it != end; ++it) {
+ QSockFd &sd = it.value();
+ if (!sd.selected) {
+ d->doWsaAsyncSelect(it.key(), sd.event);
+ sd.selected = true;
+ }
+ }
}
}
if (!haveMessage) {
@@ -895,8 +895,25 @@ void QEventDispatcherWin32::registerSocketNotifier(QSocketNotifier *notifier)
sn->fd = sockfd;
dict->insert(sn->fd, sn);
- if (d->internalHwnd)
- d->doWsaAsyncSelect(sockfd);
+ long event = 0;
+ if (d->sn_read.contains(sockfd))
+ event |= FD_READ | FD_CLOSE | FD_ACCEPT;
+ if (d->sn_write.contains(sockfd))
+ event |= FD_WRITE | FD_CONNECT;
+ if (d->sn_except.contains(sockfd))
+ event |= FD_OOB;
+
+ QSFDict::iterator it = d->active_fd.find(sockfd);
+ if (it != d->active_fd.end()) {
+ QSockFd &sd = it.value();
+ if (sd.selected) {
+ d->doWsaAsyncSelect(sockfd, 0);
+ sd.selected = false;
+ }
+ sd.event |= event;
+ } else {
+ d->active_fd.insert(sockfd, QSockFd(event));
+ }
}
void QEventDispatcherWin32::unregisterSocketNotifier(QSocketNotifier *notifier)
@@ -915,6 +932,19 @@ void QEventDispatcherWin32::unregisterSocketNotifier(QSocketNotifier *notifier)
#endif
Q_D(QEventDispatcherWin32);
+ QSFDict::iterator it = d->active_fd.find(sockfd);
+ if (it != d->active_fd.end()) {
+ QSockFd &sd = it.value();
+ if (sd.selected)
+ d->doWsaAsyncSelect(sockfd, 0);
+ const long event[3] = { FD_READ | FD_CLOSE | FD_ACCEPT, FD_WRITE | FD_CONNECT, FD_OOB };
+ sd.event ^= event[type];
+ if (sd.event == 0)
+ d->active_fd.erase(it);
+ else
+ sd.selected = false;
+ }
+
QSNDict *sn_vec[3] = { &d->sn_read, &d->sn_write, &d->sn_except };
QSNDict *dict = sn_vec[type];
QSockNot *sn = dict->value(sockfd);
@@ -923,9 +953,6 @@ void QEventDispatcherWin32::unregisterSocketNotifier(QSocketNotifier *notifier)
dict->remove(sockfd);
delete sn;
-
- if (d->internalHwnd)
- d->doWsaAsyncSelect(sockfd);
}
void QEventDispatcherWin32::registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object)
@@ -1163,6 +1190,7 @@ void QEventDispatcherWin32::closingDown()
unregisterSocketNotifier((*(d->sn_write.begin()))->obj);
while (!d->sn_except.isEmpty())
unregisterSocketNotifier((*(d->sn_except.begin()))->obj);
+ Q_ASSERT(d->active_fd.isEmpty());
// clean up any timers
for (int i = 0; i < d->timerVec.count(); ++i)
diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h
index e59e29f1ff..8578110ee4 100644
--- a/src/corelib/kernel/qeventdispatcher_win_p.h
+++ b/src/corelib/kernel/qeventdispatcher_win_p.h
@@ -115,6 +115,14 @@ struct QSockNot {
};
typedef QHash<int, QSockNot *> QSNDict;
+struct QSockFd {
+ long event;
+ bool selected;
+
+ explicit inline QSockFd(long ev = 0) : event(ev), selected(false) { }
+};
+typedef QHash<int, QSockFd> QSFDict;
+
struct WinTimerInfo { // internal timer info
QObject *dispatcher;
int timerId;
@@ -169,7 +177,8 @@ public:
QSNDict sn_read;
QSNDict sn_write;
QSNDict sn_except;
- void doWsaAsyncSelect(int socket);
+ QSFDict active_fd;
+ void doWsaAsyncSelect(int socket, long event);
QList<QWinEventNotifier *> winEventNotifierList;
void activateEventNotifier(QWinEventNotifier * wen);
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 7ae9fef622..820af298c0 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
-** Copyright (C) 2014 Olivier Goffart <ogoffart@woboq.com>
+** Copyright (C) 2015 Olivier Goffart <ogoffart@woboq.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -1547,12 +1547,13 @@ bool QMetaObject::invokeMethod(QObject *obj,
/*!
\fn QMetaObject::Connection &QMetaObject::Connection::operator=(Connection &&other)
- Move-assigns \a other to this object.
+ Move-assigns \a other to this object, and returns a reference.
*/
/*!
\fn QMetaObject::Connection::Connection(Connection &&o)
- Move-constructs a Connection instance, making it point to the same object that \a o was pointing to.
+ Move-constructs a Connection instance, making it point to the same object
+ that \a o was pointing to.
*/
/*!
@@ -3027,6 +3028,11 @@ QVariant QMetaProperty::read(const QObject *object) const
Writes \a value as the property's value to the given \a object. Returns
true if the write succeeded; otherwise returns \c false.
+ If \a value is not of the same type type as the property, a conversion
+ is attempted. An empty QVariant() is equivalent to a call to reset()
+ if this property is resetable, or setting a default-constructed object
+ otherwise.
+
\sa read(), reset(), isWritable()
*/
bool QMetaProperty::write(QObject *object, const QVariant &value) const
@@ -3067,8 +3073,15 @@ bool QMetaProperty::write(QObject *object, const QVariant &value) const
if (t == QMetaType::UnknownType)
return false;
}
- if (t != QMetaType::QVariant && t != (uint)value.userType() && (t < QMetaType::User && !v.convert((QVariant::Type)t)))
- return false;
+ if (t != QMetaType::QVariant && int(t) != value.userType()) {
+ if (!value.isValid()) {
+ if (isResettable())
+ return reset(object);
+ v = QVariant(t, 0);
+ } else if (!v.convert(t)) {
+ return false;
+ }
+ }
}
// the status variable is changed by qt_metacall to indicate what it did
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index d324b6f150..c9884cd76c 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -1485,7 +1485,7 @@ void QObject::moveToThread(QThread *targetThread)
} else if (d->threadData != currentData) {
qWarning("QObject::moveToThread: Current thread (%p) is not the object's thread (%p).\n"
"Cannot move to target thread (%p)\n",
- currentData->thread, d->threadData->thread, targetData ? targetData->thread : Q_NULLPTR);
+ currentData->thread.load(), d->threadData->thread.load(), targetData ? targetData->thread.load() : Q_NULLPTR);
#ifdef Q_OS_MAC
qWarning("You might be loading two sets of Qt binaries into the same process. "
@@ -3831,7 +3831,7 @@ int QObjectPrivate::signalIndex(const char *signalName,
\b{Note:} Dynamic properties starting with "_q_" are reserved for internal
purposes.
- \sa property(), metaObject(), dynamicPropertyNames()
+ \sa property(), metaObject(), dynamicPropertyNames(), QMetaProperty::write()
*/
bool QObject::setProperty(const char *name, const QVariant &value)
{
diff --git a/src/corelib/kernel/qsharedmemory_systemv.cpp b/src/corelib/kernel/qsharedmemory_systemv.cpp
index 29fee12c0b..0d2eea49e9 100644
--- a/src/corelib/kernel/qsharedmemory_systemv.cpp
+++ b/src/corelib/kernel/qsharedmemory_systemv.cpp
@@ -82,7 +82,7 @@ key_t QSharedMemoryPrivate::handle()
return 0;
}
- unix_key = ftok(QFile::encodeName(nativeKey).constData(), 'Q');
+ unix_key = qt_safe_ftok(QFile::encodeName(nativeKey), 'Q');
if (-1 == unix_key) {
errorString = QSharedMemory::tr("%1: ftok failed").arg(QLatin1String("QSharedMemory::handle:"));
error = QSharedMemory::KeyError;
diff --git a/src/corelib/kernel/qsocketnotifier.cpp b/src/corelib/kernel/qsocketnotifier.cpp
index d789af2fd9..3a5eff0c19 100644
--- a/src/corelib/kernel/qsocketnotifier.cpp
+++ b/src/corelib/kernel/qsocketnotifier.cpp
@@ -98,42 +98,6 @@ public:
QTcpSocket and QUdpSocket provide notification through signals, so
there is normally no need to use a QSocketNotifier on them.
- \section1 Notes for Windows Users
-
- The socket passed to QSocketNotifier will become non-blocking, even if
- it was created as a blocking socket.
- The activated() signal is sometimes triggered by high general activity
- on the host, even if there is nothing to read. A subsequent read from
- the socket can then fail, the error indicating that there is no data
- available (e.g., \c{WSAEWOULDBLOCK}). This is an operating system
- limitation, and not a bug in QSocketNotifier.
-
- To ensure that the socket notifier handles read notifications correctly,
- follow these steps when you receive a notification:
-
- \list 1
- \li Disable the notifier.
- \li Read data from the socket.
- \li Re-enable the notifier if you are interested in more data (such as after
- having written a new command to a remote server).
- \endlist
-
- To ensure that the socket notifier handles write notifications correctly,
- follow these steps when you receive a notification:
-
- \list 1
- \li Disable the notifier.
- \li Write as much data as you can (before \c EWOULDBLOCK is returned).
- \li Re-enable notifier if you have more data to write.
- \endlist
-
- \b{Further information:}
- On Windows, Qt always disables the notifier after getting a notification,
- and only re-enables it if more data is expected. For example, if data is
- read from the socket and it can be used to read more, or if reading or
- writing is not possible because the socket would block, in which case
- it is necessary to wait before attempting to read or write again.
-
\sa QFile, QProcess, QTcpSocket, QUdpSocket
*/
diff --git a/src/corelib/kernel/qsystemsemaphore_systemv.cpp b/src/corelib/kernel/qsystemsemaphore_systemv.cpp
index 32a4bdef51..490de5f9ee 100644
--- a/src/corelib/kernel/qsystemsemaphore_systemv.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_systemv.cpp
@@ -85,7 +85,7 @@ key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode)
createdFile = (1 == built);
// Get the unix key for the created file
- unix_key = ftok(QFile::encodeName(fileName).constData(), 'Q');
+ unix_key = qt_safe_ftok(QFile::encodeName(fileName), 'Q');
if (-1 == unix_key) {
errorString = QCoreApplication::tr("%1: ftok failed", "QSystemSemaphore").arg(QLatin1String("QSystemSemaphore::handle:"));
error = QSystemSemaphore::KeyError;
diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp
index b9109a96aa..af9a1be6ab 100644
--- a/src/corelib/kernel/qtimer.cpp
+++ b/src/corelib/kernel/qtimer.cpp
@@ -278,15 +278,10 @@ QSingleShotTimer::QSingleShotTimer(int msec, Qt::TimerType timerType, const QObj
{
timerId = startTimer(msec, timerType);
if (r && thread() != r->thread()) {
- // We need the invocation to happen in the receiver object's thread.
- // So, move QSingleShotTimer to the correct thread. Before that occurs, we
- // shall remove the parent from the object.
+ // Avoid leaking the QSingleShotTimer instance in case the application exits before the timer fires
+ connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &QObject::deleteLater);
setParent(0);
moveToThread(r->thread());
-
- // Given we're also parentless now, we should take defence against leaks
- // in case the application quits before we expire.
- connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &QObject::deleteLater);
}
}
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 35f178e6a9..fdcbdb1c45 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -413,7 +413,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
QString *str = static_cast<QString *>(result);
switch (d->type) {
case QVariant::Char:
- *str = QString(*v_cast<QChar>(d));
+ *str = *v_cast<QChar>(d);
break;
case QMetaType::Char:
case QMetaType::SChar:
diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp
index 133933f9af..c1e17b9fc4 100644
--- a/src/corelib/mimetypes/qmimedatabase.cpp
+++ b/src/corelib/mimetypes/qmimedatabase.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
diff --git a/src/corelib/mimetypes/qmimedatabase.h b/src/corelib/mimetypes/qmimedatabase.h
index 912d9b8443..fd19636e27 100644
--- a/src/corelib/mimetypes/qmimedatabase.h
+++ b/src/corelib/mimetypes/qmimedatabase.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
diff --git a/src/corelib/mimetypes/qmimedatabase_p.h b/src/corelib/mimetypes/qmimedatabase_p.h
index 1308907b9b..1ac7264a9e 100644
--- a/src/corelib/mimetypes/qmimedatabase_p.h
+++ b/src/corelib/mimetypes/qmimedatabase_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
diff --git a/src/corelib/mimetypes/qmimemagicrule.cpp b/src/corelib/mimetypes/qmimemagicrule.cpp
index c8508ac0d2..6a3a429179 100644
--- a/src/corelib/mimetypes/qmimemagicrule.cpp
+++ b/src/corelib/mimetypes/qmimemagicrule.cpp
@@ -38,6 +38,7 @@
#ifndef QT_NO_MIMETYPE
+#include "qmimetypeparser_p.h"
#include <QtCore/QList>
#include <QtCore/QDebug>
#include <qendian.h>
@@ -231,26 +232,53 @@ static inline QByteArray makePattern(const QByteArray &value)
return pattern;
}
-QMimeMagicRule::QMimeMagicRule(QMimeMagicRule::Type theType,
+// Evaluate a magic match rule like
+// <match value="must be converted with BinHex" type="string" offset="11"/>
+// <match value="0x9501" type="big16" offset="0:64"/>
+
+QMimeMagicRule::QMimeMagicRule(const QString &typeStr,
const QByteArray &theValue,
- int theStartPos,
- int theEndPos,
- const QByteArray &theMask) :
+ const QString &offsets,
+ const QByteArray &theMask,
+ QString *errorString) :
d(new QMimeMagicRulePrivate)
{
- Q_ASSERT(!theValue.isEmpty());
-
- d->type = theType;
d->value = theValue;
- d->startPos = theStartPos;
- d->endPos = theEndPos;
d->mask = theMask;
d->matchFunction = 0;
+ d->type = QMimeMagicRule::type(typeStr.toLatin1());
+ if (d->type == Invalid) {
+ *errorString = QStringLiteral("Type %s is not supported").arg(typeStr);
+ }
+
+ // Parse for offset as "1" or "1:10"
+ const int colonIndex = offsets.indexOf(QLatin1Char(':'));
+ const QString startPosStr = colonIndex == -1 ? offsets : offsets.mid(0, colonIndex);
+ const QString endPosStr = colonIndex == -1 ? offsets : offsets.mid(colonIndex + 1);
+ if (!QMimeTypeParserBase::parseNumber(startPosStr, &d->startPos, errorString) ||
+ !QMimeTypeParserBase::parseNumber(endPosStr, &d->endPos, errorString)) {
+ d->type = Invalid;
+ return;
+ }
+
+ if (d->value.isEmpty()) {
+ d->type = Invalid;
+ if (errorString)
+ *errorString = QLatin1String("Invalid empty magic rule value");
+ return;
+ }
+
if (d->type >= Host16 && d->type <= Byte) {
bool ok;
d->number = d->value.toUInt(&ok, 0); // autodetect
- Q_ASSERT(ok);
+ if (!ok) {
+ d->type = Invalid;
+ if (errorString)
+ *errorString = QString::fromLatin1("Invalid magic rule value \"%1\"").arg(
+ QString::fromLatin1(d->value));
+ return;
+ }
d->numberMask = !d->mask.isEmpty() ? d->mask.toUInt(&ok, 0) : 0; // autodetect
}
@@ -259,9 +287,23 @@ QMimeMagicRule::QMimeMagicRule(QMimeMagicRule::Type theType,
d->pattern = makePattern(d->value);
d->pattern.squeeze();
if (!d->mask.isEmpty()) {
- Q_ASSERT(d->mask.size() >= 4 && d->mask.startsWith("0x"));
- d->mask = QByteArray::fromHex(QByteArray::fromRawData(d->mask.constData() + 2, d->mask.size() - 2));
- Q_ASSERT(d->mask.size() == d->pattern.size());
+ if (d->mask.size() < 4 || !d->mask.startsWith("0x")) {
+ d->type = Invalid;
+ if (errorString)
+ *errorString = QString::fromLatin1("Invalid magic rule mask \"%1\"").arg(
+ QString::fromLatin1(d->mask));
+ return;
+ }
+ const QByteArray &tempMask = QByteArray::fromHex(QByteArray::fromRawData(
+ d->mask.constData() + 2, d->mask.size() - 2));
+ if (tempMask.size() != d->pattern.size()) {
+ d->type = Invalid;
+ if (errorString)
+ *errorString = QString::fromLatin1("Invalid magic rule mask size \"%1\"").arg(
+ QString::fromLatin1(d->mask));
+ return;
+ }
+ d->mask = tempMask;
} else {
d->mask.fill(char(-1), d->pattern.size());
}
diff --git a/src/corelib/mimetypes/qmimemagicrule_p.h b/src/corelib/mimetypes/qmimemagicrule_p.h
index 03ac1d1de9..6b64bfcc10 100644
--- a/src/corelib/mimetypes/qmimemagicrule_p.h
+++ b/src/corelib/mimetypes/qmimemagicrule_p.h
@@ -61,7 +61,8 @@ class QMimeMagicRule
public:
enum Type { Invalid = 0, String, Host16, Host32, Big16, Big32, Little16, Little32, Byte };
- QMimeMagicRule(Type type, const QByteArray &value, int startPos, int endPos, const QByteArray &mask = QByteArray());
+ QMimeMagicRule(const QString &typeStr, const QByteArray &value, const QString &offsets,
+ const QByteArray &mask, QString *errorString);
QMimeMagicRule(const QMimeMagicRule &other);
~QMimeMagicRule();
diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp
index fa40b743d3..a8a1331053 100644
--- a/src/corelib/mimetypes/qmimeprovider.cpp
+++ b/src/corelib/mimetypes/qmimeprovider.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
diff --git a/src/corelib/mimetypes/qmimeprovider_p.h b/src/corelib/mimetypes/qmimeprovider_p.h
index eaf95942f7..c0517d69a4 100644
--- a/src/corelib/mimetypes/qmimeprovider_p.h
+++ b/src/corelib/mimetypes/qmimeprovider_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp
index 3206ff66e3..e3b01bbb89 100644
--- a/src/corelib/mimetypes/qmimetype.cpp
+++ b/src/corelib/mimetypes/qmimetype.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
diff --git a/src/corelib/mimetypes/qmimetype.h b/src/corelib/mimetypes/qmimetype.h
index 3c153da21d..6a00541ebc 100644
--- a/src/corelib/mimetypes/qmimetype.h
+++ b/src/corelib/mimetypes/qmimetype.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com>
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -44,7 +45,6 @@
QT_BEGIN_NAMESPACE
class QMimeTypePrivate;
-class QFileinfo;
class QStringList;
class QMimeType;
diff --git a/src/corelib/mimetypes/qmimetypeparser.cpp b/src/corelib/mimetypes/qmimetypeparser.cpp
index 9610162c4f..8a8b97655a 100644
--- a/src/corelib/mimetypes/qmimetypeparser.cpp
+++ b/src/corelib/mimetypes/qmimetypeparser.cpp
@@ -153,8 +153,8 @@ QMimeTypeParserBase::ParseState QMimeTypeParserBase::nextState(ParseState curren
return ParseError;
}
-// Parse int number from an (attribute) string)
-static bool parseNumber(const QString &n, int *target, QString *errorMessage)
+// Parse int number from an (attribute) string
+bool QMimeTypeParserBase::parseNumber(const QString &n, int *target, QString *errorMessage)
{
bool ok;
*target = n.toInt(&ok);
@@ -165,37 +165,14 @@ static bool parseNumber(const QString &n, int *target, QString *errorMessage)
return true;
}
-// Evaluate a magic match rule like
-// <match value="must be converted with BinHex" type="string" offset="11"/>
-// <match value="0x9501" type="big16" offset="0:64"/>
#ifndef QT_NO_XMLSTREAMREADER
-static bool createMagicMatchRule(const QXmlStreamAttributes &atts,
- QString *errorMessage, QMimeMagicRule *&rule)
+static QMimeMagicRule *createMagicMatchRule(const QXmlStreamAttributes &atts, QString *errorMessage)
{
const QString type = atts.value(QLatin1String(matchTypeAttributeC)).toString();
- QMimeMagicRule::Type magicType = QMimeMagicRule::type(type.toLatin1());
- if (magicType == QMimeMagicRule::Invalid) {
- qWarning("%s: match type %s is not supported.", Q_FUNC_INFO, type.toUtf8().constData());
- return true;
- }
const QString value = atts.value(QLatin1String(matchValueAttributeC)).toString();
- if (value.isEmpty()) {
- *errorMessage = QString::fromLatin1("Empty match value detected.");
- return false;
- }
- // Parse for offset as "1" or "1:10"
- int startPos, endPos;
- const QString offsetS = atts.value(QLatin1String(matchOffsetAttributeC)).toString();
- const int colonIndex = offsetS.indexOf(QLatin1Char(':'));
- const QString startPosS = colonIndex == -1 ? offsetS : offsetS.mid(0, colonIndex);
- const QString endPosS = colonIndex == -1 ? offsetS : offsetS.mid(colonIndex + 1);
- if (!parseNumber(startPosS, &startPos, errorMessage) || !parseNumber(endPosS, &endPos, errorMessage))
- return false;
+ const QString offsets = atts.value(QLatin1String(matchOffsetAttributeC)).toString();
const QString mask = atts.value(QLatin1String(matchMaskAttributeC)).toString();
-
- rule = new QMimeMagicRule(magicType, value.toUtf8(), startPos, endPos, mask.toLatin1());
-
- return true;
+ return new QMimeMagicRule(type, value.toUtf8(), offsets, mask.toLatin1(), errorMessage);
}
#endif
@@ -283,9 +260,10 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
}
break;
case ParseMagicMatchRule: {
- QMimeMagicRule *rule = 0;
- if (!createMagicMatchRule(atts, errorMessage, rule))
- return false;
+ QString magicErrorMessage;
+ QMimeMagicRule *rule = createMagicMatchRule(atts, &magicErrorMessage);
+ if (!rule->isValid())
+ qWarning("QMimeDatabase: Error parsing %s\n%s", qPrintable(fileName), qPrintable(magicErrorMessage));
QList<QMimeMagicRule> *ruleList;
if (currentRules.isEmpty())
ruleList = &rules;
diff --git a/src/corelib/mimetypes/qmimetypeparser_p.h b/src/corelib/mimetypes/qmimetypeparser_p.h
index 2be4380cee..3a2e6b8a14 100644
--- a/src/corelib/mimetypes/qmimetypeparser_p.h
+++ b/src/corelib/mimetypes/qmimetypeparser_p.h
@@ -66,6 +66,8 @@ public:
bool parse(QIODevice *dev, const QString &fileName, QString *errorMessage);
+ static bool parseNumber(const QString &n, int *target, QString *errorMessage);
+
protected:
virtual bool process(const QMimeType &t, QString *errorMessage) = 0;
virtual bool process(const QMimeGlobPattern &t, QString *errorMessage) = 0;
diff --git a/src/corelib/plugin/qelfparser_p.cpp b/src/corelib/plugin/qelfparser_p.cpp
index d93be439e0..3798231383 100644
--- a/src/corelib/plugin/qelfparser_p.cpp
+++ b/src/corelib/plugin/qelfparser_p.cpp
@@ -148,7 +148,7 @@ int QElfParser::parse(const char *dataStart, ulong fdlen, const QString &library
#endif
ElfSectionHeader strtab;
- qulonglong soff = e_shoff + e_shentsize * (e_shtrndx);
+ qulonglong soff = e_shoff + qelfword_t(e_shentsize) * qelfword_t(e_shtrndx);
if ((soff + e_shentsize) > fdlen || soff % 4 || soff == 0) {
if (lib)
diff --git a/src/corelib/plugin/qplugin.qdoc b/src/corelib/plugin/qplugin.qdoc
index 94f5bc8a30..00ecb30430 100644
--- a/src/corelib/plugin/qplugin.qdoc
+++ b/src/corelib/plugin/qplugin.qdoc
@@ -28,7 +28,7 @@
/*!
\headerfile <QtPlugin>
\title Defining Plugins
- \target qtplugin-defining-plugins
+ \keyword qtplugin-defining-plugins
\ingroup plugins
\brief The <QtPlugin> header file defines macros for defining plugins.
diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp
index b95f7539f6..8264a27842 100644
--- a/src/corelib/plugin/qpluginloader.cpp
+++ b/src/corelib/plugin/qpluginloader.cpp
@@ -286,9 +286,9 @@ static QString locatePlugin(const QString& fileName)
suffixes.prepend(QString());
// Split up "subdir/filename"
- const int slash = fileName.lastIndexOf('/');
- const QString baseName = fileName.mid(slash + 1);
- const QString basePath = isAbsolute ? QString() : fileName.left(slash + 1); // keep the '/'
+ const int slash = fileName.lastIndexOf(QLatin1Char('/'));
+ const QStringRef baseName = fileName.midRef(slash + 1);
+ const QStringRef basePath = isAbsolute ? QStringRef() : fileName.leftRef(slash + 1); // keep the '/'
const bool debug = qt_debug_component();
diff --git a/src/corelib/statemachine/qhistorystate.cpp b/src/corelib/statemachine/qhistorystate.cpp
index a0ebb9d239..8887ce27e5 100644
--- a/src/corelib/statemachine/qhistorystate.cpp
+++ b/src/corelib/statemachine/qhistorystate.cpp
@@ -166,6 +166,8 @@ QHistoryState::~QHistoryState()
Returns this history state's default transition. The default transition is
taken when the history state has never been entered before. The target states
of the default transition therefore make up the default state.
+
+ \since 5.6
*/
QAbstractTransition *QHistoryState::defaultTransition() const
{
@@ -178,6 +180,8 @@ QAbstractTransition *QHistoryState::defaultTransition() const
This will set the source state of the \a transition to the history state.
Note that the eventTest method of the \a transition will never be called.
+
+ \since 5.6
*/
void QHistoryState::setDefaultTransition(QAbstractTransition *transition)
{
@@ -290,6 +294,15 @@ bool QHistoryState::event(QEvent *e)
\sa QHistoryState::historyType
*/
+/*!
+ \fn QHistoryState::defaultTransitionChanged()
+ \since 5.6
+
+ This signal is emitted when the defaultTransition property is changed.
+
+ \sa QHistoryState::defaultTransition
+*/
+
QT_END_NAMESPACE
#endif //QT_NO_STATEMACHINE
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index c5e251b37b..3ffe191093 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -1288,7 +1288,7 @@ QVariant QStateMachinePrivate::savedValueForRestorable(const QList<QAbstractStat
QObject *object, const QByteArray &propertyName) const
{
#ifdef QSTATEMACHINE_RESTORE_PROPERTIES_DEBUG
- qDebug() << q_func() << ": savedValueForRestorable(" << exitedStates_sorted << object << propertyName << ")";
+ qDebug() << q_func() << ": savedValueForRestorable(" << exitedStates_sorted << object << propertyName << ')';
#endif
for (int i = exitedStates_sorted.size() - 1; i >= 0; --i) {
QAbstractState *s = exitedStates_sorted.at(i);
@@ -1311,7 +1311,7 @@ void QStateMachinePrivate::registerRestorable(QAbstractState *state, QObject *ob
const QVariant &value)
{
#ifdef QSTATEMACHINE_RESTORE_PROPERTIES_DEBUG
- qDebug() << q_func() << ": registerRestorable(" << state << object << propertyName << value << ")";
+ qDebug() << q_func() << ": registerRestorable(" << state << object << propertyName << value << ')';
#endif
RestorableId id(object, propertyName);
QHash<RestorableId, QVariant> &restorables = registeredRestorablesForState[state];
@@ -1327,7 +1327,7 @@ void QStateMachinePrivate::unregisterRestorables(const QList<QAbstractState *> &
const QByteArray &propertyName)
{
#ifdef QSTATEMACHINE_RESTORE_PROPERTIES_DEBUG
- qDebug() << q_func() << ": unregisterRestorables(" << states << object << propertyName << ")";
+ qDebug() << q_func() << ": unregisterRestorables(" << states << object << propertyName << ')';
#endif
RestorableId id(object, propertyName);
for (int i = 0; i < states.size(); ++i) {
diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h
index fe7a06d16b..45c6dfcb33 100644
--- a/src/corelib/statemachine/qstatemachine_p.h
+++ b/src/corelib/statemachine/qstatemachine_p.h
@@ -134,16 +134,16 @@ public:
virtual void beginMacrostep();
virtual void endMacrostep(bool didChange);
virtual void exitInterpreter();
- void exitStates(QEvent *event, const QList<QAbstractState *> &statesToExit_sorted,
- const QHash<QAbstractState*, QVector<QPropertyAssignment> > &assignmentsForEnteredStates);
+ virtual void exitStates(QEvent *event, const QList<QAbstractState *> &statesToExit_sorted,
+ const QHash<QAbstractState*, QVector<QPropertyAssignment> > &assignmentsForEnteredStates);
QList<QAbstractState*> computeExitSet(const QList<QAbstractTransition*> &enabledTransitions, CalculationCache *cache);
QSet<QAbstractState*> computeExitSet_Unordered(const QList<QAbstractTransition*> &enabledTransitions, CalculationCache *cache);
QSet<QAbstractState*> computeExitSet_Unordered(QAbstractTransition *t, CalculationCache *cache);
void executeTransitionContent(QEvent *event, const QList<QAbstractTransition*> &transitionList);
- void enterStates(QEvent *event, const QList<QAbstractState*> &exitedStates_sorted,
- const QList<QAbstractState*> &statesToEnter_sorted,
- const QSet<QAbstractState*> &statesForDefaultEntry,
- QHash<QAbstractState *, QVector<QPropertyAssignment> > &propertyAssignmentsForState
+ virtual void enterStates(QEvent *event, const QList<QAbstractState*> &exitedStates_sorted,
+ const QList<QAbstractState*> &statesToEnter_sorted,
+ const QSet<QAbstractState*> &statesForDefaultEntry,
+ QHash<QAbstractState *, QVector<QPropertyAssignment> > &propertyAssignmentsForState
#ifndef QT_NO_ANIMATION
, const QList<QAbstractAnimation*> &selectedAnimations
#endif
diff --git a/src/corelib/thread/qfuturewatcher.cpp b/src/corelib/thread/qfuturewatcher.cpp
index 3056216f6e..43eff83116 100644
--- a/src/corelib/thread/qfuturewatcher.cpp
+++ b/src/corelib/thread/qfuturewatcher.cpp
@@ -248,7 +248,7 @@ bool QFutureWatcherBase::isStarted() const
/*! \fn bool QFutureWatcher::isFinished() const
Returns \c true if the asynchronous computation represented by the future()
- has finished; otherwise returns \c false.
+ has finished, or if no future has been set; otherwise returns \c false.
*/
bool QFutureWatcherBase::isFinished() const
{
@@ -304,15 +304,6 @@ void QFutureWatcherBase::waitForFinished()
futureInterface().waitForFinished();
}
-/*! \fn void QFutureWatcher::setPendingResultsLimit(int limit)
-
- The setPendingResultsLimit() provides throttling control. When the number
- of pending resultReadyAt() or resultsReadyAt() signals exceeds the
- \a limit, the computation represented by the future will be throttled
- automatically. The computation will resume once the number of pending
- signals drops below the \a limit.
-*/
-
bool QFutureWatcherBase::event(QEvent *event)
{
Q_D(QFutureWatcherBase);
@@ -342,6 +333,14 @@ bool QFutureWatcherBase::event(QEvent *event)
return QObject::event(event);
}
+/*! \fn void QFutureWatcher::setPendingResultsLimit(int limit)
+
+ The setPendingResultsLimit() provides throttling control. When the number
+ of pending resultReadyAt() or resultsReadyAt() signals exceeds the
+ \a limit, the computation represented by the future will be throttled
+ automatically. The computation will resume once the number of pending
+ signals drops below the \a limit.
+*/
void QFutureWatcherBase::setPendingResultsLimit(int limit)
{
Q_D(QFutureWatcherBase);
@@ -379,7 +378,8 @@ void QFutureWatcherBase::disconnectNotify(const QMetaMethod &signal)
*/
QFutureWatcherBasePrivate::QFutureWatcherBasePrivate()
: maximumPendingResultsReady(QThread::idealThreadCount() * 2),
- resultAtConnected(0)
+ resultAtConnected(0),
+ finished(true) /* the initial m_future is a canceledResult(), with Finished set */
{ }
/*!
@@ -400,7 +400,7 @@ void QFutureWatcherBase::disconnectOutputInterface(bool pendingAssignment)
d->pendingResultsReady.store(0);
qDeleteAll(d->pendingCallOutEvents);
d->pendingCallOutEvents.clear();
- d->finished = false;
+ d->finished = false; /* May soon be amended, during connectOutputInterface() */
}
futureInterface().d->disconnectOutputInterface(d_func());
diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp
index 3269ee3ae8..742a572bef 100644
--- a/src/corelib/thread/qmutex.cpp
+++ b/src/corelib/thread/qmutex.cpp
@@ -571,19 +571,26 @@ FreeList *freelist()
return &list;
}
#else
+static QBasicAtomicPointer<FreeList> freeListPtr;
+
FreeList *freelist()
{
- static QAtomicPointer<FreeList> list;
- FreeList *local = list.loadAcquire();
+ FreeList *local = freeListPtr.loadAcquire();
if (!local) {
local = new FreeList;
- if (!list.testAndSetRelease(0, local)) {
+ if (!freeListPtr.testAndSetRelease(0, local)) {
delete local;
- local = list.loadAcquire();
+ local = freeListPtr.loadAcquire();
}
}
return local;
}
+
+static void qFreeListDeleter()
+{
+ delete freeListPtr.load();
+}
+Q_DESTRUCTOR_FUNCTION(qFreeListDeleter)
#endif
}
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index ffefe0b1d1..a0d354acdc 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -276,7 +276,7 @@ public:
QStack<QEventLoop *> eventLoops;
QPostEventList postEventList;
- QThread *thread;
+ QAtomicPointer<QThread> thread;
Qt::HANDLE threadId;
QAtomicPointer<QAbstractEventDispatcher> eventDispatcher;
QVector<void *> tls;
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index 4b50936958..c340915d35 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -222,7 +222,7 @@ QThreadData *QThreadData::current(bool createIfNecessary)
data->isAdopted = true;
data->threadId = (Qt::HANDLE)pthread_self();
if (!QCoreApplicationPrivate::theMainThread)
- QCoreApplicationPrivate::theMainThread = data->thread;
+ QCoreApplicationPrivate::theMainThread = data->thread.load();
}
return data;
}
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index 72f04ff7af..1a4b41fee4 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -121,7 +121,7 @@ QThreadData *QThreadData::current(bool createIfNecessary)
threadData->threadId = reinterpret_cast<Qt::HANDLE>(quintptr(GetCurrentThreadId()));
if (!QCoreApplicationPrivate::theMainThread) {
- QCoreApplicationPrivate::theMainThread = threadData->thread;
+ QCoreApplicationPrivate::theMainThread = threadData->thread.load();
// TODO: is there a way to reflect the branch's behavior using
// WinRT API?
} else {
diff --git a/src/corelib/thread/qthreadstorage.cpp b/src/corelib/thread/qthreadstorage.cpp
index 05ab01cc54..37892233f3 100644
--- a/src/corelib/thread/qthreadstorage.cpp
+++ b/src/corelib/thread/qthreadstorage.cpp
@@ -121,7 +121,7 @@ void **QThreadStorageData::get() const
DEBUG_MSG("QThreadStorageData: Returning storage %d, data %p, for thread %p",
id,
*v,
- data->thread);
+ data->thread.load());
return *v ? v : 0;
}
@@ -143,7 +143,7 @@ void **QThreadStorageData::set(void *p)
DEBUG_MSG("QThreadStorageData: Deleting previous storage %d, data %p, for thread %p",
id,
value,
- data->thread);
+ data->thread.load());
QMutexLocker locker(&destructorsMutex);
DestructorMap *destr = destructors();
@@ -159,7 +159,7 @@ void **QThreadStorageData::set(void *p)
// store new data
value = p;
- DEBUG_MSG("QThreadStorageData: Set storage %d for thread %p to %p", id, data->thread, p);
+ DEBUG_MSG("QThreadStorageData: Set storage %d for thread %p to %p", id, data->thread.load(), p);
return &value;
}
diff --git a/src/corelib/tools/qalgorithms.qdoc b/src/corelib/tools/qalgorithms.qdoc
index dac353fa70..dac353fa70 100755..100644
--- a/src/corelib/tools/qalgorithms.qdoc
+++ b/src/corelib/tools/qalgorithms.qdoc
diff --git a/src/corelib/tools/qbitarray.h b/src/corelib/tools/qbitarray.h
index 4e5c26b86a..e686d53db4 100644
--- a/src/corelib/tools/qbitarray.h
+++ b/src/corelib/tools/qbitarray.h
@@ -48,7 +48,7 @@ class Q_CORE_EXPORT QBitArray
QByteArray d;
public:
- inline QBitArray() {}
+ inline QBitArray() Q_DECL_NOTHROW {}
explicit QBitArray(int size, bool val = false);
QBitArray(const QBitArray &other) : d(other.d) {}
inline QBitArray &operator=(const QBitArray &other) { d = other.d; return *this; }
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index ac191ef265..c223c9de6c 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -578,8 +578,8 @@ QByteArray qUncompress(const uchar* data, int nbytes)
qWarning("qUncompress: Input data is corrupted");
return QByteArray();
}
- ulong expectedSize = (data[0] << 24) | (data[1] << 16) |
- (data[2] << 8) | (data[3] );
+ ulong expectedSize = uint((data[0] << 24) | (data[1] << 16) |
+ (data[2] << 8) | (data[3] ));
ulong len = qMax(expectedSize, 1ul);
QScopedPointer<QByteArray::Data, QScopedPointerPodDeleter> d;
diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp
index 20e0688f45..15c7a0646f 100644
--- a/src/corelib/tools/qcommandlineparser.cpp
+++ b/src/corelib/tools/qcommandlineparser.cpp
@@ -325,13 +325,13 @@ void QCommandLineParser::setSingleDashWordOptionMode(QCommandLineParser::SingleD
\sa setOptionsAfterPositionalArgumentsMode()
- \since 5.5
+ \since 5.6
*/
/*!
Sets the parsing mode to \a parsingMode.
This must be called before process() or parse().
- \since 5.5
+ \since 5.6
*/
void QCommandLineParser::setOptionsAfterPositionalArgumentsMode(QCommandLineParser::OptionsAfterPositionalArgumentsMode parsingMode)
{
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 0d7225eea0..4854ceb5ca 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -3123,6 +3123,7 @@ QTimeZone QDateTime::timeZone() const
case Qt::UTC:
return QTimeZone::utc();
case Qt::OffsetFromUTC:
+ return QTimeZone(d->m_offsetFromUtc);
case Qt::TimeZone:
Q_ASSERT(d->m_timeZone.isValid());
return d->m_timeZone;
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 8d65a018ae..a18dd74706 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -935,7 +935,7 @@ template <class Key, class T>
class QMultiHash : public QHash<Key, T>
{
public:
- QMultiHash() {}
+ QMultiHash() Q_DECL_NOTHROW {}
#ifdef Q_COMPILER_INITIALIZER_LISTS
inline QMultiHash(std::initializer_list<std::pair<Key,T> > list)
{
@@ -948,7 +948,10 @@ public:
// compiler-generated destructor is fine!
QMultiHash(const QHash<Key, T> &other) : QHash<Key, T>(other) {}
- void swap(QMultiHash &other) { QHash<Key, T>::swap(other); } // prevent QMultiHash<->QHash swaps
+#ifdef Q_COMPILER_RVALUE_REFS
+ QMultiHash(QHash<Key, T> &&other) Q_DECL_NOTHROW : QHash<Key, T>(std::move(other)) {}
+#endif
+ void swap(QMultiHash &other) Q_DECL_NOTHROW { QHash<Key, T>::swap(other); } // prevent QMultiHash<->QHash swaps
inline typename QHash<Key, T>::iterator replace(const Key &key, const T &value)
{ return QHash<Key, T>::insert(key, value); }
diff --git a/src/corelib/tools/qlinkedlist.cpp b/src/corelib/tools/qlinkedlist.cpp
index fbd263e88b..5d91bfe924 100644
--- a/src/corelib/tools/qlinkedlist.cpp
+++ b/src/corelib/tools/qlinkedlist.cpp
@@ -388,6 +388,52 @@ const QLinkedListData QLinkedListData::shared_null = {
\sa constBegin(), end()
*/
+/*! \fn QLinkedList::reverse_iterator QLinkedList::rbegin()
+ \since 5.6
+
+ Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
+ item in the list, in reverse order.
+
+ \sa begin(), crbegin(), rend()
+*/
+
+/*! \fn QLinkedList::const_reverse_iterator QLinkedList::rbegin() const
+ \since 5.6
+ \overload
+*/
+
+/*! \fn QLinkedList::const_reverse_iterator QLinkedList::crbegin() const
+ \since 5.6
+
+ Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
+ item in the list, in reverse order.
+
+ \sa begin(), rbegin(), rend()
+*/
+
+/*! \fn QLinkedList::reverse_iterator QLinkedList::rend()
+ \since 5.6
+
+ Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to one past
+ the last item in the list, in reverse order.
+
+ \sa end(), crend(), rbegin()
+*/
+
+/*! \fn QLinkedList::const_reverse_iterator QLinkedList::rend() const
+ \since 5.6
+ \overload
+*/
+
+/*! \fn QLinkedList::const_reverse_iterator QLinkedList::crend() const
+ \since 5.6
+
+ Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to one
+ past the last item in the list, in reverse order.
+
+ \sa end(), rend(), rbegin()
+*/
+
/*! \fn QLinkedList::iterator QLinkedList::insert(iterator before, const T &value)
Inserts \a value in front of the item pointed to by the iterator
@@ -423,6 +469,38 @@ const QLinkedListData QLinkedListData::shared_null = {
Qt-style synonym for QLinkedList::const_iterator.
*/
+/*! \typedef QLinkedList::reverse_iterator
+ \since 5.6
+
+ The QLinkedList::reverse_iterator typedef provides an STL-style non-const
+ reverse iterator for QLinkedList.
+
+ It is simply a typedef for \c{std::reverse_iterator<QLinkedList::iterator>}.
+
+ \warning Iterators on implicitly shared containers do not work
+ exactly like STL-iterators. You should avoid copying a container
+ while iterators are active on that container. For more information,
+ read \l{Implicit sharing iterator problem}.
+
+ \sa QLinkedList::rbegin(), QLinkedList::rend(), QLinkedList::const_reverse_iterator, QLinkedList::iterator
+*/
+
+/*! \typedef QLinkedList::const_reverse_iterator
+ \since 5.6
+
+ The QLinkedList::const_reverse_iterator typedef provides an STL-style const
+ reverse iterator for QLinkedList.
+
+ It is simply a typedef for \c{std::reverse_iterator<QLinkedList::const_iterator>}.
+
+ \warning Iterators on implicitly shared containers do not work
+ exactly like STL-iterators. You should avoid copying a container
+ while iterators are active on that container. For more information,
+ read \l{Implicit sharing iterator problem}.
+
+ \sa QLinkedList::rbegin(), QLinkedList::rend(), QLinkedList::reverse_iterator, QLinkedList::const_iterator
+*/
+
/*!
\typedef QLinkedList::size_type
diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h
index f216aa121c..110529d843 100644
--- a/src/corelib/tools/qlinkedlist.h
+++ b/src/corelib/tools/qlinkedlist.h
@@ -74,7 +74,7 @@ class QLinkedList
union { QLinkedListData *d; QLinkedListNode<T> *e; };
public:
- inline QLinkedList() : d(const_cast<QLinkedListData *>(&QLinkedListData::shared_null)) { }
+ inline QLinkedList() Q_DECL_NOTHROW : d(const_cast<QLinkedListData *>(&QLinkedListData::shared_null)) { }
inline QLinkedList(const QLinkedList<T> &l) : d(l.d) { d->ref.ref(); if (!d->sharable) detach(); }
#if defined(Q_COMPILER_INITIALIZER_LISTS)
inline QLinkedList(std::initializer_list<T> list)
@@ -86,11 +86,12 @@ public:
~QLinkedList();
QLinkedList<T> &operator=(const QLinkedList<T> &);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QLinkedList(QLinkedList<T> &&other) : d(other.d) { other.d = const_cast<QLinkedListData *>(&QLinkedListData::shared_null); }
- inline QLinkedList<T> &operator=(QLinkedList<T> &&other)
+ QLinkedList(QLinkedList<T> &&other) Q_DECL_NOTHROW
+ : d(other.d) { other.d = const_cast<QLinkedListData *>(&QLinkedListData::shared_null); }
+ QLinkedList<T> &operator=(QLinkedList<T> &&other) Q_DECL_NOTHROW
{ QLinkedList moved(std::move(other)); swap(moved); return *this; }
#endif
- inline void swap(QLinkedList<T> &other) { qSwap(d, other.d); }
+ inline void swap(QLinkedList<T> &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
bool operator==(const QLinkedList<T> &l) const;
inline bool operator!=(const QLinkedList<T> &l) const { return !(*this == l); }
@@ -182,14 +183,25 @@ public:
friend class const_iterator;
// stl style
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
inline iterator begin() { detach(); return e->n; }
- inline const_iterator begin() const { return e->n; }
- inline const_iterator cbegin() const { return e->n; }
- inline const_iterator constBegin() const { return e->n; }
+ inline const_iterator begin() const Q_DECL_NOTHROW { return e->n; }
+ inline const_iterator cbegin() const Q_DECL_NOTHROW { return e->n; }
+ inline const_iterator constBegin() const Q_DECL_NOTHROW { return e->n; }
inline iterator end() { detach(); return e; }
- inline const_iterator end() const { return e; }
- inline const_iterator cend() const { return e; }
- inline const_iterator constEnd() const { return e; }
+ inline const_iterator end() const Q_DECL_NOTHROW { return e; }
+ inline const_iterator cend() const Q_DECL_NOTHROW { return e; }
+ inline const_iterator constEnd() const Q_DECL_NOTHROW { return e; }
+
+ reverse_iterator rbegin() { return reverse_iterator(end()); }
+ reverse_iterator rend() { return reverse_iterator(begin()); }
+ const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); }
+ const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); }
+ const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); }
+ const_reverse_iterator crend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); }
+
iterator insert(iterator before, const T &t);
iterator erase(iterator pos);
iterator erase(iterator first, iterator last);
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 32e0141d55..9a57a2c6a5 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -143,11 +143,12 @@ public:
~QList();
QList<T> &operator=(const QList<T> &l);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QList(QList<T> &&other) : d(other.d) { other.d = const_cast<QListData::Data *>(&QListData::shared_null); }
- inline QList &operator=(QList<T> &&other)
+ inline QList(QList<T> &&other) Q_DECL_NOTHROW
+ : d(other.d) { other.d = const_cast<QListData::Data *>(&QListData::shared_null); }
+ inline QList &operator=(QList<T> &&other) Q_DECL_NOTHROW
{ QList moved(std::move(other)); swap(moved); return *this; }
#endif
- inline void swap(QList<T> &other) { qSwap(d, other.d); }
+ inline void swap(QList<T> &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
#ifdef Q_COMPILER_INITIALIZER_LISTS
inline QList(std::initializer_list<T> args)
: d(const_cast<QListData::Data *>(&QListData::shared_null))
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 181daa04e4..57ef53eea4 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -89,9 +89,9 @@ QLocale::Language QLocalePrivate::codeToLanguage(const QString &code)
int len = code.length();
if (len != 2 && len != 3)
return QLocale::C;
- ushort uc1 = len-- > 0 ? code[0].toLower().unicode() : 0;
- ushort uc2 = len-- > 0 ? code[1].toLower().unicode() : 0;
- ushort uc3 = len-- > 0 ? code[2].toLower().unicode() : 0;
+ ushort uc1 = code[0].toLower().unicode();
+ ushort uc2 = code[1].toLower().unicode();
+ ushort uc3 = len > 2 ? code[2].toLower().unicode() : 0;
const unsigned char *c = language_code_list;
for (; *c != 0; c += 3) {
@@ -145,9 +145,9 @@ QLocale::Country QLocalePrivate::codeToCountry(const QString &code)
int len = code.length();
if (len != 2 && len != 3)
return QLocale::AnyCountry;
- ushort uc1 = len-- > 0 ? code[0].toUpper().unicode() : 0;
- ushort uc2 = len-- > 0 ? code[1].toUpper().unicode() : 0;
- ushort uc3 = len-- > 0 ? code[2].toUpper().unicode() : 0;
+ ushort uc1 = code[0].toUpper().unicode();
+ ushort uc2 = code[1].toUpper().unicode();
+ ushort uc3 = len > 2 ? code[2].toUpper().unicode() : 0;
const unsigned char *c = country_code_list;
for (; *c != 0; c += 3) {
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index b7bd268bda..fe9ddaaa32 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -321,7 +321,7 @@ class QMap
QMapData<Key, T> *d;
public:
- inline QMap() : d(static_cast<QMapData<Key, T> *>(const_cast<QMapDataBase *>(&QMapDataBase::shared_null))) { }
+ inline QMap() Q_DECL_NOTHROW : d(static_cast<QMapData<Key, T> *>(const_cast<QMapDataBase *>(&QMapDataBase::shared_null))) { }
#ifdef Q_COMPILER_INITIALIZER_LISTS
inline QMap(std::initializer_list<std::pair<Key,T> > list)
: d(static_cast<QMapData<Key, T> *>(const_cast<QMapDataBase *>(&QMapDataBase::shared_null)))
@@ -336,17 +336,17 @@ public:
QMap<Key, T> &operator=(const QMap<Key, T> &other);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QMap(QMap<Key, T> &&other)
+ inline QMap(QMap<Key, T> &&other) Q_DECL_NOTHROW
: d(other.d)
{
other.d = static_cast<QMapData<Key, T> *>(
const_cast<QMapDataBase *>(&QMapDataBase::shared_null));
}
- inline QMap<Key, T> &operator=(QMap<Key, T> &&other)
+ inline QMap<Key, T> &operator=(QMap<Key, T> &&other) Q_DECL_NOTHROW
{ QMap moved(std::move(other)); swap(moved); return *this; }
#endif
- inline void swap(QMap<Key, T> &other) { qSwap(d, other.d); }
+ inline void swap(QMap<Key, T> &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
explicit QMap(const typename std::map<Key, T> &other);
std::map<Key, T> toStdMap() const;
@@ -1168,7 +1168,7 @@ template <class Key, class T>
class QMultiMap : public QMap<Key, T>
{
public:
- QMultiMap() {}
+ QMultiMap() Q_DECL_NOTHROW {}
#ifdef Q_COMPILER_INITIALIZER_LISTS
inline QMultiMap(std::initializer_list<std::pair<Key,T> > list)
{
@@ -1177,7 +1177,10 @@ public:
}
#endif
QMultiMap(const QMap<Key, T> &other) : QMap<Key, T>(other) {}
- inline void swap(QMultiMap<Key, T> &other) { QMap<Key, T>::swap(other); }
+#ifdef Q_COMPILER_RVALUE_REFS
+ QMultiMap(QMap<Key, T> &&other) Q_DECL_NOTHROW : QMap<Key, T>(std::move(other)) {}
+#endif
+ void swap(QMultiMap<Key, T> &other) Q_DECL_NOTHROW { QMap<Key, T>::swap(other); }
inline typename QMap<Key, T>::iterator replace(const Key &key, const T &value)
{ return QMap<Key, T>::insert(key, value); }
diff --git a/src/corelib/tools/qqueue.h b/src/corelib/tools/qqueue.h
index 7a7abab070..0cb8353d0f 100644
--- a/src/corelib/tools/qqueue.h
+++ b/src/corelib/tools/qqueue.h
@@ -44,7 +44,7 @@ class QQueue : public QList<T>
{
public:
// compiler-generated special member functions are fine!
- inline void swap(QQueue<T> &other) { QList<T>::swap(other); } // prevent QList<->QQueue swaps
+ inline void swap(QQueue<T> &other) Q_DECL_NOTHROW { QList<T>::swap(other); } // prevent QList<->QQueue swaps
#ifndef Q_QDOC
// bring in QList::swap(int, int). We cannot say using QList<T>::swap,
// because we don't want to make swap(QList&) available.
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
index d8b0bf6e9f..81b108059b 100644
--- a/src/corelib/tools/qregularexpression.cpp
+++ b/src/corelib/tools/qregularexpression.cpp
@@ -2479,7 +2479,7 @@ QDataStream &operator>>(QDataStream &in, QRegularExpression &re)
QDebug operator<<(QDebug debug, const QRegularExpression &re)
{
QDebugStateSaver saver(debug);
- debug.nospace() << "QRegularExpression(" << re.pattern() << ", " << re.patternOptions() << ")";
+ debug.nospace() << "QRegularExpression(" << re.pattern() << ", " << re.patternOptions() << ')';
return debug;
}
@@ -2521,7 +2521,7 @@ QDebug operator<<(QDebug debug, QRegularExpression::PatternOptions patternOption
flags.chop(1);
}
- debug.nospace() << "QRegularExpression::PatternOptions(" << flags << ")";
+ debug.nospace() << "QRegularExpression::PatternOptions(" << flags << ')';
return debug;
}
@@ -2550,7 +2550,7 @@ QDebug operator<<(QDebug debug, const QRegularExpressionMatch &match)
for (int i = 0; i <= match.lastCapturedIndex(); ++i) {
debug << i
<< ":(" << match.capturedStart(i) << ", " << match.capturedEnd(i)
- << ", " << match.captured(i) << ")";
+ << ", " << match.captured(i) << ')';
if (i < match.lastCapturedIndex())
debug << ", ";
}
@@ -2558,12 +2558,12 @@ QDebug operator<<(QDebug debug, const QRegularExpressionMatch &match)
debug << ", has partial match: ("
<< match.capturedStart(0) << ", "
<< match.capturedEnd(0) << ", "
- << match.captured(0) << ")";
+ << match.captured(0) << ')';
} else {
debug << ", no match";
}
- debug << ")";
+ debug << ')';
return debug;
}
diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h
index aeba6cf68d..3f4208e8b3 100644
--- a/src/corelib/tools/qset.h
+++ b/src/corelib/tools/qset.h
@@ -39,6 +39,8 @@
#include <initializer_list>
#endif
+#include <iterator>
+
QT_BEGIN_NAMESPACE
@@ -48,7 +50,7 @@ class QSet
typedef QHash<T, QHashDummyValue> Hash;
public:
- inline QSet() {}
+ inline QSet() Q_DECL_NOTHROW {}
#ifdef Q_COMPILER_INITIALIZER_LISTS
inline QSet(std::initializer_list<T> list)
{
@@ -60,7 +62,7 @@ public:
// compiler-generated copy/move ctor/assignment operators are fine!
// compiler-generated destructor is fine!
- inline void swap(QSet<T> &other) { q_hash.swap(other.q_hash); }
+ inline void swap(QSet<T> &other) Q_DECL_NOTHROW { q_hash.swap(other.q_hash); }
inline bool operator==(const QSet<T> &other) const
{ return q_hash == other.q_hash; }
@@ -161,14 +163,25 @@ public:
};
// STL style
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
inline iterator begin() { return q_hash.begin(); }
- inline const_iterator begin() const { return q_hash.begin(); }
- inline const_iterator cbegin() const { return q_hash.begin(); }
- inline const_iterator constBegin() const { return q_hash.constBegin(); }
+ inline const_iterator begin() const Q_DECL_NOTHROW { return q_hash.begin(); }
+ inline const_iterator cbegin() const Q_DECL_NOTHROW { return q_hash.begin(); }
+ inline const_iterator constBegin() const Q_DECL_NOTHROW { return q_hash.constBegin(); }
inline iterator end() { return q_hash.end(); }
- inline const_iterator end() const { return q_hash.end(); }
- inline const_iterator cend() const { return q_hash.end(); }
- inline const_iterator constEnd() const { return q_hash.constEnd(); }
+ inline const_iterator end() const Q_DECL_NOTHROW { return q_hash.end(); }
+ inline const_iterator cend() const Q_DECL_NOTHROW { return q_hash.end(); }
+ inline const_iterator constEnd() const Q_DECL_NOTHROW { return q_hash.constEnd(); }
+
+ reverse_iterator rbegin() { return reverse_iterator(end()); }
+ reverse_iterator rend() { return reverse_iterator(begin()); }
+ const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); }
+ const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); }
+ const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); }
+ const_reverse_iterator crend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); }
+
iterator erase(iterator i)
{
Q_ASSERT_X(isValidIterator(i), "QSet::erase", "The specified const_iterator argument 'i' is invalid");
diff --git a/src/corelib/tools/qset.qdoc b/src/corelib/tools/qset.qdoc
index d91a589aa1..542def4651 100644
--- a/src/corelib/tools/qset.qdoc
+++ b/src/corelib/tools/qset.qdoc
@@ -384,6 +384,52 @@
\sa constBegin(), end()
*/
+/*! \fn QSet::reverse_iterator QSet::rbegin()
+ \since 5.6
+
+ Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
+ item in the set, in reverse order.
+
+ \sa begin(), crbegin(), rend()
+*/
+
+/*! \fn QSet::const_reverse_iterator QSet::rbegin() const
+ \since 5.6
+ \overload
+*/
+
+/*! \fn QSet::const_reverse_iterator QSet::crbegin() const
+ \since 5.6
+
+ Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
+ item in the set, in reverse order.
+
+ \sa begin(), rbegin(), rend()
+*/
+
+/*! \fn QSet::reverse_iterator QSet::rend()
+ \since 5.6
+
+ Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to one past
+ the last item in the set, in reverse order.
+
+ \sa end(), crend(), rbegin()
+*/
+
+/*! \fn QSet::const_reverse_iterator QSet::rend() const
+ \since 5.6
+ \overload
+*/
+
+/*! \fn QSet::const_reverse_iterator QSet::crend() const
+ \since 5.6
+
+ Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to one
+ past the last item in the set, in reverse order.
+
+ \sa end(), rend(), rbegin()
+*/
+
/*!
\typedef QSet::Iterator
\since 4.2
@@ -445,6 +491,38 @@
Typedef for T. Provided for STL compatibility.
*/
+/*! \typedef QSet::reverse_iterator
+ \since 5.6
+
+ The QSet::reverse_iterator typedef provides an STL-style non-const
+ reverse iterator for QSet.
+
+ It is simply a typedef for \c{std::reverse_iterator<QSet::iterator>}.
+
+ \warning Iterators on implicitly shared containers do not work
+ exactly like STL-iterators. You should avoid copying a container
+ while iterators are active on that container. For more information,
+ read \l{Implicit sharing iterator problem}.
+
+ \sa QSet::rbegin(), QSet::rend(), QSet::const_reverse_iterator, QSet::iterator
+*/
+
+/*! \typedef QSet::const_reverse_iterator
+ \since 5.6
+
+ The QSet::const_reverse_iterator typedef provides an STL-style const
+ reverse iterator for QSet.
+
+ It is simply a typedef for \c{std::reverse_iterator<QSet::const_iterator>}.
+
+ \warning Iterators on implicitly shared containers do not work
+ exactly like STL-iterators. You should avoid copying a container
+ while iterators are active on that container. For more information,
+ read \l{Implicit sharing iterator problem}.
+
+ \sa QSet::rbegin(), QSet::rend(), QSet::reverse_iterator, QSet::const_iterator
+*/
+
/*!
\fn QSet::const_iterator QSet::insert(const T &value)
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index c4deee36e4..96f5419af6 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -54,9 +54,9 @@
* for the x86 and ARM intrinsics:
* - GCC: the -mXXX or march=YYY flag is necessary before #include
* up to 4.8; GCC >= 4.9 can include unconditionally
- * - Clang: same as GCC, with unconditional inclusion with version 3.7
* - Intel CC: #include can happen unconditionally
* - MSVC: #include can happen unconditionally
+ * - RVCT: ???
*
* We will try to include all headers possible under this configuration.
*
@@ -139,8 +139,7 @@
#define QT_COMPILER_SUPPORTS(x) (QT_COMPILER_SUPPORTS_ ## x - 0)
#if (defined(Q_CC_INTEL) || defined(Q_CC_MSVC) \
- || (defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && (__GNUC__-0) * 100 + (__GNUC_MINOR__-0) >= 409) \
- || (defined(Q_CC_CLANG) && Q_CC_CLANG >= 307)) \
+ || (defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && (__GNUC__-0) * 100 + (__GNUC_MINOR__-0) >= 409)) \
&& !defined(QT_BOOTSTRAPPED)
# define QT_COMPILER_SUPPORTS_SIMD_ALWAYS
# define QT_COMPILER_SUPPORTS_HERE(x) QT_COMPILER_SUPPORTS(x)
@@ -151,7 +150,7 @@
# define QT_FUNCTION_TARGET(x)
# endif
#else
-# define QT_COMPILER_SUPPORTS_HERE(x) defined(__ ## x ## __)
+# define QT_COMPILER_SUPPORTS_HERE(x) (__ ## x ## __)
# define QT_FUNCTION_TARGET(x)
#endif
diff --git a/src/corelib/tools/qstack.h b/src/corelib/tools/qstack.h
index 278e89ca2f..cb72316c32 100644
--- a/src/corelib/tools/qstack.h
+++ b/src/corelib/tools/qstack.h
@@ -44,7 +44,7 @@ class QStack : public QVector<T>
{
public:
// compiler-generated special member functions are fine!
- inline void swap(QStack<T> &other) { QVector<T>::swap(other); } // prevent QVector<->QStack swaps
+ inline void swap(QStack<T> &other) Q_DECL_NOTHROW { QVector<T>::swap(other); } // prevent QVector<->QStack swaps
inline void push(const T &t) { QVector<T>::append(t); }
T pop();
T &top();
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index e3a3cc79c6..ea220ed557 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -1509,7 +1509,7 @@ QString::QString(const QChar *unicode, int size)
} else {
if (size < 0) {
size = 0;
- while (unicode[size] != 0)
+ while (!unicode[size].isNull())
++size;
}
if (!size) {
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index ece86c5917..47c4272389 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -1244,13 +1244,13 @@ inline bool QByteArray::operator==(const QString &s) const
inline bool QByteArray::operator!=(const QString &s) const
{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) != 0; }
inline bool QByteArray::operator<(const QString &s) const
-{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) < 0; }
-inline bool QByteArray::operator>(const QString &s) const
{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) > 0; }
+inline bool QByteArray::operator>(const QString &s) const
+{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) < 0; }
inline bool QByteArray::operator<=(const QString &s) const
-{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) <= 0; }
-inline bool QByteArray::operator>=(const QString &s) const
{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) >= 0; }
+inline bool QByteArray::operator>=(const QString &s) const
+{ return QString::compare_helper(s.constData(), s.size(), constData(), size()) <= 0; }
#endif // !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
#ifndef QT_NO_CAST_TO_ASCII
diff --git a/src/corelib/tools/qstringalgorithms_p.h b/src/corelib/tools/qstringalgorithms_p.h
index 65901b0286..a12874f567 100644
--- a/src/corelib/tools/qstringalgorithms_p.h
+++ b/src/corelib/tools/qstringalgorithms_p.h
@@ -101,8 +101,6 @@ template <typename StringType> struct QStringAlgorithms
if (begin == str.cbegin() && end == str.cend())
return str;
- if (begin == end)
- return StringType();
if (!isConst && str.isDetached())
return trimmed_helper_inplace(str, begin, end);
return StringType(begin, end - begin);
diff --git a/src/corelib/tools/qversionnumber.cpp b/src/corelib/tools/qversionnumber.cpp
index 4197fc47b1..f432820252 100644
--- a/src/corelib/tools/qversionnumber.cpp
+++ b/src/corelib/tools/qversionnumber.cpp
@@ -202,7 +202,7 @@ QVector<int> QVersionNumber::segments() const
Returns an equivalent version number but with all trailing zeros removed.
To check if two numbers are equivalent, use normalized() on both version
- numbers before perforing the compare.
+ numbers before performing the compare.
\snippet qversionnumber/main.cpp 4
*/
diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp
index 13c84db9ae..69e2e5d5c1 100644
--- a/src/corelib/xml/qxmlstream.cpp
+++ b/src/corelib/xml/qxmlstream.cpp
@@ -3013,7 +3013,8 @@ void QXmlStreamWriterPrivate::checkIfASCIICompatibleCodec()
#ifndef QT_NO_TEXTCODEC
Q_ASSERT(encoder);
// assumes ASCII-compatibility for all 8-bit encodings
- const QByteArray bytes = encoder->fromUnicode(QStringLiteral(" "));
+ QChar space = QLatin1Char(' ');
+ const QByteArray bytes = encoder->fromUnicode(&space, 1);
isCodecASCIICompatible = (bytes.count() == 1);
#else
isCodecASCIICompatible = true;