summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/sqlite/patches/0001-Fix-CVE-2019-19244-in-SQLite.patch26
-rw-r--r--src/3rdparty/sqlite/sqlite3.c1
-rw-r--r--src/corelib/Qt5CoreMacros.cmake2
-rw-r--r--src/corelib/codecs/qgb18030codec.cpp1
-rw-r--r--src/corelib/doc/src/qtcore-index.qdoc2
-rw-r--r--src/corelib/doc/src/resource-system.qdoc4
-rw-r--r--src/corelib/global/qcompilerdetection.h77
-rw-r--r--src/corelib/global/qconfig-bootstrapped.h4
-rw-r--r--src/corelib/global/qendian.cpp6
-rw-r--r--src/corelib/global/qendian.h4
-rw-r--r--src/corelib/global/qfloat16.h1
-rw-r--r--src/corelib/global/qglobal.cpp4
-rw-r--r--src/corelib/global/qglobal.h8
-rw-r--r--src/corelib/global/qglobal_p.h4
-rw-r--r--src/corelib/global/qlogging.cpp8
-rw-r--r--src/corelib/global/qnamespace.qdoc16
-rw-r--r--src/corelib/global/qnumeric_p.h2
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp2
-rw-r--r--src/corelib/io/qprocess.cpp2
-rw-r--r--src/corelib/io/qresource.cpp4
-rw-r--r--src/corelib/io/qstandardpaths.cpp16
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp2
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.cpp6
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.h22
-rw-r--r--src/corelib/kernel/qdeadlinetimer.h4
-rw-r--r--src/corelib/kernel/qobject.h4
-rw-r--r--src/corelib/kernel/qtimer.cpp8
-rw-r--r--src/corelib/kernel/qtimer.h6
-rw-r--r--src/corelib/kernel/qvariant.cpp39
-rw-r--r--src/corelib/kernel/qvariant.h6
-rw-r--r--src/corelib/kernel/qvariant_p.h5
-rw-r--r--src/corelib/serialization/qcborarray.h2
-rw-r--r--src/corelib/serialization/qcbormap.h2
-rw-r--r--src/corelib/serialization/qcborvalue.cpp157
-rw-r--r--src/corelib/serialization/qcborvalue.h6
-rw-r--r--src/corelib/serialization/qcborvalue_p.h3
-rw-r--r--src/corelib/text/qbytearray.cpp2
-rw-r--r--src/corelib/text/qbytearray.h2
-rw-r--r--src/corelib/text/qstring.cpp7
-rw-r--r--src/corelib/text/qstring.h2
-rw-r--r--src/corelib/thread/qatomic.cpp204
-rw-r--r--src/corelib/thread/qatomic.h6
-rw-r--r--src/corelib/thread/qfutex_p.h4
-rw-r--r--src/corelib/thread/qmutex.h10
-rw-r--r--src/corelib/time/qdatetime.cpp194
-rw-r--r--src/corelib/time/qdatetimeparser.cpp14
-rw-r--r--src/corelib/time/qtimezoneprivate.cpp13
-rw-r--r--src/corelib/time/qtimezoneprivate_android.cpp52
-rw-r--r--src/corelib/time/qtimezoneprivate_mac.mm47
-rw-r--r--src/corelib/tools/qalgorithms.h4
-rw-r--r--src/corelib/tools/qpoint.h1
-rw-r--r--src/corelib/tools/qrect.h1
-rw-r--r--src/corelib/tools/qscopeguard.h4
-rw-r--r--src/gui/doc/src/qtgui.qdoc2
-rw-r--r--src/gui/kernel/qplatformcursor.cpp8
-rw-r--r--src/gui/kernel/qplatformcursor.h1
-rw-r--r--src/gui/kernel/qwindow.cpp2
-rw-r--r--src/gui/math3d/qmatrix4x4.h1
-rw-r--r--src/gui/math3d/qquaternion.h1
-rw-r--r--src/gui/math3d/qvector2d.h1
-rw-r--r--src/gui/math3d/qvector3d.h1
-rw-r--r--src/gui/math3d/qvector4d.h1
-rw-r--r--src/gui/opengl/qopenglframebufferobject.cpp6
-rw-r--r--src/gui/opengl/qopenglfunctions.cpp8
-rw-r--r--src/gui/painting/qcolorspace.cpp10
-rw-r--r--src/gui/painting/qtransform.h1
-rw-r--r--src/gui/rhi/qrhi_p.h20
-rw-r--r--src/gui/rhi/qrhid3d11.cpp2
-rw-r--r--src/gui/rhi/qrhigles2.cpp3
-rw-r--r--src/gui/rhi/qrhimetal.mm5
-rw-r--r--src/gui/rhi/qrhivulkan.cpp2
-rw-r--r--src/gui/text/qcssparser.cpp1
-rw-r--r--src/gui/text/qcssparser_p.h4
-rw-r--r--src/gui/text/qtextcursor.cpp1
-rw-r--r--src/gui/text/qtextdocument.cpp14
-rw-r--r--src/gui/text/qtexthtmlparser.cpp7
-rw-r--r--src/network/ssl/qsslsocket.cpp2
-rw-r--r--src/network/ssl/qsslsocket_openssl.cpp12
-rw-r--r--src/opengl/qgl.cpp2
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm11
-rw-r--r--src/platformsupport/platformsupport.pro2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibility.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoacursor.h3
-rw-r--r--src/plugins/platforms/cocoa/qcocoacursor.mm25
-rw-r--r--src/plugins/platforms/cocoa/qcocoadrag.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.h4
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm20
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm10
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm9
-rw-r--r--src/plugins/platforms/ios/qiostextresponder.mm8
-rw-r--r--src/plugins/platforms/qnx/qqnxscreeneventthread.cpp24
-rw-r--r--src/plugins/platforms/qnx/qqnxscreeneventthread.h2
-rw-r--r--src/plugins/platforms/wasm/qwasmopenglcontext.cpp7
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.cpp25
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsinputcontext.cpp7
-rw-r--r--src/plugins/platforms/windows/qwindowssystemtrayicon.cpp10
-rw-r--r--src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp15
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp11
-rw-r--r--src/plugins/sqldrivers/README4
-rw-r--r--src/plugins/sqldrivers/psql/qsql_psql.cpp35
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac.mm8
-rw-r--r--src/sql/doc/snippets/code/doc_src_sql-driver.qdoc57
-rw-r--r--src/sql/doc/src/sql-driver.qdoc58
-rw-r--r--src/testlib/doc/snippets/code/doc_src_cmakelists.txt14
-rw-r--r--src/testlib/doc/src/qttest-best-practices.qdoc4
-rw-r--r--src/testlib/doc/src/qttestlib-manual.qdoc43
-rw-r--r--src/testlib/qtest.h2
-rw-r--r--src/tools/androiddeployqt/main.cpp19
-rw-r--r--src/tools/rcc/rcc.cpp20
-rw-r--r--src/widgets/accessible/qaccessiblemenu.cpp2
-rw-r--r--src/widgets/dialogs/qprogressdialog.cpp17
-rw-r--r--src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp4
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp6
-rw-r--r--src/widgets/itemviews/qlistview.cpp4
-rw-r--r--src/widgets/itemviews/qtreeview.cpp2
-rw-r--r--src/widgets/kernel/qapplication.cpp128
-rw-r--r--src/widgets/kernel/qtooltip.cpp43
-rw-r--r--src/widgets/kernel/qwidget.cpp28
-rw-r--r--src/widgets/styles/qcommonstyle.cpp22
-rw-r--r--src/widgets/styles/qfusionstyle.cpp57
-rw-r--r--src/widgets/styles/qstylehelper.cpp9
-rw-r--r--src/widgets/styles/qstyleoption.cpp2
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp10
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp200
-rw-r--r--src/widgets/widgets/qlineedit.cpp33
-rw-r--r--src/widgets/widgets/qmenu.cpp2
-rw-r--r--src/widgets/widgets/qmenubar.cpp3
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp1
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp6
130 files changed, 1362 insertions, 833 deletions
diff --git a/src/3rdparty/sqlite/patches/0001-Fix-CVE-2019-19244-in-SQLite.patch b/src/3rdparty/sqlite/patches/0001-Fix-CVE-2019-19244-in-SQLite.patch
new file mode 100644
index 0000000000..9906292860
--- /dev/null
+++ b/src/3rdparty/sqlite/patches/0001-Fix-CVE-2019-19244-in-SQLite.patch
@@ -0,0 +1,26 @@
+From 676425e522e08eb0e7dfaacdac79a5de27542322 Mon Sep 17 00:00:00 2001
+From: Andy Shaw <andy.shaw@qt.io>
+Date: Wed, 11 Dec 2019 10:51:22 +0100
+Subject: [PATCH 53/53] Fix CVE-2019-19244 in SQLite
+
+Fixes: QTBUG-80635
+Change-Id: I718349e28ec76ea164dd50f2a985f2074dd6bdbd
+---
+ src/3rdparty/sqlite/sqlite3.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c
+index 8fd740b300..bd647ca1c2 100644
+--- a/src/3rdparty/sqlite/sqlite3.c
++++ b/src/3rdparty/sqlite/sqlite3.c
+@@ -131679,6 +131679,7 @@ SQLITE_PRIVATE int sqlite3Select(
+ */
+ if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct
+ && sqlite3ExprListCompare(sSort.pOrderBy, pEList, -1)==0
++ && p->pWin==0
+ ){
+ p->selFlags &= ~SF_Distinct;
+ pGroupBy = p->pGroupBy = sqlite3ExprListDup(db, pEList, 0);
+--
+2.21.0 (Apple Git-122.2)
+
diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c
index 8fd740b300..bd647ca1c2 100644
--- a/src/3rdparty/sqlite/sqlite3.c
+++ b/src/3rdparty/sqlite/sqlite3.c
@@ -131679,6 +131679,7 @@ SQLITE_PRIVATE int sqlite3Select(
*/
if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct
&& sqlite3ExprListCompare(sSort.pOrderBy, pEList, -1)==0
+ && p->pWin==0
){
p->selFlags &= ~SF_Distinct;
pGroupBy = p->pGroupBy = sqlite3ExprListDup(db, pEList, 0);
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake
index 17cc19fc4e..84c75401b1 100644
--- a/src/corelib/Qt5CoreMacros.cmake
+++ b/src/corelib/Qt5CoreMacros.cmake
@@ -385,7 +385,7 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.9)
set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG)
set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG)
if (Qt5_POSITION_INDEPENDENT_CODE
- AND (CMAKE_VERSION VERSION_LESS 2.8.12
+ AND (CMAKE_VERSION VERSION_GREATER_EQUAL 2.8.12
AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)))
set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ${Qt5_POSITION_INDEPENDENT_CODE})
diff --git a/src/corelib/codecs/qgb18030codec.cpp b/src/corelib/codecs/qgb18030codec.cpp
index 4206eacb6f..ca15be1cea 100644
--- a/src/corelib/codecs/qgb18030codec.cpp
+++ b/src/corelib/codecs/qgb18030codec.cpp
@@ -107,7 +107,6 @@ QByteArray QGb18030Codec::convertFromUnicode(const QChar *uc, int len, Converter
if (high >= 0) {
if (uc[i].isLowSurrogate()) {
// valid surrogate pair
- ++i;
uint u = QChar::surrogateToUcs4(high, uc[i].unicode());
len = qt_UnicodeToGb18030(u, buf);
if (len >= 2) {
diff --git a/src/corelib/doc/src/qtcore-index.qdoc b/src/corelib/doc/src/qtcore-index.qdoc
index 40a6584af0..29fc25f69d 100644
--- a/src/corelib/doc/src/qtcore-index.qdoc
+++ b/src/corelib/doc/src/qtcore-index.qdoc
@@ -56,7 +56,7 @@
\include module-use.qdocinc using qt module
\quotefile overview/using-qt-core.cmake
- See also the \l[QtDoc]{Building with CMake} overview.
+ See also the \l[QtDoc]{Build with CMake} overview.
\section2 Building with qmake
diff --git a/src/corelib/doc/src/resource-system.qdoc b/src/corelib/doc/src/resource-system.qdoc
index 69ec5e556b..f9ef317799 100644
--- a/src/corelib/doc/src/resource-system.qdoc
+++ b/src/corelib/doc/src/resource-system.qdoc
@@ -189,13 +189,13 @@
XML file to indicate a file should be most compressed, regardless of
which algorithms \c rcc supports.
- \li \c{zstd}: use the \l{Zstandard}{https://zstd.net} library to compress
+ \li \c{zstd}: use the \l{https://zstd.net}{Zstandard} library to compress
contents. Valid compression levels range from 1 to 19, 1 is least
compression (least CPU time) and 19 is the most compression (most CPU
time). The default level is 14. A special value of 0 tells the \c{zstd}
library to choose an implementation-defined default.
- \li \c{zlib}: use the \l{zlib}{https://zlib.net} library to compress
+ \li \c{zlib}: use the \l{https://zlib.net}{zlib} library to compress
contents. Valid compression levels range from 1 to 9, with 1the least
compression (least CPU time) and 9 the most compression (most CPU time).
The special value 0 means "no compression" and should not be used. The
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index e47f284a42..60dc7ce688 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -506,6 +506,39 @@
#endif
/*
+ * SG10's SD-6 feature detection and some useful extensions from Clang and GCC
+ * https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations
+ * http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros
+ * Not using wrapper macros, per http://eel.is/c++draft/cpp.cond#7.sentence-2
+ */
+#ifndef __has_builtin
+# define __has_builtin(x) 0
+#endif
+#ifndef __has_feature
+# define __has_feature(x) 0
+#endif
+#ifndef __has_attribute
+# define __has_attribute(x) 0
+#endif
+#ifndef __has_cpp_attribute
+# define __has_cpp_attribute(x) 0
+#endif
+#ifndef __has_include
+# define __has_include(x) 0
+#endif
+#ifndef __has_include_next
+# define __has_include_next(x) 0
+#endif
+
+// Kept around until all submodules have transitioned
+#define QT_HAS_BUILTIN(x) __has_builtin(x)
+#define QT_HAS_FEATURE(x) __has_feature(x)
+#define QT_HAS_ATTRIBUTE(x) __has_attribute(x)
+#define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
+#define QT_HAS_INCLUDE(x) __has_include(x)
+#define QT_HAS_INCLUDE_NEXT(x) __has_include_next(x)
+
+/*
* C++11 support
*
* Paper Macro SD-6 macro
@@ -1032,37 +1065,6 @@
#endif
/*
- * SG10's SD-6 feature detection and some useful extensions from Clang and GCC
- * https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations
- * http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros
- */
-#ifdef __has_builtin
-# define QT_HAS_BUILTIN(x) __has_builtin(x)
-#else
-# define QT_HAS_BUILTIN(x) 0
-#endif
-#ifdef __has_attribute
-# define QT_HAS_ATTRIBUTE(x) __has_attribute(x)
-#else
-# define QT_HAS_ATTRIBUTE(x) 0
-#endif
-#ifdef __has_cpp_attribute
-# define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
-#else
-# define QT_HAS_CPP_ATTRIBUTE(x) 0
-#endif
-#ifdef __has_include
-# define QT_HAS_INCLUDE(x) __has_include(x)
-#else
-# define QT_HAS_INCLUDE(x) 0
-#endif
-#ifdef __has_include_next
-# define QT_HAS_INCLUDE_NEXT(x) __has_include_next(x)
-#else
-# define QT_HAS_INCLUDE_NEXT(x) 0
-#endif
-
-/*
* C++11 keywords and expressions
*/
#ifdef Q_COMPILER_NULLPTR
@@ -1138,7 +1140,7 @@
# define Q_DECL_ALIGN(n) alignas(n)
#endif
-#if QT_HAS_CPP_ATTRIBUTE(nodiscard) && !defined(Q_CC_CLANG) // P0188R1
+#if __has_cpp_attribute(nodiscard) && !defined(Q_CC_CLANG) // P0188R1
// Can't use [[nodiscard]] with Clang, see https://bugs.llvm.org/show_bug.cgi?id=33518
# undef Q_REQUIRED_RESULT
# define Q_REQUIRED_RESULT [[nodiscard]]
@@ -1240,11 +1242,6 @@
#ifndef QT_MAKE_CHECKED_ARRAY_ITERATOR
# define QT_MAKE_CHECKED_ARRAY_ITERATOR(x, N) (x)
#endif
-#ifdef __has_feature
-# define QT_HAS_FEATURE(x) __has_feature(x)
-#else
-# define QT_HAS_FEATURE(x) 0
-#endif
/*
* Warning/diagnostic handling
@@ -1335,11 +1332,11 @@
} while (false)
#if defined(__cplusplus)
-#if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough)
+#if __has_cpp_attribute(clang::fallthrough)
# define Q_FALLTHROUGH() [[clang::fallthrough]]
-#elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
+#elif __has_cpp_attribute(gnu::fallthrough)
# define Q_FALLTHROUGH() [[gnu::fallthrough]]
-#elif QT_HAS_CPP_ATTRIBUTE(fallthrough)
+#elif __has_cpp_attribute(fallthrough)
# define Q_FALLTHROUGH() [[fallthrough]]
#endif
#endif
diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h
index e6ad80525a..c6f071bc3f 100644
--- a/src/corelib/global/qconfig-bootstrapped.h
+++ b/src/corelib/global/qconfig-bootstrapped.h
@@ -75,13 +75,13 @@
# define QT_FEATURE_alloca_malloc_h -1
#endif
#define QT_CRYPTOGRAPHICHASH_ONLY_SHA1
-#define QT_FEATURE_cxx11_random (QT_HAS_INCLUDE(<random>) ? 1 : -1)
+#define QT_FEATURE_cxx11_random (__has_include(<random>) ? 1 : -1)
#define QT_NO_DATASTREAM
#define QT_FEATURE_datestring 1
#define QT_FEATURE_datetimeparser -1
#define QT_FEATURE_easingcurve -1
#define QT_FEATURE_etw -1
-#define QT_FEATURE_getauxval (QT_HAS_INCLUDE(<sys/auxv.h>) ? 1 : -1)
+#define QT_FEATURE_getauxval (__has_include(<sys/auxv.h>) ? 1 : -1)
#define QT_FEATURE_getentropy -1
#define QT_NO_GEOM_VARIANT
#define QT_FEATURE_hijricalendar -1
diff --git a/src/corelib/global/qendian.cpp b/src/corelib/global/qendian.cpp
index 7fd6e13d3b..98dc6a9a4b 100644
--- a/src/corelib/global/qendian.cpp
+++ b/src/corelib/global/qendian.cpp
@@ -137,7 +137,7 @@ QT_BEGIN_NAMESPACE
\sa qToLittleEndian()
*/
/*!
- \fn template <typename T> T qFromLittleEndian(const void *src)
+ \fn template <typename T> inline T qFromLittleEndian(const void *src)
\since 4.3
\relates <QtEndian>
@@ -159,7 +159,7 @@ QT_BEGIN_NAMESPACE
\sa qToLittleEndian()
*/
/*!
- \fn template <typename T> T qFromLittleEndian(T src)
+ \fn template <typename T> inline T qFromLittleEndian(T src)
\since 4.3
\relates <QtEndian>
\overload
@@ -171,7 +171,7 @@ QT_BEGIN_NAMESPACE
unmodified.
*/
/*!
- \fn template <typename T> T qFromLittleEndian(const void *src, qsizetype count, void *dest)
+ \fn template <typename T> inline T qFromLittleEndian(const void *src, qsizetype count, void *dest)
\since 5.12
\relates <QtEndian>
diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h
index 5cd9d3160b..257efbbdbe 100644
--- a/src/corelib/global/qendian.h
+++ b/src/corelib/global/qendian.h
@@ -66,7 +66,7 @@ template <typename T> Q_ALWAYS_INLINE void qToUnaligned(const T src, void *dest)
// Using sizeof(T) inside memcpy function produces internal compiler error with
// MSVC2008/ARM in tst_endian -> use extra indirection to resolve size of T.
const size_t size = sizeof(T);
-#if QT_HAS_BUILTIN(__builtin_memcpy)
+#if __has_builtin(__builtin_memcpy)
__builtin_memcpy
#else
memcpy
@@ -78,7 +78,7 @@ template <typename T> Q_ALWAYS_INLINE T qFromUnaligned(const void *src)
{
T dest;
const size_t size = sizeof(T);
-#if QT_HAS_BUILTIN(__builtin_memcpy)
+#if __has_builtin(__builtin_memcpy)
__builtin_memcpy
#else
memcpy
diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h
index 9a4f1800a4..02fd2f03cc 100644
--- a/src/corelib/global/qfloat16.h
+++ b/src/corelib/global/qfloat16.h
@@ -239,6 +239,7 @@ QF16_MAKE_ARITH_OP_INT(/)
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wfloat-equal")
QT_WARNING_DISABLE_GCC("-Wfloat-equal")
+QT_WARNING_DISABLE_INTEL(1572)
inline bool operator>(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) > static_cast<float>(b); }
inline bool operator<(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) < static_cast<float>(b); }
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 4ab5bd2edb..b662233d4e 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -92,7 +92,7 @@
# include <sys/systeminfo.h>
#endif
-#if defined(Q_OS_DARWIN) && QT_HAS_INCLUDE(<IOKit/IOKitLib.h>)
+#if defined(Q_OS_DARWIN) && __has_include(<IOKit/IOKitLib.h>)
# include <IOKit/IOKitLib.h>
# include <private/qcore_mac_p.h>
#endif
@@ -3041,7 +3041,7 @@ enum {
*/
QByteArray QSysInfo::machineUniqueId()
{
-#if defined(Q_OS_DARWIN) && QT_HAS_INCLUDE(<IOKit/IOKitLib.h>)
+#if defined(Q_OS_DARWIN) && __has_include(<IOKit/IOKitLib.h>)
char uuid[UuidStringLen + 1];
io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
QCFString stringRef = (CFStringRef)IORegistryEntryCreateCFProperty(service, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0);
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 1e26e9453a..e636a7cf8f 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -769,7 +769,7 @@ inline void qt_noop(void) {}
#if !defined(QT_NO_EXCEPTIONS)
# if !defined(Q_MOC_RUN)
-# if (defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !QT_HAS_FEATURE(cxx_exceptions)) || \
+# if (defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !__has_feature(cxx_exceptions)) || \
(defined(Q_CC_GNU) && !defined(__EXCEPTIONS))
# define QT_NO_EXCEPTIONS
# endif
@@ -944,6 +944,10 @@ QT_WARNING_POP
# define Q_DUMMY_COMPARISON_OPERATOR(C)
#endif
+QT_WARNING_PUSH
+// warning: noexcept-expression evaluates to ‘false’ because of a call to ‘void swap(..., ...)'
+QT_WARNING_DISABLE_GCC("-Wnoexcept")
+
namespace QtPrivate
{
namespace SwapExceptionTester { // insulate users from the "using std::swap" below
@@ -963,6 +967,8 @@ inline void qSwap(T &value1, T &value2)
swap(value1, value2);
}
+QT_WARNING_POP
+
#if QT_DEPRECATED_SINCE(5, 0)
Q_CORE_EXPORT QT_DEPRECATED void *qMalloc(size_t size) Q_ALLOC_SIZE(1);
Q_CORE_EXPORT QT_DEPRECATED void qFree(void *ptr);
diff --git a/src/corelib/global/qglobal_p.h b/src/corelib/global/qglobal_p.h
index 58bc8b7bf3..5ab84fa8be 100644
--- a/src/corelib/global/qglobal_p.h
+++ b/src/corelib/global/qglobal_p.h
@@ -74,7 +74,7 @@ Q_CORE_EXPORT time_t qMkTime(struct tm *when);
QT_END_NAMESPACE
-#if !QT_HAS_BUILTIN(__builtin_available)
+#if !__has_builtin(__builtin_available)
#include <initializer_list>
#include <QtCore/qoperatingsystemversion.h>
#include <QtCore/qversionnumber.h>
@@ -142,7 +142,7 @@ QT_END_NAMESPACE
QT_BUILTIN_AVAILABLE1, \
QT_BUILTIN_AVAILABLE0, )
#define __builtin_available(...) QT_BUILTIN_AVAILABLE_CHOOSER(__VA_ARGS__)(__VA_ARGS__)
-#endif // !QT_HAS_BUILTIN(__builtin_available)
+#endif // !__has_builtin(__builtin_available)
#endif // defined(__cplusplus)
#endif // QGLOBAL_P_H
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 17f2246082..5a7f8242de 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -70,7 +70,7 @@
#if QT_CONFIG(slog2)
#include <sys/slog2.h>
#endif
-#if QT_HAS_INCLUDE(<paths.h>)
+#if __has_include(<paths.h>)
#include <paths.h>
#endif
@@ -106,7 +106,7 @@
# if __UCLIBC_HAS_BACKTRACE__
# define QLOGGING_HAVE_BACKTRACE
# endif
-# elif (defined(__GLIBC__) && defined(__GLIBCXX__)) || (QT_HAS_INCLUDE(<cxxabi.h>) && QT_HAS_INCLUDE(<execinfo.h>))
+# elif (defined(__GLIBC__) && defined(__GLIBCXX__)) || (__has_include(<cxxabi.h>) && __has_include(<execinfo.h>))
# define QLOGGING_HAVE_BACKTRACE
# endif
#endif
@@ -116,7 +116,7 @@ extern char *__progname;
#endif
#ifndef QT_BOOTSTRAPPED
-#if defined(Q_OS_LINUX) && (defined(__GLIBC__) || QT_HAS_INCLUDE(<sys/syscall.h>))
+#if defined(Q_OS_LINUX) && (defined(__GLIBC__) || __has_include(<sys/syscall.h>))
# include <sys/syscall.h>
# if defined(Q_OS_ANDROID) && !defined(SYS_gettid)
@@ -1276,7 +1276,7 @@ void QMessagePattern::setPattern(const QString &pattern)
#if defined(QLOGGING_HAVE_BACKTRACE) && !defined(QT_BOOTSTRAPPED)
// make sure the function has "Message" in the name so the function is removed
-#if ((defined(Q_CC_GNU) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)) || QT_HAS_ATTRIBUTE(optimize)) \
+#if ((defined(Q_CC_GNU) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)) || __has_attribute(optimize)) \
&& !defined(Q_CC_INTEL) && !defined(Q_CC_CLANG)
// force skipping the frame pointer, to save the backtrace() function some work
__attribute__((optimize("omit-frame-pointer")))
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index cce88782e9..bebe67be3f 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -724,9 +724,17 @@
\value LocalDate \e{This enum value is deprecated.} Use Qt::SystemLocaleShortDate
instead (or Qt::SystemLocaleLongDate if you want long dates).
- \value RFC2822Date \l{RFC 2822}, \l{RFC 850} and \l{RFC 1036} format: either
- \c{[ddd,] dd MMM yyyy hh:mm[:ss] +/-TZ} or \c{ddd MMM dd yyyy hh:mm[:ss] +/-TZ}
- for combined dates and times.
+ \value RFC2822Date \l{RFC 2822}, \l{RFC 850} and \l{RFC 1036} format:
+ either \c{[ddd,] dd MMM yyyy [hh:mm[:ss]][ ±tzoff]}
+ or \c{ddd MMM dd[ hh:mm:ss] yyyy[ ±tzoff]} are recognized for combined dates
+ and times, where \c{tzoff} is a timezone offset in \c{hhmm} format. For
+ dates and times separately, the same formats are matched and the unwanted
+ parts are ignored. In particular, note that a time is not recognized without
+ an accompanying date. When converting dates to string form,
+ format \c{dd MMM yyyy} is used, for times the format is \c{hh:mm:ss}. For
+ combined date and time, these are combined
+ as \c{dd MMM yyyy hh:mm:ss ±tzoff} (omitting the optional leading day of the
+ week from the first format recognized).
\note For \c ISODate formats, each \c Y, \c M and \c D represents a single digit
of the year, month and day used to specify the date. Each \c H, \c M and \c S
diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h
index 86e7997680..fdfcbda6ca 100644
--- a/src/corelib/global/qnumeric_p.h
+++ b/src/corelib/global/qnumeric_p.h
@@ -249,7 +249,7 @@ QT_WARNING_POP
// size_t. Implementations for 8- and 16-bit types will work but may not be as
// efficient. Implementations for 64-bit may be missing on 32-bit platforms.
-#if (defined(Q_CC_GNU) && (Q_CC_GNU >= 500) || (defined(Q_CC_INTEL) && !defined(Q_OS_WIN))) || QT_HAS_BUILTIN(__builtin_add_overflow)
+#if (defined(Q_CC_GNU) && (Q_CC_GNU >= 500) || (defined(Q_CC_INTEL) && !defined(Q_OS_WIN))) || __has_builtin(__builtin_add_overflow)
// GCC 5, ICC 18, and Clang 3.8 have builtins to detect overflows
template <typename T> inline
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index c3abec8989..38cb6a423d 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -55,7 +55,7 @@
#include <stdio.h>
#include <errno.h>
-#if QT_HAS_INCLUDE(<paths.h>)
+#if __has_include(<paths.h>)
# include <paths.h>
#endif
#ifndef _PATH_TMP // from <paths.h>
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 35ca2542f7..3a77242d7c 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -100,7 +100,7 @@ QT_END_NAMESPACE
#include <private/qcore_unix_p.h>
#endif
-#if QT_HAS_INCLUDE(<paths.h>)
+#if __has_include(<paths.h>)
#include <paths.h>
#endif
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index 22c22ce711..5cbe49e2f7 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -280,9 +280,9 @@ static inline QStringList *resourceSearchPaths()
RCC tool used to compress the payload.
\value NoCompression Contents are not compressed
- \value ZlibCompression Contents are compressed using \l{zlib}{https://zlib.net} and can
+ \value ZlibCompression Contents are compressed using \l{https://zlib.net}{zlib} and can
be decompressed using the qUncompress() function.
- \value ZstdCompression Contents are compressed using \l{zstd}{https://zstd.net}. To
+ \value ZstdCompression Contents are compressed using \l{https://zstd.net}{zstd}. To
decompress, use the \c{ZSTD_decompress} function from the zstd
library.
diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp
index 6ebef3ee20..bca454fc7a 100644
--- a/src/corelib/io/qstandardpaths.cpp
+++ b/src/corelib/io/qstandardpaths.cpp
@@ -48,7 +48,7 @@
#include <qcoreapplication.h>
#endif
-#if QT_HAS_INCLUDE(<paths.h>)
+#if __has_include(<paths.h>)
#include <paths.h>
#endif
@@ -357,14 +357,14 @@ QT_BEGIN_NAMESPACE
/*!
\fn QString QStandardPaths::writableLocation(StandardLocation type)
- \include standardpath/functiondoc.qdocinc writableLocation
+ \include standardpath/functiondocs.qdocinc writableLocation
*/
/*!
\fn QStringList QStandardPaths::standardLocations(StandardLocation type)
- \include standardpath/functiondoc.qdocinc standardLocations
+ \include standardpath/functiondocs.qdocinc standardLocations
\sa writableLocation()
*/
@@ -388,7 +388,7 @@ static bool existsAsSpecified(const QString &path, QStandardPaths::LocateOptions
}
/*!
- \include standardpath/functiondoc.qdocinc locate
+ \include standardpath/functiondocs.qdocinc locate
*/
QString QStandardPaths::locate(StandardLocation type, const QString &fileName, LocateOptions options)
{
@@ -402,7 +402,7 @@ QString QStandardPaths::locate(StandardLocation type, const QString &fileName, L
}
/*!
- \include standardpath/functiondoc.qdocinc locateAll
+ \include standardpath/functiondocs.qdocinc locateAll
*/
QStringList QStandardPaths::locateAll(StandardLocation type, const QString &fileName, LocateOptions options)
{
@@ -475,7 +475,7 @@ static inline QString
#endif // Q_OS_WIN
/*!
- \include standardpath/functiondoc.qdocinc findExecutable
+ \include standardpath/functiondocs.qdocinc findExecutable
*/
QString QStandardPaths::findExecutable(const QString &executableName, const QStringList &paths)
{
@@ -533,7 +533,7 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr
}
/*!
- \include standardpath/functiondoc.qdocinc displayName
+ \include standardpath/functiondocs.qdocinc displayName
*/
#if !defined(Q_OS_MAC) && !defined(QT_BOOTSTRAPPED)
@@ -590,7 +590,7 @@ QString QStandardPaths::displayName(StandardLocation type)
/*!
\fn void QStandardPaths::setTestModeEnabled(bool testMode)
- \include standardpath/functiondoc.qdocinc setTestModeEnabled
+ \include standardpath/functiondocs.qdocinc setTestModeEnabled
*/
static bool qsp_testMode = false;
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp
index 1e72241e68..37b8a60c37 100644
--- a/src/corelib/io/qstorageinfo_unix.cpp
+++ b/src/corelib/io/qstorageinfo_unix.cpp
@@ -108,7 +108,7 @@
# endif // QT_LARGEFILE_SUPPORT
#endif // Q_OS_BSD4
-#if QT_HAS_INCLUDE(<paths.h>)
+#if __has_include(<paths.h>)
# include <paths.h>
#endif
#ifndef _PATH_MOUNTED
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
index 978102035e..21303549ab 100644
--- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
@@ -2682,6 +2682,7 @@ void QSortFilterProxyModel::setFilterCaseSensitivity(Qt::CaseSensitivity cs)
d->filter_about_to_be_changed();
d->filter_data.setCaseSensitivity(cs);
d->filter_changed();
+ emit filterCaseSensitivityChanged(cs);
}
/*!
@@ -2707,6 +2708,7 @@ void QSortFilterProxyModel::setSortCaseSensitivity(Qt::CaseSensitivity cs)
d->sort_casesensitivity = cs;
d->sort();
+ emit sortCaseSensitivityChanged(cs);
}
/*!
@@ -2732,6 +2734,7 @@ void QSortFilterProxyModel::setSortLocaleAware(bool on)
d->sort_localeaware = on;
d->sort();
+ emit sortLocaleAwareChanged(on);
}
/*!
@@ -2856,6 +2859,7 @@ void QSortFilterProxyModel::setSortRole(int role)
return;
d->sort_role = role;
d->sort();
+ emit sortRoleChanged(role);
}
/*!
@@ -2881,6 +2885,7 @@ void QSortFilterProxyModel::setFilterRole(int role)
d->filter_about_to_be_changed();
d->filter_role = role;
d->filter_changed();
+ emit filterRoleChanged(role);
}
/*!
@@ -2907,6 +2912,7 @@ void QSortFilterProxyModel::setRecursiveFilteringEnabled(bool recursive)
d->filter_about_to_be_changed();
d->filter_recursive = recursive;
d->filter_changed();
+ emit recursiveFilteringEnabledChanged(recursive);
}
#if QT_DEPRECATED_SINCE(5, 11)
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.h b/src/corelib/itemmodels/qsortfilterproxymodel.h
index 303226668f..91253dd601 100644
--- a/src/corelib/itemmodels/qsortfilterproxymodel.h
+++ b/src/corelib/itemmodels/qsortfilterproxymodel.h
@@ -68,12 +68,12 @@ class Q_CORE_EXPORT QSortFilterProxyModel : public QAbstractProxyModel
#endif
Q_PROPERTY(int filterKeyColumn READ filterKeyColumn WRITE setFilterKeyColumn)
Q_PROPERTY(bool dynamicSortFilter READ dynamicSortFilter WRITE setDynamicSortFilter)
- Q_PROPERTY(Qt::CaseSensitivity filterCaseSensitivity READ filterCaseSensitivity WRITE setFilterCaseSensitivity)
- Q_PROPERTY(Qt::CaseSensitivity sortCaseSensitivity READ sortCaseSensitivity WRITE setSortCaseSensitivity)
- Q_PROPERTY(bool isSortLocaleAware READ isSortLocaleAware WRITE setSortLocaleAware)
- Q_PROPERTY(int sortRole READ sortRole WRITE setSortRole)
- Q_PROPERTY(int filterRole READ filterRole WRITE setFilterRole)
- Q_PROPERTY(bool recursiveFilteringEnabled READ isRecursiveFilteringEnabled WRITE setRecursiveFilteringEnabled)
+ Q_PROPERTY(Qt::CaseSensitivity filterCaseSensitivity READ filterCaseSensitivity WRITE setFilterCaseSensitivity NOTIFY filterCaseSensitivityChanged)
+ Q_PROPERTY(Qt::CaseSensitivity sortCaseSensitivity READ sortCaseSensitivity WRITE setSortCaseSensitivity NOTIFY sortCaseSensitivityChanged)
+ Q_PROPERTY(bool isSortLocaleAware READ isSortLocaleAware WRITE setSortLocaleAware NOTIFY sortLocaleAwareChanged)
+ Q_PROPERTY(int sortRole READ sortRole WRITE setSortRole NOTIFY sortRoleChanged)
+ Q_PROPERTY(int filterRole READ filterRole WRITE setFilterRole NOTIFY filterRoleChanged)
+ Q_PROPERTY(bool recursiveFilteringEnabled READ isRecursiveFilteringEnabled WRITE setRecursiveFilteringEnabled NOTIFY recursiveFilteringEnabledChanged)
public:
explicit QSortFilterProxyModel(QObject *parent = nullptr);
@@ -185,6 +185,16 @@ public:
QStringList mimeTypes() const override;
Qt::DropActions supportedDropActions() const override;
+
+Q_SIGNALS:
+ void dynamicSortFilterChanged(bool dynamicSortFilter);
+ void filterCaseSensitivityChanged(Qt::CaseSensitivity filterCaseSensitivity);
+ void sortCaseSensitivityChanged(Qt::CaseSensitivity sortCaseSensitivity);
+ void sortLocaleAwareChanged(bool sortLocaleAware);
+ void sortRoleChanged(int sortRole);
+ void filterRoleChanged(int filterRole);
+ void recursiveFilteringEnabledChanged(bool recursiveFilteringEnabled);
+
private:
Q_DECLARE_PRIVATE(QSortFilterProxyModel)
Q_DISABLE_COPY(QSortFilterProxyModel)
diff --git a/src/corelib/kernel/qdeadlinetimer.h b/src/corelib/kernel/qdeadlinetimer.h
index 9dd92481d2..99e09eb31f 100644
--- a/src/corelib/kernel/qdeadlinetimer.h
+++ b/src/corelib/kernel/qdeadlinetimer.h
@@ -52,7 +52,7 @@
#include <limits>
-#if QT_HAS_INCLUDE(<chrono>)
+#if __has_include(<chrono>)
# include <chrono>
#endif
@@ -120,7 +120,7 @@ public:
QDeadlineTimer &operator-=(qint64 msecs)
{ *this = *this + (-msecs); return *this; }
-#if QT_HAS_INCLUDE(<chrono>) || defined(Q_CLANG_QDOC)
+#if __has_include(<chrono>) || defined(Q_CLANG_QDOC)
template <class Clock, class Duration>
QDeadlineTimer(std::chrono::time_point<Clock, Duration> deadline_,
Qt::TimerType type_ = Qt::CoarseTimer) : t2(0)
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 540b8b32c1..f5d7c22e3a 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -55,7 +55,7 @@
#include <QtCore/qobject_impl.h>
-#if QT_HAS_INCLUDE(<chrono>)
+#if __has_include(<chrono>)
# include <chrono>
#endif
@@ -160,7 +160,7 @@ public:
void moveToThread(QThread *thread);
int startTimer(int interval, Qt::TimerType timerType = Qt::CoarseTimer);
-#if QT_HAS_INCLUDE(<chrono>)
+#if __has_include(<chrono>)
Q_ALWAYS_INLINE
int startTimer(std::chrono::milliseconds time, Qt::TimerType timerType = Qt::CoarseTimer)
{
diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp
index 948f697dc5..4d8778ecf5 100644
--- a/src/corelib/kernel/qtimer.cpp
+++ b/src/corelib/kernel/qtimer.cpp
@@ -84,10 +84,10 @@ QT_BEGIN_NAMESPACE
must start and stop the timer in its thread; it is not possible to
start a timer from another thread.
- As a special case, a QTimer with a timeout of 0 will time out as
- soon as all the events in the window system's event queue have
- been processed. This can be used to do heavy work while providing
- a snappy user interface:
+ As a special case, a QTimer with a timeout of 0 will time out as soon as
+ possible, though the ordering between zero timers and other sources of
+ events is unspecified. Zero timers can be used to do some work while still
+ providing a snappy user interface:
\snippet timers/timers.cpp 4
\snippet timers/timers.cpp 5
diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h
index eb7185c12d..6bbfd741d9 100644
--- a/src/corelib/kernel/qtimer.h
+++ b/src/corelib/kernel/qtimer.h
@@ -47,7 +47,7 @@
#include <QtCore/qbasictimer.h> // conceptual inheritance
#include <QtCore/qobject.h>
-#if QT_HAS_INCLUDE(<chrono>)
+#if __has_include(<chrono>)
# include <chrono>
#endif
@@ -177,7 +177,7 @@ Q_SIGNALS:
void timeout(QPrivateSignal);
public:
-#if QT_HAS_INCLUDE(<chrono>) || defined(Q_QDOC)
+#if __has_include(<chrono>) || defined(Q_QDOC)
void setInterval(std::chrono::milliseconds value)
{
setInterval(int(value.count()));
@@ -223,7 +223,7 @@ private:
static void singleShotImpl(int msec, Qt::TimerType timerType,
const QObject *receiver, QtPrivate::QSlotObjectBase *slotObj);
-#if QT_HAS_INCLUDE(<chrono>)
+#if __has_include(<chrono>)
static Qt::TimerType defaultTypeFor(std::chrono::milliseconds interval)
{ return defaultTypeFor(int(interval.count())); }
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 43a3fb1db0..a1e1c71d12 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -2577,8 +2577,8 @@ void QVariant::save(QDataStream &s) const
} else if (typeId >= QMetaType::QKeySequence && typeId <= QMetaType::QQuaternion) {
// and as a result these types received lower ids too
typeId +=1;
- } else if (typeId == QMetaType::QPolygonF) {
- // This existed in Qt 4 only as a custom type
+ } else if (typeId == QMetaType::QPolygonF || typeId == QMetaType::QUuid) {
+ // These existed in Qt 4 only as a custom type
typeId = 127;
fakeUserType = true;
}
@@ -4520,15 +4520,24 @@ QSequentialIterable::const_iterator QSequentialIterable::end() const
return it;
}
+static const QVariant variantFromVariantDataHelper(const QtMetaTypePrivate::VariantData &d) {
+ QVariant v;
+ if (d.metaTypeId == qMetaTypeId<QVariant>())
+ v = *reinterpret_cast<const QVariant*>(d.data);
+ else
+ v = QVariant(d.metaTypeId, d.data, d.flags & ~QVariantConstructionFlags::ShouldDeleteVariantData);
+ if (d.flags & QVariantConstructionFlags::ShouldDeleteVariantData)
+ QMetaType::destroy(d.metaTypeId, const_cast<void *>(d.data));
+ return v;
+}
+
/*!
Returns the element at position \a idx in the container.
*/
QVariant QSequentialIterable::at(int idx) const
{
const QtMetaTypePrivate::VariantData d = m_impl.at(idx);
- if (d.metaTypeId == qMetaTypeId<QVariant>())
- return *reinterpret_cast<const QVariant*>(d.data);
- return QVariant(d.metaTypeId, d.data, d.flags);
+ return variantFromVariantDataHelper(d);
}
/*!
@@ -4605,9 +4614,7 @@ QSequentialIterable::const_iterator::operator=(const const_iterator &other)
const QVariant QSequentialIterable::const_iterator::operator*() const
{
const QtMetaTypePrivate::VariantData d = m_impl.getCurrent();
- if (d.metaTypeId == qMetaTypeId<QVariant>())
- return *reinterpret_cast<const QVariant*>(d.data);
- return QVariant(d.metaTypeId, d.data, d.flags);
+ return variantFromVariantDataHelper(d);
}
/*!
@@ -4939,10 +4946,7 @@ QAssociativeIterable::const_iterator::operator=(const const_iterator &other)
const QVariant QAssociativeIterable::const_iterator::operator*() const
{
const QtMetaTypePrivate::VariantData d = m_impl.getCurrentValue();
- QVariant v(d.metaTypeId, d.data, d.flags);
- if (d.metaTypeId == qMetaTypeId<QVariant>())
- return *reinterpret_cast<const QVariant*>(d.data);
- return v;
+ return variantFromVariantDataHelper(d);
}
/*!
@@ -4951,10 +4955,7 @@ const QVariant QAssociativeIterable::const_iterator::operator*() const
const QVariant QAssociativeIterable::const_iterator::key() const
{
const QtMetaTypePrivate::VariantData d = m_impl.getCurrentKey();
- QVariant v(d.metaTypeId, d.data, d.flags);
- if (d.metaTypeId == qMetaTypeId<QVariant>())
- return *reinterpret_cast<const QVariant*>(d.data);
- return v;
+ return variantFromVariantDataHelper(d);
}
/*!
@@ -4962,11 +4963,7 @@ const QVariant QAssociativeIterable::const_iterator::key() const
*/
const QVariant QAssociativeIterable::const_iterator::value() const
{
- const QtMetaTypePrivate::VariantData d = m_impl.getCurrentValue();
- QVariant v(d.metaTypeId, d.data, d.flags);
- if (d.metaTypeId == qMetaTypeId<QVariant>())
- return *reinterpret_cast<const QVariant*>(d.data);
- return v;
+ return operator*();
}
/*!
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index e7d3d9c835..a4957472ec 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -53,7 +53,7 @@
#include <QtCore/qbytearraylist.h>
#endif
-#if QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L
+#if __has_include(<variant>) && __cplusplus >= 201703L
#include <variant>
#elif defined(Q_CLANG_QDOC)
namespace std { template<typename...> struct variant; }
@@ -370,7 +370,7 @@ class Q_CORE_EXPORT QVariant
static inline QVariant fromValue(const T &value)
{ return QVariant(qMetaTypeId<T>(), &value, QTypeInfo<T>::isPointer); }
-#if (QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L) || defined(Q_CLANG_QDOC)
+#if (__has_include(<variant>) && __cplusplus >= 201703L) || defined(Q_CLANG_QDOC)
template<typename... Types>
static inline QVariant fromStdVariant(const std::variant<Types...> &value)
{
@@ -544,7 +544,7 @@ inline QVariant QVariant::fromValue(const QVariant &value)
return value;
}
-#if QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L
+#if __has_include(<variant>) && __cplusplus >= 201703L
template<>
inline QVariant QVariant::fromValue(const std::monostate &)
{
diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h
index 3d87beac83..b8b63b5e6f 100644
--- a/src/corelib/kernel/qvariant_p.h
+++ b/src/corelib/kernel/qvariant_p.h
@@ -105,6 +105,11 @@ inline T *v_cast(QVariant::Private *d, T * = nullptr)
#endif
+enum QVariantConstructionFlags : uint {
+ Default = 0x0,
+ PointerType = 0x1,
+ ShouldDeleteVariantData = 0x2 // only used in Q*Iterable
+};
//a simple template that avoids to allocate 2 memory chunks when creating a QVariant
template <class T> class QVariantPrivateSharedEx : public QVariant::PrivateShared
diff --git a/src/corelib/serialization/qcborarray.h b/src/corelib/serialization/qcborarray.h
index e06544f245..fe06b8630f 100644
--- a/src/corelib/serialization/qcborarray.h
+++ b/src/corelib/serialization/qcborarray.h
@@ -214,7 +214,7 @@ public:
bool contains(const QCborValue &value) const;
int compare(const QCborArray &other) const noexcept Q_DECL_PURE_FUNCTION;
-#if 0 && QT_HAS_INCLUDE(<compare>)
+#if 0 && __has_include(<compare>)
std::strong_ordering operator<=>(const QCborArray &other) const
{
int c = compare(other);
diff --git a/src/corelib/serialization/qcbormap.h b/src/corelib/serialization/qcbormap.h
index 4aea901eef..6636ce776a 100644
--- a/src/corelib/serialization/qcbormap.h
+++ b/src/corelib/serialization/qcbormap.h
@@ -245,7 +245,7 @@ public:
{ const_iterator it = find(key); return it != end(); }
int compare(const QCborMap &other) const noexcept Q_DECL_PURE_FUNCTION;
-#if 0 && QT_HAS_INCLUDE(<compare>)
+#if 0 && __has_include(<compare>)
std::strong_ordering operator<=>(const QCborMap &other) const
{
int c = compare(other);
diff --git a/src/corelib/serialization/qcborvalue.cpp b/src/corelib/serialization/qcborvalue.cpp
index 9053618014..4052bfa22e 100644
--- a/src/corelib/serialization/qcborvalue.cpp
+++ b/src/corelib/serialization/qcborvalue.cpp
@@ -758,6 +758,81 @@ QT_BEGIN_NAMESPACE
using namespace QtCbor;
+static QCborValue::Type convertToExtendedType(QCborContainerPrivate *d)
+{
+ qint64 tag = d->elements.at(0).value;
+ auto &e = d->elements[1];
+ const ByteData *b = d->byteData(e);
+
+ auto replaceByteData = [&](const char *buf, qsizetype len, Element::ValueFlags f) {
+ d->data.clear();
+ d->usedData = 0;
+ e.flags = Element::HasByteData | f;
+ e.value = d->addByteData(buf, len);
+ };
+
+ switch (tag) {
+ case qint64(QCborKnownTags::DateTimeString):
+ case qint64(QCborKnownTags::UnixTime_t): {
+ QDateTime dt;
+ if (tag == qint64(QCborKnownTags::DateTimeString) && b &&
+ e.type == QCborValue::String && (e.flags & Element::StringIsUtf16) == 0) {
+ // The data is supposed to be US-ASCII. If it isn't (contains UTF-8),
+ // QDateTime::fromString will fail anyway.
+ dt = QDateTime::fromString(b->asLatin1(), Qt::ISODateWithMs);
+ } else if (tag == qint64(QCborKnownTags::UnixTime_t) && e.type == QCborValue::Integer) {
+ dt = QDateTime::fromSecsSinceEpoch(e.value, Qt::UTC);
+ } else if (tag == qint64(QCborKnownTags::UnixTime_t) && e.type == QCborValue::Double) {
+ dt = QDateTime::fromMSecsSinceEpoch(qint64(e.fpvalue() * 1000), Qt::UTC);
+ }
+ if (dt.isValid()) {
+ QByteArray text = dt.toString(Qt::ISODateWithMs).toLatin1();
+ replaceByteData(text, text.size(), Element::StringIsAscii);
+ e.type = QCborValue::String;
+ d->elements[0].value = qint64(QCborKnownTags::DateTimeString);
+ return QCborValue::DateTime;
+ }
+ break;
+ }
+
+ case qint64(QCborKnownTags::Url):
+ if (e.type == QCborValue::String) {
+ if (b) {
+ // normalize to a short (decoded) form, so as to save space
+ QUrl url(e.flags & Element::StringIsUtf16 ?
+ b->asQStringRaw() :
+ b->toUtf8String());
+ QByteArray encoded = url.toString(QUrl::DecodeReserved).toUtf8();
+ replaceByteData(encoded, encoded.size(), {});
+ }
+ return QCborValue::Url;
+ }
+ break;
+
+ case quint64(QCborKnownTags::RegularExpression):
+ if (e.type == QCborValue::String) {
+ // no normalization is necessary
+ return QCborValue::RegularExpression;
+ }
+ break;
+
+ case qint64(QCborKnownTags::Uuid):
+ if (e.type == QCborValue::ByteArray) {
+ // force the size to 16
+ char buf[sizeof(QUuid)] = {};
+ if (b)
+ memcpy(buf, b->byte(), qMin(sizeof(buf), size_t(b->len)));
+ replaceByteData(buf, sizeof(buf), {});
+
+ return QCborValue::Uuid;
+ }
+ break;
+ }
+
+ // no enriching happened
+ return QCborValue::Tag;
+}
+
// in qcborstream.cpp
extern void qt_cbor_stream_set_error(QCborStreamReaderPrivate *d, QCborError error);
@@ -1384,77 +1459,10 @@ static QCborValue taggedValueFromCbor(QCborStreamReader &reader)
d->decodeValueFromCbor(reader);
}
- QCborValue::Type type = QCborValue::Tag;
+ QCborValue::Type type;
if (reader.lastError() == QCborError::NoError) {
// post-process to create our extended types
- qint64 tag = d->elements.at(0).value;
- auto &e = d->elements[1];
- const ByteData *b = d->byteData(e);
-
- auto replaceByteData = [&](const char *buf, qsizetype len) {
- d->data.clear();
- d->usedData = 0;
- e.flags = Element::HasByteData | Element::StringIsAscii;
- e.value = d->addByteData(buf, len);
- };
-
- switch (tag) {
- case qint64(QCborKnownTags::DateTimeString):
- case qint64(QCborKnownTags::UnixTime_t): {
- QDateTime dt;
- if (tag == qint64(QCborKnownTags::DateTimeString) && b &&
- e.type == QCborValue::String && (e.flags & Element::StringIsUtf16) == 0) {
- // The data is supposed to be US-ASCII. If it isn't,
- // QDateTime::fromString will fail anyway.
- dt = QDateTime::fromString(b->asLatin1(), Qt::ISODateWithMs);
- } else if (tag == qint64(QCborKnownTags::UnixTime_t) && e.type == QCborValue::Integer) {
- dt = QDateTime::fromSecsSinceEpoch(e.value, Qt::UTC);
- } else if (tag == qint64(QCborKnownTags::UnixTime_t) && e.type == QCborValue::Double) {
- dt = QDateTime::fromMSecsSinceEpoch(qint64(e.fpvalue() * 1000), Qt::UTC);
- }
- if (dt.isValid()) {
- QByteArray text = dt.toString(Qt::ISODateWithMs).toLatin1();
- replaceByteData(text, text.size());
- e.type = QCborValue::String;
- d->elements[0].value = qint64(QCborKnownTags::DateTimeString);
- type = QCborValue::DateTime;
- }
- break;
- }
-
- case qint64(QCborKnownTags::Url):
- if (e.type == QCborValue::String) {
- if (b) {
- // normalize to a short (decoded) form, so as to save space
- QUrl url(e.flags & Element::StringIsUtf16 ?
- b->asQStringRaw() :
- b->toUtf8String());
- QByteArray encoded = url.toString(QUrl::DecodeReserved).toUtf8();
- replaceByteData(encoded, encoded.size());
- }
- type = QCborValue::Url;
- }
- break;
-
- case quint64(QCborKnownTags::RegularExpression):
- if (e.type == QCborValue::String) {
- // no normalization is necessary
- type = QCborValue::RegularExpression;
- }
- break;
-
- case qint64(QCborKnownTags::Uuid):
- if (e.type == QCborValue::ByteArray) {
- // force the size to 16
- char buf[sizeof(QUuid)] = {};
- if (b)
- memcpy(buf, b->byte(), qMin(sizeof(buf), size_t(b->len)));
- replaceByteData(buf, sizeof(buf));
-
- type = QCborValue::Uuid;
- }
- break;
- }
+ type = convertToExtendedType(d);
} else {
// decoding error
type = QCborValue::Invalid;
@@ -1717,21 +1725,22 @@ QCborValue::QCborValue(const QCborMap &m)
}
/*!
- \fn QCborValue::QCborValue(QCborTag t, const QCborValue &tv)
- \fn QCborValue::QCborValue(QCborKnownTags t, const QCborValue &tv)
+ \fn QCborValue::QCborValue(QCborTag tag, const QCborValue &tv)
+ \fn QCborValue::QCborValue(QCborKnownTags tag, const QCborValue &tv)
Creates a QCborValue for the extended type represented by the tag value \a
- t, tagging value \a tv. The tag can later be retrieved using tag() and
+ tag, tagging value \a tv. The tag can later be retrieved using tag() and
the tagged value using taggedValue().
\sa isTag(), tag(), taggedValue(), QCborKnownTags
*/
-QCborValue::QCborValue(QCborTag t, const QCborValue &tv)
+QCborValue::QCborValue(QCborTag tag, const QCborValue &tv)
: n(-1), container(new QCborContainerPrivate), t(Tag)
{
container->ref.storeRelaxed(1);
- container->append(t);
+ container->append(tag);
container->append(tv);
+ t = convertToExtendedType(container);
}
/*!
diff --git a/src/corelib/serialization/qcborvalue.h b/src/corelib/serialization/qcborvalue.h
index f79fc572c4..914103b0a5 100644
--- a/src/corelib/serialization/qcborvalue.h
+++ b/src/corelib/serialization/qcborvalue.h
@@ -59,7 +59,7 @@
# undef False
#endif
-#if 0 && QT_HAS_INCLUDE(<compare>)
+#if 0 && __has_include(<compare>)
# include <compare>
#endif
@@ -261,7 +261,7 @@ public:
QCborValueRef operator[](const QString & key);
int compare(const QCborValue &other) const;
-#if 0 && QT_HAS_INCLUDE(<compare>)
+#if 0 && __has_include(<compare>)
std::strong_ordering operator<=>(const QCborValue &other) const
{
int c = compare(other);
@@ -411,7 +411,7 @@ public:
int compare(const QCborValue &other) const
{ return concrete().compare(other); }
-#if 0 && QT_HAS_INCLUDE(<compare>)
+#if 0 && __has_include(<compare>)
std::strong_ordering operator<=>(const QCborValue &other) const
{
int c = compare(other);
diff --git a/src/corelib/serialization/qcborvalue_p.h b/src/corelib/serialization/qcborvalue_p.h
index 590c2d6e05..48818e4c63 100644
--- a/src/corelib/serialization/qcborvalue_p.h
+++ b/src/corelib/serialization/qcborvalue_p.h
@@ -196,8 +196,7 @@ public:
if (value.container)
return replaceAt_complex(e, value, disp);
- e.value = value.value_helper();
- e.type = value.type();
+ e = { value.value_helper(), value.type() };
if (value.isContainer())
e.container = nullptr;
}
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp
index c50e087c10..e89caabdb0 100644
--- a/src/corelib/text/qbytearray.cpp
+++ b/src/corelib/text/qbytearray.cpp
@@ -332,7 +332,7 @@ int qstricmp(const char *str1, const char *str2)
return int(Incomplete);
};
-#if defined(__SSE4_1__) && !(defined(__SANITIZE_ADDRESS__) || QT_HAS_FEATURE(address_sanitizer))
+#if defined(__SSE4_1__) && !(defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer))
enum { PageSize = 4096, PageMask = PageSize - 1 };
const __m128i zero = _mm_setzero_si128();
forever {
diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h
index 7c571706d8..5d8ccbfb1a 100644
--- a/src/corelib/text/qbytearray.h
+++ b/src/corelib/text/qbytearray.h
@@ -254,7 +254,7 @@ public:
void chop(int n);
#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) && !defined(Q_CLANG_QDOC)
-# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !QT_HAS_CPP_ATTRIBUTE(nodiscard)
+# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !__has_cpp_attribute(nodiscard)
// required due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61941
# pragma push_macro("Q_REQUIRED_RESULT")
# undef Q_REQUIRED_RESULT
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index 51aa0b7512..4d83f19db7 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -146,6 +146,9 @@ qsizetype qFindStringBoyerMoore(QStringView haystack, qsizetype from, QStringVie
static inline qsizetype qFindChar(QStringView str, QChar ch, qsizetype from, Qt::CaseSensitivity cs) noexcept;
template <typename Haystack>
static inline qsizetype qLastIndexOf(Haystack haystack, QChar needle, qsizetype from, Qt::CaseSensitivity cs) noexcept;
+template <>
+inline qsizetype qLastIndexOf(QString haystack, QChar needle,
+ qsizetype from, Qt::CaseSensitivity cs) noexcept = delete; // unwanted, would detach
static inline qsizetype qt_string_count(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs);
static inline qsizetype qt_string_count(QStringView haystack, QChar needle, Qt::CaseSensitivity cs);
@@ -3817,7 +3820,7 @@ int QString::indexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) co
int QString::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) const
{
// ### Qt6: qsizetype
- return int(QtPrivate::lastIndexOf(*this, from, str, cs));
+ return int(QtPrivate::lastIndexOf(QStringView(*this), from, str, cs));
}
#endif // QT_STRINGVIEW_LEVEL < 2
@@ -3856,7 +3859,7 @@ int QString::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) co
int QString::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
{
// ### Qt6: qsizetype
- return int(qLastIndexOf(*this, ch, from, cs));
+ return int(qLastIndexOf(QStringView(*this), ch, from, cs));
}
#if QT_STRINGVIEW_LEVEL < 2
diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h
index 5def2c81a1..1669d7c94a 100644
--- a/src/corelib/text/qstring.h
+++ b/src/corelib/text/qstring.h
@@ -487,7 +487,7 @@ public:
Q_REQUIRED_RESULT QString rightJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const;
#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) && !defined(Q_CLANG_QDOC)
-# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !QT_HAS_CPP_ATTRIBUTE(nodiscard)
+# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !__has_cpp_attribute(nodiscard)
// required due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61941
# pragma push_macro("Q_REQUIRED_RESULT")
# undef Q_REQUIRED_RESULT
diff --git a/src/corelib/thread/qatomic.cpp b/src/corelib/thread/qatomic.cpp
index b1a7edad91..5c3ad9412f 100644
--- a/src/corelib/thread/qatomic.cpp
+++ b/src/corelib/thread/qatomic.cpp
@@ -234,22 +234,26 @@
\sa QAtomicPointer
*/
-/*! \fn QAtomicInt::QAtomicInt(int value)
+/*!
+ \fn QAtomicInt::QAtomicInt(int value)
Constructs a QAtomicInt with the given \a value.
*/
-/*! \fn QAtomicInteger<T>::QAtomicInteger(T value)
+/*!
+ \fn template <typename T> QAtomicInteger<T>::QAtomicInteger(T value)
Constructs a QAtomicInteger with the given \a value.
*/
-/*! \fn template <typename T> QAtomicInteger<T>::QAtomicInteger(const QAtomicInteger &other)
+/*!
+ \fn template <typename T> QAtomicInteger<T>::QAtomicInteger(const QAtomicInteger &other)
Constructs a copy of \a other.
*/
-/*! \fn template <typename T> QAtomicInteger &QAtomicInteger<T>::operator=(const QAtomicInteger &other)
+/*!
+ \fn template <typename T> QAtomicInteger &QAtomicInteger<T>::operator=(const QAtomicInteger &other)
Assigns \a other to this QAtomicInteger and returns a reference to
this QAtomicInteger.
@@ -344,19 +348,22 @@
\sa storeRelaxed(), storeRelease()
*/
-/*! \fn template <typename T> bool QAtomicInteger<T>::isReferenceCountingNative()
+/*!
+ \fn template <typename T> bool QAtomicInteger<T>::isReferenceCountingNative()
Returns \c true if reference counting is implemented using atomic
processor instructions, false otherwise.
*/
-/*! \fn template <typename T> bool QAtomicInteger<T>::isReferenceCountingWaitFree()
+/*!
+ \fn template <typename T> bool QAtomicInteger<T>::isReferenceCountingWaitFree()
Returns \c true if atomic reference counting is wait-free, false
otherwise.
*/
-/*! \fn template <typename T> bool QAtomicInteger<T>::ref()
+/*!
+ \fn template <typename T> bool QAtomicInteger<T>::ref()
Atomically increments the value of this QAtomicInteger. Returns \c true
if the new value is non-zero, false otherwise.
@@ -394,7 +401,8 @@
\sa ref(), operator++(), operator--(int)
*/
-/*! \fn template <typename T> bool QAtomicInteger<T>::deref()
+/*!
+ \fn template <typename T> bool QAtomicInteger<T>::deref()
Atomically decrements the value of this QAtomicInteger. Returns \c true
if the new value is non-zero, false otherwise.
@@ -432,18 +440,21 @@
\sa deref(), operator--(), operator++(int)
*/
-/*! \fn template <typename T> bool QAtomicInteger<T>::isTestAndSetNative()
+/*!
+ \fn template <typename T> bool QAtomicInteger<T>::isTestAndSetNative()
Returns \c true if test-and-set is implemented using atomic processor
instructions, false otherwise.
*/
-/*! \fn template <typename T> bool QAtomicInteger<T>::isTestAndSetWaitFree()
+/*!
+ \fn template <typename T> bool QAtomicInteger<T>::isTestAndSetWaitFree()
Returns \c true if atomic test-and-set is wait-free, false otherwise.
*/
-/*! \fn template <typename T> bool QAtomicInteger<T>::testAndSetRelaxed(T expectedValue, T newValue)
+/*!
+ \fn template <typename T> bool QAtomicInteger<T>::testAndSetRelaxed(T expectedValue, T newValue)
Atomic test-and-set.
@@ -457,7 +468,8 @@
processor to freely reorder memory accesses.
*/
-/*! \fn template <typename T> bool QAtomicInteger<T>::testAndSetAcquire(T expectedValue, T newValue)
+/*!
+ \fn template <typename T> bool QAtomicInteger<T>::testAndSetAcquire(T expectedValue, T newValue)
Atomic test-and-set.
@@ -472,7 +484,8 @@
be re-ordered before the atomic operation.
*/
-/*! \fn template <typename T> bool QAtomicInteger<T>::testAndSetRelease(T expectedValue, T newValue)
+/*!
+ \fn template <typename T> bool QAtomicInteger<T>::testAndSetRelease(T expectedValue, T newValue)
Atomic test-and-set.
@@ -487,7 +500,8 @@
re-ordered after the atomic operation.
*/
-/*! \fn template <typename T> bool QAtomicInteger<T>::testAndSetOrdered(T expectedValue, T newValue)
+/*!
+ \fn template <typename T> bool QAtomicInteger<T>::testAndSetOrdered(T expectedValue, T newValue)
Atomic test-and-set.
@@ -502,19 +516,22 @@
may not be re-ordered.
*/
-/*! \fn template <typename T> bool QAtomicInteger<T>::isFetchAndStoreNative()
+/*!
+ \fn template <typename T> bool QAtomicInteger<T>::isFetchAndStoreNative()
Returns \c true if fetch-and-store is implemented using atomic
processor instructions, false otherwise.
*/
-/*! \fn template <typename T> bool QAtomicInteger<T>::isFetchAndStoreWaitFree()
+/*!
+ \fn template <typename T> bool QAtomicInteger<T>::isFetchAndStoreWaitFree()
Returns \c true if atomic fetch-and-store is wait-free, false
otherwise.
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreRelaxed(T newValue)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreRelaxed(T newValue)
Atomic fetch-and-store.
@@ -526,7 +543,8 @@
processor to freely reorder memory accesses.
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreAcquire(T newValue)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreAcquire(T newValue)
Atomic fetch-and-store.
@@ -539,7 +557,8 @@
be re-ordered before the atomic operation.
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreRelease(T newValue)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreRelease(T newValue)
Atomic fetch-and-store.
@@ -552,7 +571,8 @@
re-ordered after the atomic operation.
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreOrdered(T newValue)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndStoreOrdered(T newValue)
Atomic fetch-and-store.
@@ -565,19 +585,22 @@
may not be re-ordered.
*/
-/*! \fn template <typename T> bool QAtomicInteger<T>::isFetchAndAddNative()
+/*!
+ \fn template <typename T> bool QAtomicInteger<T>::isFetchAndAddNative()
Returns \c true if fetch-and-add is implemented using atomic
processor instructions, false otherwise.
*/
-/*! \fn template <typename T> bool QAtomicInteger<T>::isFetchAndAddWaitFree()
+/*!
+ \fn template <typename T> bool QAtomicInteger<T>::isFetchAndAddWaitFree()
Returns \c true if atomic fetch-and-add is wait-free, false
otherwise.
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAddRelaxed(T valueToAdd)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndAddRelaxed(T valueToAdd)
Atomic fetch-and-add.
@@ -591,7 +614,8 @@
\sa operator+=(), fetchAndSubRelaxed()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAddAcquire(T valueToAdd)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndAddAcquire(T valueToAdd)
Atomic fetch-and-add.
@@ -606,7 +630,8 @@
\sa operator+=(), fetchAndSubAcquire()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAddRelease(T valueToAdd)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndAddRelease(T valueToAdd)
Atomic fetch-and-add.
@@ -621,7 +646,8 @@
\sa operator+=(), fetchAndSubRelease()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAddOrdered(T valueToAdd)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndAddOrdered(T valueToAdd)
Atomic fetch-and-add.
@@ -636,7 +662,8 @@
\sa operator+=(), fetchAndSubOrdered()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::operator+=(T value)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::operator+=(T value)
\since 5.3
Atomic add-and-fetch.
@@ -650,7 +677,8 @@
\sa fetchAndAddOrdered(), operator-=()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndSubRelaxed(T valueToSub)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndSubRelaxed(T valueToSub)
\since 5.3
Atomic fetch-and-sub.
@@ -665,7 +693,8 @@
\sa operator-=(), fetchAndAddRelaxed()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndSubAcquire(T valueToSub)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndSubAcquire(T valueToSub)
\since 5.3
Atomic fetch-and-sub.
@@ -681,7 +710,8 @@
\sa operator-=(), fetchAndAddAcquire()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndSubRelease(T valueToSub)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndSubRelease(T valueToSub)
\since 5.3
Atomic fetch-and-sub.
@@ -697,7 +727,8 @@
\sa operator-=(), fetchAndAddRelease()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndSubOrdered(T valueToSub)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndSubOrdered(T valueToSub)
\since 5.3
Atomic fetch-and-sub.
@@ -713,7 +744,8 @@
\sa operator-=(), fetchAndAddOrdered()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::operator-=(T value)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::operator-=(T value)
\since 5.3
Atomic sub-and-fetch.
@@ -727,7 +759,8 @@
\sa fetchAndSubOrdered(), operator+=()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndOrRelaxed(T valueToOr)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndOrRelaxed(T valueToOr)
\since 5.3
Atomic fetch-and-or.
@@ -742,7 +775,8 @@
\sa operator|=()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndOrAcquire(T valueToOr)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndOrAcquire(T valueToOr)
\since 5.3
Atomic fetch-and-or.
@@ -758,7 +792,8 @@
\sa operator|=()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndOrRelease(T valueToOr)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndOrRelease(T valueToOr)
\since 5.3
Atomic fetch-and-or.
@@ -774,7 +809,8 @@
\sa operator|=()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndOrOrdered(T valueToOr)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndOrOrdered(T valueToOr)
\since 5.3
Atomic fetch-and-or.
@@ -790,7 +826,8 @@
\sa operator|=()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::operator|=(T value)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::operator|=(T value)
\since 5.3
Atomic or-and-fetch.
@@ -804,7 +841,8 @@
\sa fetchAndOrOrdered()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndXorRelaxed(T valueToXor)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndXorRelaxed(T valueToXor)
\since 5.3
Atomic fetch-and-xor.
@@ -819,7 +857,8 @@
\sa operator^=()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndXorAcquire(T valueToXor)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndXorAcquire(T valueToXor)
\since 5.3
Atomic fetch-and-xor.
@@ -835,7 +874,8 @@
\sa operator^=()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndXorRelease(T valueToXor)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndXorRelease(T valueToXor)
\since 5.3
Atomic fetch-and-xor.
@@ -851,7 +891,8 @@
\sa operator^=()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndXorOrdered(T valueToXor)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndXorOrdered(T valueToXor)
\since 5.3
Atomic fetch-and-xor.
@@ -867,7 +908,8 @@
\sa operator^=()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::operator^=(T value)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::operator^=(T value)
\since 5.3
Atomic xor-and-fetch.
@@ -881,7 +923,8 @@
\sa fetchAndXorOrdered()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAndRelaxed(T valueToAnd)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndAndRelaxed(T valueToAnd)
\since 5.3
Atomic fetch-and-and.
@@ -896,7 +939,8 @@
\sa operator&=()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAndAcquire(T valueToAnd)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndAndAcquire(T valueToAnd)
\since 5.3
Atomic fetch-and-and.
@@ -912,7 +956,8 @@
\sa operator&=()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAndRelease(T valueToAnd)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndAndRelease(T valueToAnd)
\since 5.3
Atomic fetch-and-and.
@@ -928,7 +973,8 @@
\sa operator&=()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::fetchAndAndOrdered(T valueToAnd)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::fetchAndAndOrdered(T valueToAnd)
\since 5.3
Atomic fetch-and-and.
@@ -944,7 +990,8 @@
\sa operator&=()
*/
-/*! \fn template <typename T> T QAtomicInteger<T>::operator&=(T value)
+/*!
+ \fn template <typename T> T QAtomicInteger<T>::operator&=(T value)
\since 5.3
Atomic add-and-fetch.
@@ -1287,17 +1334,20 @@
\sa QAtomicInteger
*/
-/*! \fn template <typename T> QAtomicPointer<T>::QAtomicPointer(T *value)
+/*!
+ \fn template <typename T> QAtomicPointer<T>::QAtomicPointer(T *value)
Constructs a QAtomicPointer with the given \a value.
*/
-/*! \fn template <typename T> QAtomicPointer<T>::QAtomicPointer(const QAtomicPointer<T> &other)
+/*!
+ \fn template <typename T> QAtomicPointer<T>::QAtomicPointer(const QAtomicPointer<T> &other)
Constructs a copy of \a other.
*/
-/*! \fn template <typename T> QAtomicPointer &QAtomicPointer<T>::operator=(const QAtomicPointer &other)
+/*!
+ \fn template <typename T> QAtomicPointer &QAtomicPointer<T>::operator=(const QAtomicPointer &other)
Assigns \a other to this QAtomicPointer and returns a reference to
this QAtomicPointer.
@@ -1369,18 +1419,21 @@
\sa storeRelaxed(), loadRelaxed()
*/
-/*! \fn template <typename T> bool QAtomicPointer<T>::isTestAndSetNative()
+/*!
+ \fn template <typename T> bool QAtomicPointer<T>::isTestAndSetNative()
Returns \c true if test-and-set is implemented using atomic processor
instructions, false otherwise.
*/
-/*! \fn template <typename T> bool QAtomicPointer<T>::isTestAndSetWaitFree()
+/*!
+ \fn template <typename T> bool QAtomicPointer<T>::isTestAndSetWaitFree()
Returns \c true if atomic test-and-set is wait-free, false otherwise.
*/
-/*! \fn template <typename T> bool QAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
+/*!
+ \fn template <typename T> bool QAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
Atomic test-and-set.
@@ -1394,7 +1447,8 @@
processor to freely reorder memory accesses.
*/
-/*! \fn template <typename T> bool QAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue)
+/*!
+ \fn template <typename T> bool QAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue)
Atomic test-and-set.
@@ -1409,7 +1463,8 @@
be re-ordered before the atomic operation.
*/
-/*! \fn template <typename T> bool QAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue)
+/*!
+ \fn template <typename T> bool QAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue)
Atomic test-and-set.
@@ -1424,7 +1479,8 @@
re-ordered after the atomic operation.
*/
-/*! \fn template <typename T> bool QAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
+/*!
+ \fn template <typename T> bool QAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
Atomic test-and-set.
@@ -1439,19 +1495,22 @@
may not be re-ordered.
*/
-/*! \fn template <typename T> bool QAtomicPointer<T>::isFetchAndStoreNative()
+/*!
+ \fn template <typename T> bool QAtomicPointer<T>::isFetchAndStoreNative()
Returns \c true if fetch-and-store is implemented using atomic
processor instructions, false otherwise.
*/
-/*! \fn template <typename T> bool QAtomicPointer<T>::isFetchAndStoreWaitFree()
+/*!
+ \fn template <typename T> bool QAtomicPointer<T>::isFetchAndStoreWaitFree()
Returns \c true if atomic fetch-and-store is wait-free, false
otherwise.
*/
-/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
+/*!
+ \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
Atomic fetch-and-store.
@@ -1463,7 +1522,8 @@
processor to freely reorder memory accesses.
*/
-/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
+/*!
+ \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
Atomic fetch-and-store.
@@ -1476,7 +1536,8 @@
be re-ordered before the atomic operation.
*/
-/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreRelease(T *newValue)
+/*!
+ \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreRelease(T *newValue)
Atomic fetch-and-store.
@@ -1489,7 +1550,8 @@
re-ordered after the atomic operation.
*/
-/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
+/*!
+ \fn template <typename T> T *QAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
Atomic fetch-and-store.
@@ -1502,19 +1564,22 @@
may not be re-ordered.
*/
-/*! \fn template <typename T> bool QAtomicPointer<T>::isFetchAndAddNative()
+/*!
+ \fn template <typename T> bool QAtomicPointer<T>::isFetchAndAddNative()
Returns \c true if fetch-and-add is implemented using atomic
processor instructions, false otherwise.
*/
-/*! \fn template <typename T> bool QAtomicPointer<T>::isFetchAndAddWaitFree()
+/*!
+ \fn template <typename T> bool QAtomicPointer<T>::isFetchAndAddWaitFree()
Returns \c true if atomic fetch-and-add is wait-free, false
otherwise.
*/
-/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd)
+/*!
+ \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd)
Atomic fetch-and-add.
@@ -1526,7 +1591,8 @@
processor to freely reorder memory accesses.
*/
-/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueToAdd)
+/*!
+ \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueToAdd)
Atomic fetch-and-add.
@@ -1539,7 +1605,8 @@
be re-ordered before the atomic operation.
*/
-/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueToAdd)
+/*!
+ \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueToAdd)
Atomic fetch-and-add.
@@ -1552,7 +1619,8 @@
re-ordered after the atomic operation.
*/
-/*! \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd)
+/*!
+ \fn template <typename T> T *QAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd)
Atomic fetch-and-add.
diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h
index a3b9be0729..aa57ddc610 100644
--- a/src/corelib/thread/qatomic.h
+++ b/src/corelib/thread/qatomic.h
@@ -50,6 +50,10 @@ QT_BEGIN_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wextra")
+#ifdef Q_CLANG_QDOC
+# undef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS
+#endif
+
// High-level atomic integer operations
template <typename T>
class QAtomicInteger : public QBasicAtomicInteger<T>
@@ -194,7 +198,9 @@ public:
#ifdef Q_QDOC
T *load() const;
T *loadAcquire() const;
+ T *loadRelaxed() const;
void store(T *newValue);
+ void storeRelaxed(T *newValue);
void storeRelease(T *newValue);
static Q_DECL_CONSTEXPR bool isTestAndSetNative();
diff --git a/src/corelib/thread/qfutex_p.h b/src/corelib/thread/qfutex_p.h
index 7bec4554b7..f287b752d7 100644
--- a/src/corelib/thread/qfutex_p.h
+++ b/src/corelib/thread/qfutex_p.h
@@ -81,7 +81,7 @@ QT_END_NAMESPACE
// if not defined in linux/futex.h
# define FUTEX_PRIVATE_FLAG 128 // added in v2.6.22
-# if QT_HAS_FEATURE(thread_sanitizer) || defined(__SANITIZE_THREAD__)
+# if __has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)
# include <sanitizer/tsan_interface.h>
inline void _q_tsan_acquire(void *addr, void *addr2)
{
@@ -98,7 +98,7 @@ inline void _q_tsan_release(void *addr, void *addr2)
# else
inline void _q_tsan_acquire(void *, void *) {}
inline void _q_tsan_release(void *, void *) {}
-# endif // QT_HAS_FEATURE(thread_sanitizer) || defined(__SANITIZE_THREAD__)
+# endif // __has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)
QT_BEGIN_NAMESPACE
namespace QtLinuxFutex {
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h
index c693ff65d8..93c4bf23e8 100644
--- a/src/corelib/thread/qmutex.h
+++ b/src/corelib/thread/qmutex.h
@@ -44,7 +44,7 @@
#include <QtCore/qatomic.h>
#include <new>
-#if QT_HAS_INCLUDE(<chrono>)
+#if __has_include(<chrono>)
# include <chrono>
# include <limits>
#endif
@@ -147,7 +147,7 @@ public:
// Lockable concept
bool try_lock() QT_MUTEX_LOCK_NOEXCEPT { return tryLock(); }
-#if QT_HAS_INCLUDE(<chrono>) || defined(Q_CLANG_QDOC)
+#if __has_include(<chrono>) || defined(Q_CLANG_QDOC)
// TimedLockable concept
template <class Rep, class Period>
bool try_lock_for(std::chrono::duration<Rep, Period> duration)
@@ -175,7 +175,7 @@ private:
friend class QRecursiveMutex;
friend class ::tst_QMutex;
-#if QT_HAS_INCLUDE(<chrono>)
+#if __has_include(<chrono>)
template<class Rep, class Period>
static int convertToMilliseconds(std::chrono::duration<Rep, Period> duration)
{
@@ -213,7 +213,7 @@ public:
using QMutex::tryLock;
using QMutex::unlock;
using QMutex::try_lock;
-#if QT_HAS_INCLUDE(<chrono>)
+#if __has_include(<chrono>)
using QMutex::try_lock_for;
using QMutex::try_lock_until;
#endif
@@ -295,7 +295,7 @@ public:
inline void unlock() noexcept {}
inline bool isRecursive() const noexcept { return true; }
-#if QT_HAS_INCLUDE(<chrono>)
+#if __has_include(<chrono>)
template <class Rep, class Period>
inline bool try_lock_for(std::chrono::duration<Rep, Period> duration) noexcept
{
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp
index 878a2c1e46..a8d643d483 100644
--- a/src/corelib/time/qdatetime.cpp
+++ b/src/corelib/time/qdatetime.cpp
@@ -127,7 +127,7 @@ static const char qt_shortMonthNames[][4] = {
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
-static int qt_monthNumberFromShortName(QStringRef shortName)
+static int qt_monthNumberFromShortName(QStringView shortName)
{
for (unsigned int i = 0; i < sizeof(qt_shortMonthNames) / sizeof(qt_shortMonthNames[0]); ++i) {
if (shortName == QLatin1String(qt_shortMonthNames[i], 3))
@@ -136,9 +136,9 @@ static int qt_monthNumberFromShortName(QStringRef shortName)
return -1;
}
static int qt_monthNumberFromShortName(const QString &shortName)
-{ return qt_monthNumberFromShortName(QStringRef(&shortName)); }
+{ return qt_monthNumberFromShortName(QStringView(shortName)); }
-static int fromShortMonthName(const QStringRef &monthName, int year)
+static int fromShortMonthName(QStringView monthName, int year)
{
// Assume that English monthnames are the default
int month = qt_monthNumberFromShortName(monthName);
@@ -164,8 +164,8 @@ static ParsedRfcDateTime rfcDateImpl(const QString &s)
{
ParsedRfcDateTime result;
- // Matches "Wdy, dd Mon yyyy HH:mm:ss ±hhmm" (Wdy, being optional)
- QRegExp rex(QStringLiteral("^(?:[A-Z][a-z]+,)?[ \\t]*(\\d{1,2})[ \\t]+([A-Z][a-z]+)[ \\t]+(\\d\\d\\d\\d)(?:[ \\t]+(\\d\\d):(\\d\\d)(?::(\\d\\d))?)?[ \\t]*(?:([+-])(\\d\\d)(\\d\\d))?"));
+ // Matches "[ddd,] dd MMM yyyy[ hh:mm[:ss]] [±hhmm]" - correct RFC 822, 2822, 5322 format
+ QRegExp rex(QStringLiteral("^[ \\t]*(?:[A-Z][a-z]+,)?[ \\t]*(\\d{1,2})[ \\t]+([A-Z][a-z]+)[ \\t]+(\\d\\d\\d\\d)(?:[ \\t]+(\\d\\d):(\\d\\d)(?::(\\d\\d))?)?[ \\t]*(?:([+-])(\\d\\d)(\\d\\d))?"));
if (s.indexOf(rex) == 0) {
const QStringList cap = rex.capturedTexts();
result.date = QDate(cap[3].toInt(), qt_monthNumberFromShortName(cap[2]), cap[1].toInt());
@@ -176,8 +176,8 @@ static ParsedRfcDateTime rfcDateImpl(const QString &s)
const int minOffset = cap[9].toInt();
result.utcOffset = ((hourOffset * 60 + minOffset) * (positiveOffset ? 60 : -60));
} else {
- // Matches "Wdy Mon dd HH:mm:ss yyyy"
- QRegExp rex(QStringLiteral("^[A-Z][a-z]+[ \\t]+([A-Z][a-z]+)[ \\t]+(\\d\\d)(?:[ \\t]+(\\d\\d):(\\d\\d):(\\d\\d))?[ \\t]+(\\d\\d\\d\\d)[ \\t]*(?:([+-])(\\d\\d)(\\d\\d))?"));
+ // Matches "ddd MMM dd[ hh:mm:ss] yyyy [±hhmm]" - permissive RFC 850, 1036 (read only)
+ QRegExp rex(QStringLiteral("^[ \\t]*[A-Z][a-z]+[ \\t]+([A-Z][a-z]+)[ \\t]+(\\d\\d)(?:[ \\t]+(\\d\\d):(\\d\\d):(\\d\\d))?[ \\t]+(\\d\\d\\d\\d)[ \\t]*(?:([+-])(\\d\\d)(\\d\\d))?"));
if (s.indexOf(rex) == 0) {
const QStringList cap = rex.capturedTexts();
result.date = QDate(cap[6].toInt(), qt_monthNumberFromShortName(cap[1]), cap[2].toInt());
@@ -207,7 +207,7 @@ static QString toOffsetString(Qt::DateFormat format, int offset)
#if QT_CONFIG(datestring)
// Parse offset in [+-]HH[[:]mm] format
-static int fromOffsetString(const QStringRef &offsetString, bool *valid) noexcept
+static int fromOffsetString(QStringView offsetString, bool *valid) noexcept
{
*valid = false;
@@ -228,22 +228,23 @@ static int fromOffsetString(const QStringRef &offsetString, bool *valid) noexcep
return 0;
// Split the hour and minute parts
- const QStringRef time = offsetString.mid(1);
- int hhLen = time.indexOf(QLatin1Char(':'));
- int mmIndex;
+ const QStringView time = offsetString.mid(1);
+ qsizetype hhLen = time.indexOf(QLatin1Char(':'));
+ qsizetype mmIndex;
if (hhLen == -1)
mmIndex = hhLen = 2; // [+-]HHmm or [+-]HH format
else
mmIndex = hhLen + 1;
- const QStringRef hhRef = time.left(hhLen);
+ const QLocale C = QLocale::c();
+ const QStringView hhRef = time.left(qMin(hhLen, time.size()));
bool ok = false;
- const int hour = hhRef.toInt(&ok);
+ const int hour = C.toInt(hhRef, &ok);
if (!ok)
return 0;
- const QStringRef mmRef = time.mid(mmIndex);
- const int minute = mmRef.isEmpty() ? 0 : mmRef.toInt(&ok);
+ const QStringView mmRef = time.mid(qMin(mmIndex, time.size()));
+ const int minute = mmRef.isEmpty() ? 0 : C.toInt(mmRef, &ok);
if (!ok || minute < 0 || minute > 59)
return 0;
@@ -1625,6 +1626,29 @@ qint64 QDate::daysTo(const QDate &d) const
*/
#if QT_CONFIG(datestring)
+namespace {
+
+struct ParsedInt { int value = 0; bool ok = false; };
+
+/*
+ /internal
+
+ Read an int that must be the whole text. QStringRef::toInt() will ignore
+ spaces happily; but ISO date format should not.
+*/
+ParsedInt readInt(QStringView text)
+{
+ ParsedInt result;
+ for (const auto &ch : text) {
+ if (ch.isSpace())
+ return result;
+ }
+ result.value = QLocale::c().toInt(text, &result.ok);
+ return result;
+}
+
+}
+
/*!
Returns the QDate represented by the \a string, using the
\a format given, or an invalid date if the string cannot be
@@ -1676,17 +1700,18 @@ QDate QDate::fromString(const QString &string, Qt::DateFormat format)
return QDate(year, month, day);
}
#endif // textdate
- case Qt::ISODate: {
- // Semi-strict parsing, must be long enough and have non-numeric separators
- if (string.size() < 10 || string.at(4).isDigit() || string.at(7).isDigit()
- || (string.size() > 10 && string.at(10).isDigit())) {
- return QDate();
- }
- const int year = string.midRef(0, 4).toInt();
- if (year <= 0 || year > 9999)
- return QDate();
- return QDate(year, string.midRef(5, 2).toInt(), string.midRef(8, 2).toInt());
+ case Qt::ISODate:
+ // Semi-strict parsing, must be long enough and have punctuators as separators
+ if (string.size() >= 10 && string.at(4).isPunct() && string.at(7).isPunct()
+ && (string.size() == 10 || !string.at(10).isDigit())) {
+ QStringView view(string);
+ const ParsedInt year = readInt(view.mid(0, 4));
+ const ParsedInt month = readInt(view.mid(5, 2));
+ const ParsedInt day = readInt(view.mid(8, 2));
+ if (year.ok && year.value > 0 && year.value <= 9999 && month.ok && day.ok)
+ return QDate(year.value, month.value, day.value);
}
+ break;
}
return QDate();
}
@@ -2324,22 +2349,21 @@ int QTime::msecsTo(const QTime &t) const
#if QT_CONFIG(datestring)
-static QTime fromIsoTimeString(const QStringRef &string, Qt::DateFormat format, bool *isMidnight24)
+static QTime fromIsoTimeString(QStringView string, Qt::DateFormat format, bool *isMidnight24)
{
if (isMidnight24)
*isMidnight24 = false;
const int size = string.size();
- if (size < 5)
+ if (size < 5 || string.at(2) != QLatin1Char(':'))
return QTime();
- bool ok = false;
- int hour = string.mid(0, 2).toInt(&ok);
- if (!ok)
- return QTime();
- const int minute = string.mid(3, 2).toInt(&ok);
- if (!ok)
+ ParsedInt hour = readInt(string.mid(0, 2));
+ ParsedInt minute = readInt(string.mid(3, 2));
+ if (!hour.ok || !minute.ok)
return QTime();
+ // FIXME: ISO 8601 allows [,.]\d+ after hour, just as it does after minute
+
int second = 0;
int msec = 0;
@@ -2358,40 +2382,57 @@ static QTime fromIsoTimeString(const QStringRef &string, Qt::DateFormat format,
// seconds is 4. E.g. 12:34,99999 will expand to 12:34:59.9994. The milliseconds
// will then be rounded up AND clamped to 999.
- const QStringRef minuteFractionStr = string.mid(6, 5);
- const long minuteFractionInt = minuteFractionStr.toLong(&ok);
- if (!ok)
+ const QStringView minuteFractionStr = string.mid(6, qMin(qsizetype(5), string.size() - 6));
+ const ParsedInt parsed = readInt(minuteFractionStr);
+ if (!parsed.ok)
return QTime();
- const float minuteFraction = double(minuteFractionInt) / (std::pow(double(10), minuteFractionStr.count()));
+ const float secondWithMs
+ = double(parsed.value) * 60 / (std::pow(double(10), minuteFractionStr.size()));
- const float secondWithMs = minuteFraction * 60;
- const float secondNoMs = std::floor(secondWithMs);
- const float secondFraction = secondWithMs - secondNoMs;
- second = secondNoMs;
+ second = std::floor(secondWithMs);
+ const float secondFraction = secondWithMs - second;
msec = qMin(qRound(secondFraction * 1000.0), 999);
- } else {
+ } else if (string.at(5) == QLatin1Char(':')) {
// HH:mm:ss or HH:mm:ss.zzz
- second = string.mid(6, 2).toInt(&ok);
- if (!ok)
+ const ParsedInt parsed = readInt(string.mid(6, qMin(qsizetype(2), string.size() - 6)));
+ if (!parsed.ok)
return QTime();
- if (size > 8 && (string.at(8) == QLatin1Char(',') || string.at(8) == QLatin1Char('.'))) {
- const QStringRef msecStr(string.mid(9, 4));
- int msecInt = msecStr.isEmpty() ? 0 : msecStr.toInt(&ok);
+ second = parsed.value;
+ if (size <= 8) {
+ // No fractional part to read
+ } else if (string.at(8) == QLatin1Char(',') || string.at(8) == QLatin1Char('.')) {
+ QStringView msecStr(string.mid(9, qMin(qsizetype(4), string.size() - 9)));
+ bool ok = true;
+ // Can't use readInt() here, as we *do* allow trailing space - but not leading:
+ if (!msecStr.isEmpty() && !msecStr.at(0).isDigit())
+ return QTime();
+ msecStr = msecStr.trimmed();
+ int msecInt = msecStr.isEmpty() ? 0 : QLocale::c().toInt(msecStr, &ok);
if (!ok)
return QTime();
- const double secondFraction(msecInt / (std::pow(double(10), msecStr.count())));
+ const double secondFraction(msecInt / (std::pow(double(10), msecStr.size())));
msec = qMin(qRound(secondFraction * 1000.0), 999);
+ } else {
+#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) // behavior change
+ // Stray cruft after date-time: tolerate trailing space, but nothing else.
+ for (const auto &ch : string.mid(8)) {
+ if (!ch.isSpace())
+ return QTime();
+ }
+#endif
}
+ } else {
+ return QTime();
}
const bool isISODate = format == Qt::ISODate || format == Qt::ISODateWithMs;
- if (isISODate && hour == 24 && minute == 0 && second == 0 && msec == 0) {
+ if (isISODate && hour.value == 24 && minute.value == 0 && second == 0 && msec == 0) {
if (isMidnight24)
*isMidnight24 = true;
- hour = 0;
+ hour.value = 0;
}
- return QTime(hour, minute, second, msec);
+ return QTime(hour.value, minute.value, second, msec);
}
/*!
@@ -2428,7 +2469,7 @@ QTime QTime::fromString(const QString &string, Qt::DateFormat format)
case Qt::ISODateWithMs:
case Qt::TextDate:
default:
- return fromIsoTimeString(QStringRef(&string), format, nullptr);
+ return fromIsoTimeString(QStringView(string), format, nullptr);
}
}
@@ -3410,6 +3451,7 @@ inline qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QT
DaylightStatus hint,
QDate *zoneDate, QTime *zoneTime)
{
+ Q_ASSERT(zone.isValid());
// Get the effective data from QTimeZone
QTimeZonePrivate::Data data = zone.d->dataForLocalTime(zoneMSecs, int(hint));
// Docs state any time before 1970-01-01 will *not* have any DST applied
@@ -3799,8 +3841,9 @@ QTimeZone QDateTime::timeZone() const
case Qt::OffsetFromUTC:
return QTimeZone(d->m_offsetFromUtc);
case Qt::TimeZone:
- Q_ASSERT(d->m_timeZone.isValid());
- return d->m_timeZone;
+ if (d->m_timeZone.isValid())
+ return d->m_timeZone;
+ break;
case Qt::LocalTime:
return QTimeZone::systemTimeZone();
}
@@ -3884,6 +3927,7 @@ QString QDateTime::timeZoneAbbreviation() const
#if !QT_CONFIG(timezone)
break;
#else
+ Q_ASSERT(d->m_timeZone.isValid());
return d->m_timeZone.d->abbreviation(toMSecsSinceEpoch());
#endif // timezone
case Qt::LocalTime: {
@@ -3920,6 +3964,7 @@ bool QDateTime::isDaylightTime() const
#if !QT_CONFIG(timezone)
break;
#else
+ Q_ASSERT(d->m_timeZone.isValid());
return d->m_timeZone.d->isDaylightTime(toMSecsSinceEpoch());
#endif // timezone
case Qt::LocalTime: {
@@ -4044,6 +4089,10 @@ void QDateTime::setTimeZone(const QTimeZone &toZone)
*/
qint64 QDateTime::toMSecsSinceEpoch() const
{
+ // Note: QDateTimeParser relies on this producing a useful result, even when
+ // !isValid(), at least when the invalidity is a time in a fall-back (that
+ // we'll have adjusted to lie outside it, but marked invalid because it's
+ // not what was asked for). Other things may be doing similar.
switch (getSpec(d)) {
case Qt::UTC:
return getMSecs(d);
@@ -4058,12 +4107,13 @@ qint64 QDateTime::toMSecsSinceEpoch() const
}
case Qt::TimeZone:
-#if !QT_CONFIG(timezone)
- return 0;
-#else
- return QDateTimePrivate::zoneMSecsToEpochMSecs(d->m_msecs, d->m_timeZone,
- extractDaylightStatus(getStatus(d)));
+#if QT_CONFIG(timezone)
+ if (d->m_timeZone.isValid()) {
+ return QDateTimePrivate::zoneMSecsToEpochMSecs(d->m_msecs, d->m_timeZone,
+ extractDaylightStatus(getStatus(d)));
+ }
#endif
+ return 0;
}
Q_UNREACHABLE();
return 0;
@@ -4158,9 +4208,11 @@ void QDateTime::setMSecsSinceEpoch(qint64 msecs)
case Qt::TimeZone:
Q_ASSERT(!d.isShort());
#if QT_CONFIG(timezone)
+ d.detach();
+ if (!d->m_timeZone.isValid())
+ break;
// Docs state any LocalTime before 1970-01-01 will *not* have any DST applied
// but all affected times afterwards will have DST applied.
- d.detach();
if (msecs >= 0) {
status = mergeDaylightStatus(status,
d->m_timeZone.d->isDaylightTime(msecs)
@@ -4433,7 +4485,7 @@ static inline void massageAdjustedDateTime(const QDateTimeData &d, QDate *date,
QDateTimePrivate::DaylightStatus status = QDateTimePrivate::UnknownDaylightTime;
localMSecsToEpochMSecs(timeToMSecs(*date, *time), &status, date, time);
#if QT_CONFIG(timezone)
- } else if (spec == Qt::TimeZone) {
+ } else if (spec == Qt::TimeZone && d->m_timeZone.isValid()) {
QDateTimePrivate::zoneMSecsToEpochMSecs(timeToMSecs(*date, *time),
d->m_timeZone,
QDateTimePrivate::UnknownDaylightTime,
@@ -5094,7 +5146,8 @@ QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone
{
QDateTime dt;
dt.setTimeZone(timeZone);
- dt.setMSecsSinceEpoch(msecs);
+ if (timeZone.isValid())
+ dt.setMSecsSinceEpoch(msecs);
return dt;
}
@@ -5197,16 +5250,17 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format)
if (!date.isValid())
return QDateTime();
if (size == 10)
- return QDateTime(date);
+ return date.startOfDay();
Qt::TimeSpec spec = Qt::LocalTime;
- QStringRef isoString(&string);
- isoString = isoString.mid(10); // trim "yyyy-MM-dd"
+ QStringView isoString = QStringView(string).mid(10); // trim "yyyy-MM-dd"
- // Must be left with T and at least one digit for the hour:
+ // Must be left with T (or space) and at least one digit for the hour:
if (isoString.size() < 2
- || !(isoString.startsWith(QLatin1Char('T'))
- // FIXME: QSql relies on QVariant::toDateTime() accepting a space here:
+ || !(isoString.startsWith(QLatin1Char('T'), Qt::CaseInsensitive)
+ // RFC 3339 (section 5.6) allows a space here. (It actually
+ // allows any separator one considers more readable, merely
+ // giving space as an example - but let's not go wild !)
|| isoString.startsWith(QLatin1Char(' ')))) {
return QDateTime();
}
@@ -5214,7 +5268,7 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format)
int offset = 0;
// Check end of string for Time Zone definition, either Z for UTC or [+-]HH:mm for Offset
- if (isoString.endsWith(QLatin1Char('Z'))) {
+ if (isoString.endsWith(QLatin1Char('Z'), Qt::CaseInsensitive)) {
spec = Qt::UTC;
isoString.chop(1); // trim 'Z'
} else {
@@ -5345,7 +5399,7 @@ QDateTime QDateTime::fromString(const QString &string, Qt::DateFormat format)
if (parts.count() == 5)
return QDateTime(date, time, Qt::LocalTime);
- QStringRef tz = parts.at(5);
+ QStringView tz = parts.at(5);
if (!tz.startsWith(QLatin1String("GMT"), Qt::CaseInsensitive))
return QDateTime();
tz = tz.mid(3);
diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp
index 2c566e3584..61214b0c7e 100644
--- a/src/corelib/time/qdatetimeparser.cpp
+++ b/src/corelib/time/qdatetimeparser.cpp
@@ -369,13 +369,6 @@ static QString unquote(const QStringRef &str)
}
return ret;
}
-/*!
- \internal
-
- Parses the format \a newFormat. If successful, returns \c true and
- sets up the format. Else keeps the old format and returns \c false.
-
-*/
static inline int countRepeat(const QString &str, int index, int maxCount)
{
@@ -394,7 +387,12 @@ static inline void appendSeparator(QStringList *list, const QString &string, int
list->append(lastQuote >= from ? unquote(separator) : separator.toString());
}
+/*!
+ \internal
+ Parses the format \a newFormat. If successful, returns \c true and sets up
+ the format. Else keeps the old format and returns \c false.
+*/
bool QDateTimeParser::parseFormat(const QString &newFormat)
{
const QLatin1Char quote('\'');
@@ -1365,7 +1363,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
// given date (which might be a spring-forward, skipping an hour).
if (parserType == QVariant::DateTime && !(isSet & HourSectionMask) && !when.isValid()) {
qint64 msecs = when.toMSecsSinceEpoch();
- // Fortunately, that gets a useful answer ...
+ // Fortunately, that gets a useful answer, even though when is invalid ...
const QDateTime replace =
#if QT_CONFIG(timezone)
tspec == Qt::TimeZone
diff --git a/src/corelib/time/qtimezoneprivate.cpp b/src/corelib/time/qtimezoneprivate.cpp
index 00dc8b4ced..cb019fa1a5 100644
--- a/src/corelib/time/qtimezoneprivate.cpp
+++ b/src/corelib/time/qtimezoneprivate.cpp
@@ -380,18 +380,15 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs,
On the first pass, the case we consider is what hint told us to expect
(except when hint was -1 and didn't actually tell us what to expect),
so it's likely right. We only get a second pass if the first failed,
- by which time the second case, that we're trying, is likely right. If
- an overwhelming majority of calls have hint == -1, the Q_LIKELY here
- shall be wrong half the time; otherwise, its errors shall be rarer
- than that.
+ by which time the second case, that we're trying, is likely right.
*/
if (nextFirst ? i == 0 : i) {
Q_ASSERT(nextStart != invalidMSecs());
- if (Q_LIKELY(nextStart <= nextTran.atMSecsSinceEpoch))
+ if (nextStart <= nextTran.atMSecsSinceEpoch)
return nextTran;
} else {
// If next is invalid, nextFirst is false, to route us here first:
- if (nextStart == invalidMSecs() || Q_LIKELY(nextStart > tran.atMSecsSinceEpoch))
+ if (nextStart == invalidMSecs() || nextStart > tran.atMSecsSinceEpoch)
return tran;
}
}
@@ -420,7 +417,7 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs,
int early = offsetFromUtc(recent);
int late = offsetFromUtc(imminent);
- if (Q_LIKELY(early == late)) { // > 99% of the time
+ if (early == late) { // > 99% of the time
utcEpochMSecs = forLocalMSecs - early * 1000;
} else {
// Close to a DST transition: early > late is near a fall-back,
@@ -432,7 +429,7 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs,
const qint64 forStd = forLocalMSecs - offsetInStd * 1000;
// Best guess at the answer:
const qint64 hinted = hint > 0 ? forDst : forStd;
- if (Q_LIKELY(offsetFromUtc(hinted) == (hint > 0 ? offsetInDst : offsetInStd))) {
+ if (offsetFromUtc(hinted) == (hint > 0 ? offsetInDst : offsetInStd)) {
utcEpochMSecs = hinted;
} else if (hint <= 0 && offsetFromUtc(forDst) == offsetInDst) {
utcEpochMSecs = forDst;
diff --git a/src/corelib/time/qtimezoneprivate_android.cpp b/src/corelib/time/qtimezoneprivate_android.cpp
index be4f374fdd..5cb8155dcc 100644
--- a/src/corelib/time/qtimezoneprivate_android.cpp
+++ b/src/corelib/time/qtimezoneprivate_android.cpp
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2019 The Qt Company Ltd.
** Copyright (C) 2014 Drew Parsons <dparsons@emerall.com>
** Contact: https://www.qt.io/licensing/
**
@@ -53,9 +54,10 @@ QT_BEGIN_NAMESPACE
QAndroidTimeZonePrivate::QAndroidTimeZonePrivate()
: QTimeZonePrivate()
{
- // start with system time zone
- androidTimeZone = QJNIObjectPrivate::callStaticObjectMethod("java.util.TimeZone", "getDefault", "()Ljava/util/TimeZone;");
- init("UTC");
+ // Keep in sync with systemTimeZoneId():
+ androidTimeZone = QJNIObjectPrivate::callStaticObjectMethod(
+ "java.util.TimeZone", "getDefault", "()Ljava/util/TimeZone;");
+ m_id = androidTimeZone.callObjectMethod("getID", "()Ljava/lang/String;").toString().toUtf8();
}
// Create a named time zone
@@ -76,32 +78,33 @@ QAndroidTimeZonePrivate::~QAndroidTimeZonePrivate()
{
}
-
void QAndroidTimeZonePrivate::init(const QByteArray &ianaId)
{
- QJNIObjectPrivate jo_ianaId = QJNIObjectPrivate::fromString( QString::fromUtf8(ianaId) );
- androidTimeZone = QJNIObjectPrivate::callStaticObjectMethod( "java.util.TimeZone", "getTimeZone", "(Ljava/lang/String;)Ljava/util/TimeZone;", static_cast<jstring>(jo_ianaId.object()) );
+ const QString iana = QString::fromUtf8(ianaId);
+ androidTimeZone = QJNIObjectPrivate::callStaticObjectMethod(
+ "java.util.TimeZone", "getTimeZone", "(Ljava/lang/String;)Ljava/util/TimeZone;",
+ static_cast<jstring>(QJNIObjectPrivate::fromString(iana).object()));
+
+ // The ID or display name of the zone we've got, if it looks like what we asked for:
+ const auto match = [iana](const QJNIObjectPrivate &jname) -> QByteArray {
+ const QString name = jname.toString();
+ if (iana.compare(name, Qt::CaseInsensitive))
+ return name.toUtf8();
+
+ return QByteArray();
+ };
// Painfully, JNI gives us back a default zone object if it doesn't
// recognize the name; so check for whether ianaId is a recognized name of
// the zone object we got and ignore the zone if not.
// Try checking ianaId against getID(), getDisplayName():
- QJNIObjectPrivate jname = androidTimeZone.callObjectMethod("getID", "()Ljava/lang/String;");
- bool found = (jname.toString().toUtf8() == ianaId);
- for (int style = 1; !found && style-- > 0;) {
- for (int dst = 1; !found && dst-- > 0;) {
- jname = androidTimeZone.callObjectMethod("getDisplayName", "(ZI;)Ljava/lang/String;",
- bool(dst), style);
- found = (jname.toString().toUtf8() == ianaId);
+ m_id = match(androidTimeZone.callObjectMethod("getID", "()Ljava/lang/String;"));
+ for (int style = 1; m_id.isEmpty() && style-- > 0;) {
+ for (int dst = 1; m_id.isEmpty() && dst-- > 0;) {
+ m_id = match(androidTimeZone.callObjectMethod(
+ "getDisplayName", "(ZI;)Ljava/lang/String;", bool(dst), style));
}
}
-
- if (!found)
- m_id.clear();
- else if (ianaId.isEmpty())
- m_id = systemTimeZoneId();
- else
- m_id = ianaId;
}
QAndroidTimeZonePrivate *QAndroidTimeZonePrivate::clone() const
@@ -225,11 +228,10 @@ QTimeZonePrivate::Data QAndroidTimeZonePrivate::previousTransition(qint64 before
QByteArray QAndroidTimeZonePrivate::systemTimeZoneId() const
{
- QJNIObjectPrivate androidSystemTimeZone = QJNIObjectPrivate::callStaticObjectMethod("java.util.TimeZone", "getDefault", "()Ljava/util/TimeZone;");
- QJNIObjectPrivate systemTZIdAndroid = androidSystemTimeZone.callObjectMethod<jstring>("getID");
- QByteArray systemTZid = systemTZIdAndroid.toString().toUtf8();
-
- return systemTZid;
+ // Keep in sync with default constructor:
+ QJNIObjectPrivate androidSystemTimeZone = QJNIObjectPrivate::callStaticObjectMethod(
+ "java.util.TimeZone", "getDefault", "()Ljava/util/TimeZone;");
+ return androidSystemTimeZone.callObjectMethod<jstring>("getID").toString().toUtf8();
}
QList<QByteArray> QAndroidTimeZonePrivate::availableTimeZoneIds() const
diff --git a/src/corelib/time/qtimezoneprivate_mac.mm b/src/corelib/time/qtimezoneprivate_mac.mm
index d3c4fbe5da..1fb48a31d3 100644
--- a/src/corelib/time/qtimezoneprivate_mac.mm
+++ b/src/corelib/time/qtimezoneprivate_mac.mm
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2019 The Qt Company Ltd.
** Copyright (C) 2013 John Layt <jlayt@kde.org>
** Contact: https://www.qt.io/licensing/
**
@@ -59,22 +60,24 @@ QT_BEGIN_NAMESPACE
// Create the system default time zone
QMacTimeZonePrivate::QMacTimeZonePrivate()
- : m_nstz(0)
{
- init(systemTimeZoneId());
+ // Reset the cached system tz then instantiate it:
+ [NSTimeZone resetSystemTimeZone];
+ m_nstz = [NSTimeZone.systemTimeZone retain];
+ Q_ASSERT(m_nstz);
+ m_id = QString::fromNSString(m_nstz.name).toUtf8();
}
// Create a named time zone
QMacTimeZonePrivate::QMacTimeZonePrivate(const QByteArray &ianaId)
- : m_nstz(0)
+ : m_nstz(nil)
{
init(ianaId);
}
QMacTimeZonePrivate::QMacTimeZonePrivate(const QMacTimeZonePrivate &other)
- : QTimeZonePrivate(other), m_nstz(0)
+ : QTimeZonePrivate(other), m_nstz([other.m_nstz copy])
{
- m_nstz = [other.m_nstz copy];
}
QMacTimeZonePrivate::~QMacTimeZonePrivate()
@@ -94,11 +97,21 @@ void QMacTimeZonePrivate::init(const QByteArray &ianaId)
if (m_nstz)
m_id = ianaId;
}
+ if (!m_nstz) {
+ // macOS has been seen returning a systemTimeZone which reports its name
+ // as Asia/Kolkata, which doesn't appear in knownTimeZoneNames (which
+ // calls the zone Asia/Calcutta). So explicitly check for the name
+ // systemTimeZoneId() returns, and use systemTimeZone if we get it:
+ m_nstz = [NSTimeZone.systemTimeZone retain];
+ Q_ASSERT(m_nstz);
+ if (QString::fromNSString(m_nstz.name).toUtf8() == ianaId)
+ m_id = ianaId;
+ }
}
QString QMacTimeZonePrivate::comment() const
{
- return QString::fromNSString([m_nstz description]);
+ return QString::fromNSString(m_nstz.description);
}
QString QMacTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
@@ -201,7 +214,7 @@ bool QMacTimeZonePrivate::hasTransitions() const
// TODO Not sure what is returned in event of no transitions, assume will be before requested date
NSDate *epoch = [NSDate dateWithTimeIntervalSince1970:0];
const NSDate *date = [m_nstz nextDaylightSavingTimeTransitionAfterDate:epoch];
- const bool result = ([date timeIntervalSince1970] > [epoch timeIntervalSince1970]);
+ const bool result = (date.timeIntervalSince1970 > epoch.timeIntervalSince1970);
return result;
}
@@ -211,7 +224,7 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::nextTransition(qint64 afterMSecsSinc
const NSTimeInterval seconds = afterMSecsSinceEpoch / 1000.0;
NSDate *nextDate = [NSDate dateWithTimeIntervalSince1970:seconds];
nextDate = [m_nstz nextDaylightSavingTimeTransitionAfterDate:nextDate];
- const NSTimeInterval nextSecs = [nextDate timeIntervalSince1970];
+ const NSTimeInterval nextSecs = nextDate.timeIntervalSince1970;
if (nextDate == nil || nextSecs <= seconds) {
[nextDate release];
return invalidData();
@@ -237,7 +250,7 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::previousTransition(qint64 beforeMSec
NSDate *nextDate = [NSDate dateWithTimeIntervalSince1970:nextSecs];
nextDate = [m_nstz nextDaylightSavingTimeTransitionAfterDate:nextDate];
if (nextDate != nil
- && (tranSecs = [nextDate timeIntervalSince1970]) < endSecs) {
+ && (tranSecs = nextDate.timeIntervalSince1970) < endSecs) {
// There's a transition within the last year before endSecs:
nextSecs = tranSecs;
} else {
@@ -246,7 +259,7 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::previousTransition(qint64 beforeMSec
nextDate = [m_nstz nextDaylightSavingTimeTransitionAfterDate:nextDate];
if (nextDate != nil) {
NSTimeInterval lateSecs = nextSecs;
- nextSecs = [nextDate timeIntervalSince1970];
+ nextSecs = nextDate.timeIntervalSince1970;
Q_ASSERT(nextSecs <= endSecs - year || nextSecs == tranSecs);
/*
We're looking at the first ever transition for our zone, at
@@ -272,8 +285,7 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::previousTransition(qint64 beforeMSec
NSTimeInterval middle = nextSecs / 2 + lateSecs / 2;
NSDate *split = [NSDate dateWithTimeIntervalSince1970:middle];
split = [m_nstz nextDaylightSavingTimeTransitionAfterDate:split];
- if (split != nil
- && (tranSecs = [split timeIntervalSince1970]) < endSecs) {
+ if (split != nil && (tranSecs = split.timeIntervalSince1970) < endSecs) {
nextDate = split;
nextSecs = tranSecs;
} else {
@@ -290,7 +302,7 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::previousTransition(qint64 beforeMSec
while (nextDate != nil && nextSecs < endSecs) {
prevSecs = nextSecs;
nextDate = [m_nstz nextDaylightSavingTimeTransitionAfterDate:nextDate];
- nextSecs = [nextDate timeIntervalSince1970];
+ nextSecs = nextDate.timeIntervalSince1970;
if (nextSecs <= prevSecs) // presumably no later data available
break;
}
@@ -305,18 +317,19 @@ QByteArray QMacTimeZonePrivate::systemTimeZoneId() const
{
// Reset the cached system tz then return the name
[NSTimeZone resetSystemTimeZone];
- return QString::fromNSString([[NSTimeZone systemTimeZone] name]).toUtf8();
+ Q_ASSERT(NSTimeZone.systemTimeZone);
+ return QString::fromNSString(NSTimeZone.systemTimeZone.name).toUtf8();
}
QList<QByteArray> QMacTimeZonePrivate::availableTimeZoneIds() const
{
- NSEnumerator *enumerator = [[NSTimeZone knownTimeZoneNames] objectEnumerator];
- QByteArray tzid = QString::fromNSString([enumerator nextObject]).toUtf8();
+ NSEnumerator *enumerator = NSTimeZone.knownTimeZoneNames.objectEnumerator;
+ QByteArray tzid = QString::fromNSString(enumerator.nextObject).toUtf8();
QList<QByteArray> list;
while (!tzid.isEmpty()) {
list << tzid;
- tzid = QString::fromNSString([enumerator nextObject]).toUtf8();
+ tzid = QString::fromNSString(enumerator.nextObject).toUtf8();
}
std::sort(list.begin(), list.end());
diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h
index b01ce0db58..aa79e0d4a9 100644
--- a/src/corelib/tools/qalgorithms.h
+++ b/src/corelib/tools/qalgorithms.h
@@ -535,7 +535,7 @@ QT_DEPRECATED_X("Use std::binary_search") Q_OUTOFLINE_TEMPLATE RandomAccessItera
# define QT_HAS_BUILTIN_CTZS
Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) noexcept
{
-# if QT_HAS_BUILTIN(__builtin_ctzs)
+# if __has_builtin(__builtin_ctzs)
return __builtin_ctzs(v);
# else
return __builtin_ctz(v);
@@ -544,7 +544,7 @@ Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) noexcept
#define QT_HAS_BUILTIN_CLZS
Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) noexcept
{
-# if QT_HAS_BUILTIN(__builtin_clzs)
+# if __has_builtin(__builtin_clzs)
return __builtin_clzs(v);
# else
return __builtin_clz(v) - 16U;
diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h
index fe952f95da..f0a91c4ff8 100644
--- a/src/corelib/tools/qpoint.h
+++ b/src/corelib/tools/qpoint.h
@@ -352,6 +352,7 @@ Q_DECL_RELAXED_CONSTEXPR inline QPointF &QPointF::operator*=(qreal c)
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wfloat-equal")
QT_WARNING_DISABLE_GCC("-Wfloat-equal")
+QT_WARNING_DISABLE_INTEL(1572)
Q_DECL_CONSTEXPR inline bool operator==(const QPointF &p1, const QPointF &p2)
{
diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h
index 7aa2312f38..c6bfc1a50d 100644
--- a/src/corelib/tools/qrect.h
+++ b/src/corelib/tools/qrect.h
@@ -665,6 +665,7 @@ Q_DECL_CONSTEXPR inline QRectF::QRectF(const QRect &r) noexcept
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wfloat-equal")
QT_WARNING_DISABLE_GCC("-Wfloat-equal")
+QT_WARNING_DISABLE_INTEL(1572)
Q_DECL_CONSTEXPR inline bool QRectF::isNull() const noexcept
{ return w == 0. && h == 0.; }
diff --git a/src/corelib/tools/qscopeguard.h b/src/corelib/tools/qscopeguard.h
index 45c3f93da4..40d2747b1d 100644
--- a/src/corelib/tools/qscopeguard.h
+++ b/src/corelib/tools/qscopeguard.h
@@ -51,7 +51,7 @@ template <typename F> QScopeGuard<F> qScopeGuard(F f);
template <typename F>
class
-#if QT_HAS_CPP_ATTRIBUTE(nodiscard)
+#if __has_cpp_attribute(nodiscard)
// Q_REQUIRED_RESULT can be defined as __warn_unused_result__ or as [[nodiscard]]
// but the 1st one has some limitations for example can be placed only on functions.
Q_REQUIRED_RESULT
@@ -91,7 +91,7 @@ private:
template <typename F>
-#if QT_HAS_CPP_ATTRIBUTE(nodiscard)
+#if __has_cpp_attribute(nodiscard)
Q_REQUIRED_RESULT
#endif
QScopeGuard<F> qScopeGuard(F f)
diff --git a/src/gui/doc/src/qtgui.qdoc b/src/gui/doc/src/qtgui.qdoc
index c4e7d32de1..392b6040cb 100644
--- a/src/gui/doc/src/qtgui.qdoc
+++ b/src/gui/doc/src/qtgui.qdoc
@@ -62,7 +62,7 @@
\include module-use.qdocinc using qt module
\quotefile overview/using-qt-gui.cmake
- See also the \l[QtDoc]{Building with CMake} overview.
+ See also the \l[QtDoc]{Build with CMake} overview.
\section2 Building with qmake
diff --git a/src/gui/kernel/qplatformcursor.cpp b/src/gui/kernel/qplatformcursor.cpp
index 49eff2ad23..aabf28a727 100644
--- a/src/gui/kernel/qplatformcursor.cpp
+++ b/src/gui/kernel/qplatformcursor.cpp
@@ -131,6 +131,14 @@ void QPlatformCursor::setPos(const QPoint &pos)
QWindowSystemInterface::handleMouseEvent(0, pos, pos, Qt::NoButton, Qt::NoButton, QEvent::MouseMove);
}
+/*!
+ Returns the size of the cursor, in native pixels.
+*/
+QSize QPlatformCursor::size() const
+{
+ return QSize(16, 16);
+}
+
// End of display and pointer event handling code
// Beginning of built-in cursor graphics
// from src/gui/embedded/QGraphicsSystemCursorImage_qws.cpp
diff --git a/src/gui/kernel/qplatformcursor.h b/src/gui/kernel/qplatformcursor.h
index f36a73c861..f3871d8780 100644
--- a/src/gui/kernel/qplatformcursor.h
+++ b/src/gui/kernel/qplatformcursor.h
@@ -96,6 +96,7 @@ public:
#endif // QT_NO_CURSOR
virtual QPoint pos() const;
virtual void setPos(const QPoint &pos);
+ virtual QSize size() const;
static Capabilities capabilities() { return m_capabilities; }
static void setCapabilities(Capabilities c) { m_capabilities = c; }
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index b71a0c54aa..f701755500 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -1344,7 +1344,7 @@ Qt::WindowStates QWindow::windowStates() const
This is a hint to the window manager that this window is a dialog or pop-up
on behalf of the transient parent.
- In order to cause the window to be centered above its transient parent by
+ In order to cause the window to be centered above its transient \a parent by
default, depending on the window manager, it may also be necessary to call
setFlags() with a suitable \l Qt::WindowType (such as \c Qt::Dialog).
diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h
index 69c3510659..1439bfac59 100644
--- a/src/gui/math3d/qmatrix4x4.h
+++ b/src/gui/math3d/qmatrix4x4.h
@@ -215,6 +215,7 @@ private:
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wfloat-equal")
QT_WARNING_DISABLE_GCC("-Wfloat-equal")
+QT_WARNING_DISABLE_INTEL(1572)
Q_DECLARE_TYPEINFO(QMatrix4x4, Q_MOVABLE_TYPE);
inline QMatrix4x4::QMatrix4x4
diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h
index cd0d746e55..f01fab679e 100644
--- a/src/gui/math3d/qquaternion.h
+++ b/src/gui/math3d/qquaternion.h
@@ -171,6 +171,7 @@ inline QQuaternion::QQuaternion(float aScalar, float xpos, float ypos, float zpo
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wfloat-equal")
QT_WARNING_DISABLE_GCC("-Wfloat-equal")
+QT_WARNING_DISABLE_INTEL(1572)
inline bool QQuaternion::isNull() const
{
return wp == 0.0f && xp == 0.0f && yp == 0.0f && zp == 0.0f;
diff --git a/src/gui/math3d/qvector2d.h b/src/gui/math3d/qvector2d.h
index 88d8bc199e..cbce94c199 100644
--- a/src/gui/math3d/qvector2d.h
+++ b/src/gui/math3d/qvector2d.h
@@ -207,6 +207,7 @@ inline QVector2D &QVector2D::operator/=(const QVector2D &vector)
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wfloat-equal")
QT_WARNING_DISABLE_GCC("-Wfloat-equal")
+QT_WARNING_DISABLE_INTEL(1572)
Q_DECL_CONSTEXPR inline bool operator==(const QVector2D &v1, const QVector2D &v2)
{
return v1.v[0] == v2.v[0] && v1.v[1] == v2.v[1];
diff --git a/src/gui/math3d/qvector3d.h b/src/gui/math3d/qvector3d.h
index 1b49f3e7b9..d7ffb0bcc4 100644
--- a/src/gui/math3d/qvector3d.h
+++ b/src/gui/math3d/qvector3d.h
@@ -232,6 +232,7 @@ inline QVector3D &QVector3D::operator/=(const QVector3D &vector)
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wfloat-equal")
QT_WARNING_DISABLE_GCC("-Wfloat-equal")
+QT_WARNING_DISABLE_INTEL(1572)
Q_DECL_CONSTEXPR inline bool operator==(const QVector3D &v1, const QVector3D &v2)
{
return v1.v[0] == v2.v[0] && v1.v[1] == v2.v[1] && v1.v[2] == v2.v[2];
diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h
index 08cb423484..afcc71fa88 100644
--- a/src/gui/math3d/qvector4d.h
+++ b/src/gui/math3d/qvector4d.h
@@ -232,6 +232,7 @@ inline QVector4D &QVector4D::operator/=(const QVector4D &vector)
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wfloat-equal")
QT_WARNING_DISABLE_GCC("-Wfloat-equal")
+QT_WARNING_DISABLE_INTEL(1572)
Q_DECL_CONSTEXPR inline bool operator==(const QVector4D &v1, const QVector4D &v2)
{
return v1.v[0] == v2.v[0] && v1.v[1] == v2.v[1] && v1.v[2] == v2.v[2] && v1.v[3] == v2.v[3];
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp
index 5d30891565..bb0dbdc9bd 100644
--- a/src/gui/opengl/qopenglframebufferobject.cpp
+++ b/src/gui/opengl/qopenglframebufferobject.cpp
@@ -658,13 +658,11 @@ void QOpenGLFramebufferObjectPrivate::initDepthStencilAttachments(QOpenGLContext
funcs.glBindRenderbuffer(GL_RENDERBUFFER, depth_buffer);
Q_ASSERT(funcs.glIsRenderbuffer(depth_buffer));
- GLenum storageFormat = GL_DEPTH_STENCIL;
-
if (samples != 0 ) {
funcs.glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples,
- storageFormat, dsSize.width(), dsSize.height());
+ GL_DEPTH24_STENCIL8, dsSize.width(), dsSize.height());
} else {
- funcs.glRenderbufferStorage(GL_RENDERBUFFER, storageFormat,
+ funcs.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL,
dsSize.width(), dsSize.height());
}
diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp
index 8ec814296a..bc3a4f7c1d 100644
--- a/src/gui/opengl/qopenglfunctions.cpp
+++ b/src/gui/opengl/qopenglfunctions.cpp
@@ -388,8 +388,12 @@ static int qt_gl_resolve_extensions()
| QOpenGLExtensions::MapBufferRange
| QOpenGLExtensions::FramebufferBlit
| QOpenGLExtensions::FramebufferMultisample
- | QOpenGLExtensions::Sized8Formats
- | QOpenGLExtensions::TextureSwizzle;
+ | QOpenGLExtensions::Sized8Formats;
+#ifndef Q_OS_WASM
+ // WebGL 2.0 specification explicitly does not support texture swizzles
+ // https://www.khronos.org/registry/webgl/specs/latest/2.0/#5.19
+ extensions |= QOpenGLExtensions::TextureSwizzle;
+#endif
} else {
// Recognize features by extension name.
if (extensionMatcher.match("GL_OES_packed_depth_stencil"))
diff --git a/src/gui/painting/qcolorspace.cpp b/src/gui/painting/qcolorspace.cpp
index 937bb505c9..9631fdb416 100644
--- a/src/gui/painting/qcolorspace.cpp
+++ b/src/gui/painting/qcolorspace.cpp
@@ -784,10 +784,12 @@ QDebug operator<<(QDebug dbg, const QColorSpace &colorSpace)
QDebugStateSaver saver(dbg);
dbg.nospace();
dbg << "QColorSpace(";
- if (colorSpace.d_ptr->namedColorSpace)
- dbg << colorSpace.d_ptr->namedColorSpace << ", ";
- dbg << colorSpace.primaries() << ", " << colorSpace.transferFunction();
- dbg << ", gamma=" << colorSpace.gamma();
+ if (colorSpace.d_ptr) {
+ if (colorSpace.d_ptr->namedColorSpace)
+ dbg << colorSpace.d_ptr->namedColorSpace << ", ";
+ dbg << colorSpace.primaries() << ", " << colorSpace.transferFunction();
+ dbg << ", gamma=" << colorSpace.gamma();
+ }
dbg << ')';
return dbg;
}
diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h
index b220770144..b2a634dd2a 100644
--- a/src/gui/painting/qtransform.h
+++ b/src/gui/painting/qtransform.h
@@ -303,6 +303,7 @@ inline qreal QTransform::dy() const
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wfloat-equal")
QT_WARNING_DISABLE_GCC("-Wfloat-equal")
+QT_WARNING_DISABLE_INTEL(1572)
inline QTransform &QTransform::operator*=(qreal num)
{
diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h
index 907924c788..588347d111 100644
--- a/src/gui/rhi/qrhi_p.h
+++ b/src/gui/rhi/qrhi_p.h
@@ -246,10 +246,6 @@ public:
m_bindings.clear();
std::copy(first, last, std::back_inserter(m_bindings));
}
- void setBindings(const QVector<QRhiVertexInputBinding> &bindings) // compat., to be removed
- {
- setBindings(bindings.cbegin(), bindings.cend());
- }
const QRhiVertexInputBinding *cbeginBindings() const { return m_bindings.cbegin(); }
const QRhiVertexInputBinding *cendBindings() const { return m_bindings.cend(); }
const QRhiVertexInputBinding *bindingAt(int index) const { return &m_bindings.at(index); }
@@ -261,10 +257,6 @@ public:
m_attributes.clear();
std::copy(first, last, std::back_inserter(m_attributes));
}
- void setAttributes(const QVector<QRhiVertexInputAttribute> &attributes) // compat., to be removed
- {
- setAttributes(attributes.cbegin(), attributes.cend());
- }
const QRhiVertexInputAttribute *cbeginAttributes() const { return m_attributes.cbegin(); }
const QRhiVertexInputAttribute *cendAttributes() const { return m_attributes.cend(); }
@@ -551,9 +543,6 @@ public:
QRhiTextureUploadDescription() = default;
QRhiTextureUploadDescription(const QRhiTextureUploadEntry &entry);
QRhiTextureUploadDescription(std::initializer_list<QRhiTextureUploadEntry> list);
- QRhiTextureUploadDescription(const QVector<QRhiTextureUploadEntry> &entries) // compat., to be removed
- : m_entries(entries.cbegin(), entries.cend())
- { }
void setEntries(std::initializer_list<QRhiTextureUploadEntry> list) { m_entries = list; }
template<typename InputIterator>
@@ -979,11 +968,6 @@ public:
std::copy(first, last, std::back_inserter(m_bindings));
}
- void setBindings(const QVector<QRhiShaderResourceBinding> &bindings) // compat., to be removed
- {
- setBindings(bindings.cbegin(), bindings.cend());
- }
-
const QRhiShaderResourceBinding *cbeginBindings() const { return m_bindings.cbegin(); }
const QRhiShaderResourceBinding *cendBindings() const { return m_bindings.cend(); }
@@ -1172,10 +1156,6 @@ public:
m_shaderStages.clear();
std::copy(first, last, std::back_inserter(m_shaderStages));
}
- void setShaderStages(const QVector<QRhiShaderStage> &stages) // compat., to be removed
- {
- setShaderStages(stages.cbegin(), stages.cend());
- }
const QRhiShaderStage *cbeginShaderStages() const { return m_shaderStages.cbegin(); }
const QRhiShaderStage *cendShaderStages() const { return m_shaderStages.cend(); }
diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp
index 717f3e6d6c..5e576e9c6a 100644
--- a/src/gui/rhi/qrhid3d11.cpp
+++ b/src/gui/rhi/qrhid3d11.cpp
@@ -3922,7 +3922,7 @@ bool QD3D11SwapChain::buildOrResize()
desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
desc.BufferCount = BUFFER_COUNT;
desc.Scaling = DXGI_SCALING_STRETCH;
- desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
+ desc.SwapEffect = DXGI_SWAP_EFFECT(4); // DXGI_SWAP_EFFECT_FLIP_DISCARD
// Do not bother with AlphaMode, if won't work unless we go through
// DirectComposition. Instead, we just take the other (DISCARD)
// path for now when alpha is requested.
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp
index abee843a74..b394354787 100644
--- a/src/gui/rhi/qrhigles2.cpp
+++ b/src/gui/rhi/qrhigles2.cpp
@@ -3147,8 +3147,7 @@ bool QGles2RenderBuffer::build()
switch (m_type) {
case QRhiRenderBuffer::DepthStencil:
if (rhiD->caps.msaaRenderBuffer && samples > 1) {
- const GLenum storage = rhiD->caps.needsDepthStencilCombinedAttach ? GL_DEPTH_STENCIL : GL_DEPTH24_STENCIL8;
- rhiD->f->glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, storage,
+ rhiD->f->glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GL_DEPTH24_STENCIL8,
size.width(), size.height());
stencilRenderbuffer = 0;
} else if (rhiD->caps.packedDepthStencil || rhiD->caps.needsDepthStencilCombinedAttach) {
diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm
index 131b2da802..3ecc56d147 100644
--- a/src/gui/rhi/qrhimetal.mm
+++ b/src/gui/rhi/qrhimetal.mm
@@ -3149,7 +3149,10 @@ id<MTLLibrary> QRhiMetalData::createMetalLib(const QShader &shader, QShader::Var
[opts release];
// src is autoreleased
- if (err) {
+ // if lib is null and err is non-null, we had errors (fail)
+ // if lib is non-null and err is non-null, we had warnings (success)
+ // if lib is non-null and err is null, there were no errors or warnings (success)
+ if (!lib) {
const QString msg = QString::fromNSString(err.localizedDescription);
*error = msg;
return nil;
diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp
index 103fea627a..a200a6e271 100644
--- a/src/gui/rhi/qrhivulkan.cpp
+++ b/src/gui/rhi/qrhivulkan.cpp
@@ -48,7 +48,7 @@
#include <qmath.h>
#include <QVulkanFunctions>
-#include <QVulkanWindow>
+#include <QtGui/qwindow.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index ce7c7610c1..627b3ec8c0 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -443,6 +443,7 @@ void ValueExtractor::lengthValues(const Declaration &decl, int *m)
{
if (decl.d->parsed.isValid()) {
QList<QVariant> v = decl.d->parsed.toList();
+ Q_ASSERT(v.size() == 4);
for (int i = 0; i < 4; i++)
m[i] = lengthValueFromData(qvariant_cast<LengthData>(v.at(i)), f);
return;
diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h
index ab85e76cf3..d91b095a76 100644
--- a/src/gui/text/qcssparser_p.h
+++ b/src/gui/text/qcssparser_p.h
@@ -856,13 +856,13 @@ struct Q_GUI_EXPORT ValueExtractor
int extractStyleFeatures();
bool extractImage(QIcon *icon, Qt::Alignment *a, QSize *size);
- int lengthValue(const Declaration &decl);
+ void lengthValues(const Declaration &decl, int *m);
private:
void extractFont();
void borderValue(const Declaration &decl, int *width, QCss::BorderStyle *style, QBrush *color);
LengthData lengthValue(const Value& v);
- void lengthValues(const Declaration &decl, int *m);
+ int lengthValue(const Declaration &decl);
QSize sizeValue(const Declaration &decl);
void sizeValues(const Declaration &decl, QSize *radii);
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp
index c88497840f..056a854789 100644
--- a/src/gui/text/qtextcursor.cpp
+++ b/src/gui/text/qtextcursor.cpp
@@ -2261,6 +2261,7 @@ void QTextCursor::insertFragment(const QTextDocumentFragment &fragment)
d->remove();
fragment.d->insert(*this);
d->priv->endEditBlock();
+ d->setX();
if (fragment.d && fragment.d->doc)
d->priv->mergeCachedResources(fragment.d->doc->docHandle());
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index e94f635651..4b35509ace 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -347,7 +347,19 @@ QTextDocument *QTextDocument::clone(QObject *parent) const
{
Q_D(const QTextDocument);
QTextDocument *doc = new QTextDocument(parent);
- QTextCursor(doc).insertFragment(QTextDocumentFragment(this));
+ if (isEmpty()) {
+ const QTextCursor thisCursor(const_cast<QTextDocument *>(this));
+
+ const auto blockFormat = thisCursor.blockFormat();
+ if (blockFormat.isValid() && !blockFormat.isEmpty())
+ QTextCursor(doc).setBlockFormat(blockFormat);
+
+ const auto blockCharFormat = thisCursor.blockCharFormat();
+ if (blockCharFormat.isValid() && !blockCharFormat.isEmpty())
+ QTextCursor(doc).setBlockCharFormat(blockCharFormat);
+ } else {
+ QTextCursor(doc).insertFragment(QTextDocumentFragment(this));
+ }
doc->rootFrame()->setFrameFormat(rootFrame()->frameFormat());
QTextDocumentPrivate *priv = doc->d_func();
priv->title = d->title;
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index 5d37982a8b..b867f42480 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -1209,8 +1209,11 @@ void QTextHtmlParserNode::applyCssDeclarations(const QVector<QCss::Declaration>
if (decl.styleValue() != QCss::BorderStyle_Unknown && decl.styleValue() != QCss::BorderStyle_Native)
borderStyle = static_cast<QTextFrameFormat::BorderStyle>(decl.styleValue() - 1);
break;
- case QCss::BorderWidth:
- tableBorder = extractor.lengthValue(decl);
+ case QCss::BorderWidth: {
+ int borders[4];
+ extractor.lengthValues(decl, borders);
+ tableBorder = borders[0];
+ }
break;
case QCss::BorderCollapse:
borderCollapse = decl.borderCollapseValue();
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index e302aa1761..4e9e947263 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -1512,7 +1512,7 @@ bool QSslSocket::addDefaultCaCertificates(const QString &path, QSsl::EncodingFor
SSL socket's CA certificate database is initialized to the default
CA certificate database.
- \sa QSslConfiguration::caCertificates(), addCaCertificates()
+ \sa addCaCertificates()
*/
void QSslSocket::addDefaultCaCertificate(const QSslCertificate &certificate)
{
diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp
index d4bad1b1a5..51510f1c60 100644
--- a/src/network/ssl/qsslsocket_openssl.cpp
+++ b/src/network/ssl/qsslsocket_openssl.cpp
@@ -93,6 +93,7 @@
#endif
#include <algorithm>
+#include <memory>
#include <string.h>
@@ -1763,6 +1764,7 @@ QList<QSslError> QSslSocketBackendPrivate::verify(const QList<QSslCertificate> &
errors << QSslError(QSslError::UnspecifiedError);
return errors;
}
+ const std::unique_ptr<X509_STORE, decltype(&q_X509_STORE_free)> storeGuard(certStore, q_X509_STORE_free);
if (s_loadRootCertsOnDemand) {
setDefaultCaCertificates(defaultCaCertificates() + systemCaCertificates());
@@ -1811,7 +1813,6 @@ QList<QSslError> QSslSocketBackendPrivate::verify(const QList<QSslCertificate> &
intermediates = (STACK_OF(X509) *) q_OPENSSL_sk_new_null();
if (!intermediates) {
- q_X509_STORE_free(certStore);
errors << QSslError(QSslError::UnspecifiedError);
return errors;
}
@@ -1829,14 +1830,12 @@ QList<QSslError> QSslSocketBackendPrivate::verify(const QList<QSslCertificate> &
X509_STORE_CTX *storeContext = q_X509_STORE_CTX_new();
if (!storeContext) {
- q_X509_STORE_free(certStore);
errors << QSslError(QSslError::UnspecifiedError);
return errors;
}
+ std::unique_ptr<X509_STORE_CTX, decltype(&q_X509_STORE_CTX_free)> ctxGuard(storeContext, q_X509_STORE_CTX_free);
if (!q_X509_STORE_CTX_init(storeContext, certStore, reinterpret_cast<X509 *>(certificateChain[0].handle()), intermediates)) {
- q_X509_STORE_CTX_free(storeContext);
- q_X509_STORE_free(certStore);
errors << QSslError(QSslError::UnspecifiedError);
return errors;
}
@@ -1845,8 +1844,7 @@ QList<QSslError> QSslSocketBackendPrivate::verify(const QList<QSslCertificate> &
// We ignore the result of this function since we process errors via the
// callback.
(void) q_X509_verify_cert(storeContext);
-
- q_X509_STORE_CTX_free(storeContext);
+ ctxGuard.reset();
q_OPENSSL_sk_free((OPENSSL_STACK *)intermediates);
// Now process the errors
@@ -1868,8 +1866,6 @@ QList<QSslError> QSslSocketBackendPrivate::verify(const QList<QSslCertificate> &
for (const auto &error : qAsConst(lastErrors))
errors << _q_OpenSSL_to_QSslError(error.code, certificateChain.value(error.depth));
- q_X509_STORE_free(certStore);
-
return errors;
}
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 2c5a40a992..2d7b0280d8 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -4962,7 +4962,7 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con
// The only option in Qt 5 is the shader-based OpenGL 2 paint engine.
// Setting fixed pipeline transformations is futile. Instead, pass the
// extra values directly and let the engine figure the matrices out.
- static_cast<QGL2PaintEngineEx *>(p->paintEngine())->setTranslateZ(-win_z);
+ static_cast<QGL2PaintEngineEx *>(p->paintEngine())->setTranslateZ(-2 * win_z);
qt_gl_draw_text(p, qRound(win_x), qRound(win_y), str, font);
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index daa3dc94ea..894919a1c8 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -374,17 +374,6 @@ QFontEngine *QCoreTextFontDatabaseEngineFactory<QCoreTextFontEngine>::fontEngine
QCFType<CTFontDescriptorRef> descriptor = QCFType<CTFontDescriptorRef>::constructFromGet(
static_cast<CTFontDescriptorRef>(usrPtr));
- // CoreText will sometimes invalidate information in font descriptors that refer
- // to system fonts in certain function calls or application states. While the descriptor
- // looks the same from the outside, some internal plumbing is different, causing the results
- // of creating CTFonts from those descriptors unreliable. The work-around for this
- // is to copy the attributes of those descriptors each time we make a new CTFont
- // from them instead of referring to the original, as that may trigger the CoreText bug.
- if (m_systemFontDescriptors.contains(descriptor)) {
- QCFType<CFDictionaryRef> attributes = CTFontDescriptorCopyAttributes(descriptor);
- descriptor = CTFontDescriptorCreateWithAttributes(attributes);
- }
-
// Since we do not pass in the destination DPI to CoreText when making
// the font, we need to pass in a point size which is scaled to include
// the DPI. The default DPI for the screen is 72, thus the scale factor
diff --git a/src/platformsupport/platformsupport.pro b/src/platformsupport/platformsupport.pro
index 6d4f1b93bd..877665ff06 100644
--- a/src/platformsupport/platformsupport.pro
+++ b/src/platformsupport/platformsupport.pro
@@ -11,7 +11,7 @@ SUBDIRS = \
qtConfig(freetype)|darwin|win32: \
SUBDIRS += fontdatabases
-qtConfig(evdev)|qtConfig(tslib)|qtConfig(libinput)|qtConfig(integrityhid) {
+qtConfig(evdev)|qtConfig(tslib)|qtConfig(libinput)|qtConfig(integrityhid)|qtConfig(xkbcommon) {
SUBDIRS += input
input.depends += devicediscovery
}
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
index db4ec251ae..106c226adc 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
@@ -133,7 +133,7 @@ static void populateRoleMap()
roleMap[QAccessible::SpinBox] = NSAccessibilityIncrementorRole;
roleMap[QAccessible::Slider] = NSAccessibilitySliderRole;
roleMap[QAccessible::ProgressBar] = NSAccessibilityProgressIndicatorRole;
- roleMap[QAccessible::ComboBox] = NSAccessibilityPopUpButtonRole;
+ roleMap[QAccessible::ComboBox] = NSAccessibilityComboBoxRole;
roleMap[QAccessible::RadioButton] = NSAccessibilityRadioButtonRole;
roleMap[QAccessible::CheckBox] = NSAccessibilityCheckBoxRole;
roleMap[QAccessible::StaticText] = NSAccessibilityStaticTextRole;
diff --git a/src/plugins/platforms/cocoa/qcocoacursor.h b/src/plugins/platforms/cocoa/qcocoacursor.h
index 58b9ef2151..5b008eff35 100644
--- a/src/plugins/platforms/cocoa/qcocoacursor.h
+++ b/src/plugins/platforms/cocoa/qcocoacursor.h
@@ -56,6 +56,9 @@ public:
void changeCursor(QCursor *cursor, QWindow *window) override;
QPoint pos() const override;
void setPos(const QPoint &position) override;
+
+ QSize size() const override;
+
private:
QHash<Qt::CursorShape, NSCursor *> m_cursors;
NSCursor *convertCursor(QCursor *cursor);
diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm
index 87a57c78c8..e0d623fc4c 100644
--- a/src/plugins/platforms/cocoa/qcocoacursor.mm
+++ b/src/plugins/platforms/cocoa/qcocoacursor.mm
@@ -85,6 +85,31 @@ void QCocoaCursor::setPos(const QPoint &position)
CFRelease(e);
}
+
+QSize QCocoaCursor::size() const
+{
+ NSCursor *cocoaCursor = NSCursor.currentSystemCursor;
+ if (!cocoaCursor)
+ return QPlatformCursor::size();
+ NSImage *cursorImage = cocoaCursor.image;
+ if (!cursorImage)
+ return QPlatformCursor::size();
+
+ QSizeF size = QSizeF::fromCGSize(cursorImage.size);
+ NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
+ NSDictionary *accessSettings = [defaults persistentDomainForName:@"com.apple.universalaccess"];
+ if (accessSettings == nil)
+ return size.toSize();
+
+ float sizeScale = [accessSettings[@"mouseDriverCursorSize"] floatValue];
+ if (sizeScale > 0) {
+ size.rwidth() *= sizeScale;
+ size.rheight() *= sizeScale;
+ }
+
+ return size.toSize();
+}
+
NSCursor *QCocoaCursor::convertCursor(QCursor *cursor)
{
if (!cursor)
diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm
index 09433194a6..95808b8a11 100644
--- a/src/plugins/platforms/cocoa/qcocoadrag.mm
+++ b/src/plugins/platforms/cocoa/qcocoadrag.mm
@@ -134,7 +134,7 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
NSImage *nsimage = qt_mac_create_nsimage(pm);
[nsimage setSize:NSSizeFromCGSize(pmDeviceIndependentSize.toCGSize())];
- QMacPasteboard dragBoard((CFStringRef) NSDragPboard, QMacInternalPasteboardMime::MIME_DND);
+ QMacPasteboard dragBoard(CFStringRef(NSPasteboardNameDrag), QMacInternalPasteboardMime::MIME_DND);
m_drag->mimeData()->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray("dummy"));
dragBoard.setMimeData(m_drag->mimeData(), QMacPasteboard::LazyRequest);
@@ -145,7 +145,7 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
CGFloat flippedY = pmDeviceIndependentSize.height() - hotSpot.y();
event_location.y -= flippedY;
NSSize mouseOffset_unused = NSMakeSize(0.0, 0.0);
- NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
+ NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSPasteboardNameDrag];
[theWindow dragImage:nsimage
at:event_location
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h
index 4210a4ed3f..238067568b 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.h
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h
@@ -86,6 +86,10 @@ private:
QSurfaceFormat m_format;
QVarLengthArray<QMacNotificationObserver, 3> m_updateObservers;
QAtomicInt m_needsUpdate = false;
+
+#ifndef QT_NO_DEBUG_STREAM
+ friend QDebug operator<<(QDebug debug, const QCocoaGLContext *screen);
+#endif
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index b312e033cd..6db4bdb9fd 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -158,6 +158,8 @@ void QCocoaGLContext::initialize()
[m_context setValues:&order forParameter:NSOpenGLCPSurfaceOrder];
updateSurfaceFormat();
+
+ qCDebug(lcQpaOpenGLContext).verbosity(3) << "Created" << this << "based on requested" << context()->format();
}
NSOpenGLPixelFormat *QCocoaGLContext::pixelFormatForSurfaceFormat(const QSurfaceFormat &format)
@@ -355,7 +357,7 @@ QCocoaGLContext::~QCocoaGLContext()
bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface)
{
- qCDebug(lcQpaOpenGLContext) << "Making" << m_context << "current"
+ qCDebug(lcQpaOpenGLContext) << "Making" << this << "current"
<< "in" << QThread::currentThread() << "for" << surface;
Q_ASSERT(surface->surface()->supportsOpenGL());
@@ -555,4 +557,20 @@ QFunctionPointer QCocoaGLContext::getProcAddress(const char *procName)
return (QFunctionPointer)dlsym(RTLD_DEFAULT, procName);
}
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug debug, const QCocoaGLContext *context)
+{
+ QDebugStateSaver saver(debug);
+ debug.nospace();
+ debug << "QCocoaGLContext(" << (const void *)context;
+ if (context) {
+ if (debug.verbosity() > QDebug::DefaultVerbosity)
+ debug << ", " << context->format();
+ debug << ", " << context->nativeContext();
+ }
+ debug << ')';
+ return debug;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index 9a2f19c2f2..b7f15a2bf1 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -197,16 +197,6 @@ QCocoaIntegration::QCocoaIntegration(const QStringList &paramList)
[cocoaApplication setMenu:[qtMenuLoader menu]];
}
- // The presentation options such as whether or not the dock and/or menu bar is
- // hidden (automatically by the system) affects the main screen's available
- // geometry. Since we're initializing the screens synchronously at application
- // startup we need to ensure that the presentation options have been propagated
- // to the screen before we read out its properties. Normally OS X does this in
- // an asynchronous callback, but that's too late for us. We force the propagation
- // by explicitly setting the presentation option to the magic 'default value',
- // which will resolve to an actual value and result in screen invalidation.
- cocoaApplication.presentationOptions = NSApplicationPresentationDefault;
-
QCocoaScreen::initializeScreens();
QMacInternalPasteboardMime::initializeMimeTypes();
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 15329ca708..69d192b4f5 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -567,7 +567,10 @@ void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags)
Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
if ((type & Qt::Popup) != Qt::Popup && (type & Qt::Dialog) != Qt::Dialog) {
NSWindowCollectionBehavior behavior = m_view.window.collectionBehavior;
- if ((flags & Qt::WindowFullscreenButtonHint) || m_view.window.qt_fullScreen) {
+ const bool enableFullScreen = m_view.window.qt_fullScreen
+ || !(flags & Qt::CustomizeWindowHint)
+ || (flags & Qt::WindowFullscreenButtonHint);
+ if (enableFullScreen) {
behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
behavior &= ~NSWindowCollectionBehaviorFullScreenAuxiliary;
} else {
@@ -1692,9 +1695,9 @@ void QCocoaWindow::registerTouch(bool enable)
{
m_registerTouchCount += enable ? 1 : -1;
if (enable && m_registerTouchCount == 1)
- [m_view setAcceptsTouchEvents:YES];
+ m_view.allowedTouchTypes |= NSTouchTypeMaskIndirect;
else if (m_registerTouchCount == 0)
- [m_view setAcceptsTouchEvents:NO];
+ m_view.allowedTouchTypes &= ~NSTouchTypeMaskIndirect;
}
void QCocoaWindow::setContentBorderThickness(int topThickness, int bottomThickness)
diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm
index 396c769be8..1bc9744528 100644
--- a/src/plugins/platforms/ios/qiostextresponder.mm
+++ b/src/plugins/platforms/ios/qiostextresponder.mm
@@ -781,12 +781,16 @@
- (UIView *)textInputView
{
+ auto *focusWindow = QGuiApplication::focusWindow();
+ if (!focusWindow)
+ return nil;
+
// iOS expects rects we return from other UITextInput methods
// to be relative to the view this method returns.
// Since QInputMethod returns rects relative to the top level
// QWindow, that is also the view we need to return.
- Q_ASSERT(qApp->focusWindow()->handle());
- QPlatformWindow *topLevel = qApp->focusWindow()->handle();
+ Q_ASSERT(focusWindow->handle());
+ QPlatformWindow *topLevel = focusWindow->handle();
while (QPlatformWindow *p = topLevel->parent())
topLevel = p;
return reinterpret_cast<UIView *>(topLevel->winId());
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp b/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp
index 1b5f3b4954..491c314488 100644
--- a/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp
+++ b/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp
@@ -60,6 +60,18 @@ static const int c_screenCode = _PULSE_CODE_MINAVAIL + 0;
static const int c_armCode = _PULSE_CODE_MINAVAIL + 1;
static const int c_quitCode = _PULSE_CODE_MINAVAIL + 2;
+#if !defined(screen_register_event)
+int screen_register_event(screen_context_t, struct sigevent *event)
+{
+ return MsgRegisterEvent(event, -1);
+}
+
+int screen_unregister_event(struct sigevent *event)
+{
+ return MsgUnregisterEvent(event);
+}
+#endif
+
QQnxScreenEventThread::QQnxScreenEventThread(screen_context_t context)
: QThread()
, m_screenContext(context)
@@ -75,10 +87,14 @@ QQnxScreenEventThread::QQnxScreenEventThread(screen_context_t context)
qFatal("QQnxScreenEventThread: Can't continue without a channel connection");
}
- struct sigevent screenEvent;
- SIGEV_PULSE_INIT(&screenEvent, m_connectionId, SIGEV_PULSE_PRIO_INHERIT, c_screenCode, 0);
+ SIGEV_PULSE_INIT(&m_screenEvent, m_connectionId, SIGEV_PULSE_PRIO_INHERIT, c_screenCode, 0);
+ if (screen_register_event(m_screenContext, &m_screenEvent) == -1) {
+ ConnectDetach(m_connectionId);
+ ChannelDestroy(m_channelId);
+ qFatal("QQnxScreenEventThread: Can't continue without a registered event");
+ }
- screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT, nullptr, &screenEvent);
+ screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT, nullptr, &m_screenEvent);
}
QQnxScreenEventThread::~QQnxScreenEventThread()
@@ -86,6 +102,8 @@ QQnxScreenEventThread::~QQnxScreenEventThread()
// block until thread terminates
shutdown();
+ screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT, nullptr, nullptr);
+ screen_unregister_event(&m_screenEvent);
ConnectDetach(m_connectionId);
ChannelDestroy(m_channelId);
}
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventthread.h b/src/plugins/platforms/qnx/qqnxscreeneventthread.h
index 3c8d197545..e5b762369c 100644
--- a/src/plugins/platforms/qnx/qqnxscreeneventthread.h
+++ b/src/plugins/platforms/qnx/qqnxscreeneventthread.h
@@ -45,6 +45,7 @@
#include <QtCore/QMutex>
#include <screen/screen.h>
+#include <sys/siginfo.h>
QT_BEGIN_NAMESPACE
@@ -73,6 +74,7 @@ private:
int m_channelId;
int m_connectionId;
+ struct sigevent m_screenEvent;
screen_context_t m_screenContext;
bool m_emitNeededOnNextScreenPulse = true;
int m_screenPulsesSinceLastArmPulse = 0;
diff --git a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp
index 62087f54bd..0532b7e726 100644
--- a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp
+++ b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp
@@ -30,6 +30,7 @@
#include "qwasmopenglcontext.h"
#include "qwasmintegration.h"
#include <EGL/egl.h>
+#include <emscripten/val.h>
QT_BEGIN_NAMESPACE
@@ -50,7 +51,13 @@ QWasmOpenGLContext::QWasmOpenGLContext(const QSurfaceFormat &format)
QWasmOpenGLContext::~QWasmOpenGLContext()
{
if (m_context) {
+ // Destroy GL context. Work around bug in emscripten_webgl_destroy_context
+ // which removes all event handlers on the canvas by temporarily removing
+ // emscripten's JSEvents global object.
+ emscripten::val jsEvents = emscripten::val::global("window")["JSEvents"];
+ emscripten::val::global("window").set("JSEvents", emscripten::val::undefined());
emscripten_webgl_destroy_context(m_context);
+ emscripten::val::global("window").set("JSEvents", jsEvents);
m_context = 0;
}
}
diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp
index 17e8cffb76..59457f1720 100644
--- a/src/plugins/platforms/windows/qwindowscursor.cpp
+++ b/src/plugins/platforms/windows/qwindowscursor.cpp
@@ -50,6 +50,7 @@
#include <QtGui/qscreen.h>
#include <QtGui/private/qguiapplication_p.h> // getPixmapCursor()
#include <QtGui/private/qhighdpiscaling_p.h>
+#include <QtCore/private/qwinregistry_p.h>
#include <QtCore/qdebug.h>
#include <QtCore/qscopedpointer.h>
@@ -686,6 +687,30 @@ void QWindowsCursor::setPos(const QPoint &pos)
SetCursorPos(pos.x() , pos.y());
}
+/*
+ The standard size is 32x32, even though the cursor is actually just
+ 16 pixels large. If a large cursor is set in the accessibility settings,
+ then the cursor increases with 8 pixels for each step.
+*/
+QSize QWindowsCursor::size() const
+{
+ const QPair<DWORD,bool> cursorSizeSetting =
+ QWinRegistryKey(HKEY_CURRENT_USER, LR"(Control Panel\Cursors)")
+ .dwordValue(L"CursorBaseSize");
+ const int baseSize = screenCursorSize(m_screen).width() / 2;
+ if (!cursorSizeSetting.second)
+ return QSize(baseSize / 2, baseSize / 2);
+
+ // The registry values are dpi-independent, so we need to scale the result.
+ int cursorSizeValue = cursorSizeSetting.first * m_screen->logicalDpi().first
+ / m_screen->logicalBaseDpi().first;
+
+ // map from registry value 32-256 to 0-14, and from there to pixels
+ cursorSizeValue = (cursorSizeValue - 2 * baseSize) / baseSize;
+ const int cursorSize = baseSize + cursorSizeValue * (baseSize / 2);
+ return QSize(cursorSize, cursorSize);
+}
+
QPixmap QWindowsCursor::dragDefaultCursor(Qt::DropAction action) const
{
switch (action) {
diff --git a/src/plugins/platforms/windows/qwindowscursor.h b/src/plugins/platforms/windows/qwindowscursor.h
index b896f4c7a9..cf3635bd6b 100644
--- a/src/plugins/platforms/windows/qwindowscursor.h
+++ b/src/plugins/platforms/windows/qwindowscursor.h
@@ -113,6 +113,8 @@ public:
QPoint pos() const override;
void setPos(const QPoint &pos) override;
+ QSize size() const override;
+
static HCURSOR createPixmapCursor(QPixmap pixmap, const QPoint &hotSpot, qreal scaleFactor = 1);
static HCURSOR createPixmapCursor(const PixmapCursor &pc, qreal scaleFactor = 1) { return createPixmapCursor(pc.pixmap, pc.hotSpot, scaleFactor); }
static PixmapCursor customCursor(Qt::CursorShape cursorShape, const QPlatformScreen *screen = nullptr);
diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
index 079c25f9eb..19d632dc10 100644
--- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
@@ -283,8 +283,11 @@ void QWindowsInputContext::showInputPanel()
// We only call ShowCaret() on Windows 10 after 1703 as in earlier versions
// the caret would actually be visible (QTBUG-74492) and the workaround for
// the Surface seems unnecessary there anyway. But leave it hidden for IME.
- if (QOperatingSystemVersion::current() >=
- QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 16299)) {
+ // Only trigger the native OSK if the Qt OSK is not in use.
+ static bool imModuleEmpty = qEnvironmentVariableIsEmpty("QT_IM_MODULE");
+ if (imModuleEmpty
+ && QOperatingSystemVersion::current()
+ >= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 16299)) {
ShowCaret(platformWindow->handle());
} else {
HideCaret(platformWindow->handle());
diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
index f2dba4d06b..ab830e1461 100644
--- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
+++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
@@ -57,11 +57,13 @@
#include "qwindowsmenu.h"
#include "qwindowsscreen.h"
+#include <QtGui/qguiapplication.h>
#include <QtGui/qpixmap.h>
#include <QtCore/qdebug.h>
#include <QtCore/qrect.h>
#include <QtCore/qvector.h>
#include <QtCore/qsettings.h>
+#include <qpa/qwindowsysteminterface.h>
#include <qt_windows.h>
#include <commctrl.h>
@@ -134,9 +136,12 @@ static int indexOfHwnd(HWND hwnd)
extern "C" LRESULT QT_WIN_CALLBACK qWindowsTrayIconWndProc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
+ // QTBUG-79248: Trigger screen update if there are no other windows.
+ if (message == WM_DPICHANGED && QGuiApplication::topLevelWindows().isEmpty())
+ QWindowsContext::instance()->screenManager().handleScreenChanges();
if (message == MYWM_TASKBARCREATED || message == MYWM_NOTIFYICON
|| message == WM_INITMENU || message == WM_INITMENUPOPUP
- || message == WM_COMMAND) {
+ || message == WM_CLOSE || message == WM_COMMAND) {
const int index = indexOfHwnd(hwnd);
if (index >= 0) {
MSG msg;
@@ -439,6 +444,9 @@ bool QWindowsSystemTrayIcon::winEvent(const MSG &message, long *result)
case WM_INITMENUPOPUP:
QWindowsPopupMenu::notifyAboutToShow(reinterpret_cast<HMENU>(message.wParam));
break;
+ case WM_CLOSE:
+ QWindowSystemInterface::handleApplicationTermination<QWindowSystemInterface::SynchronousDelivery>();
+ break;
case WM_COMMAND:
QWindowsPopupMenu::notifyTriggered(LOWORD(message.wParam));
break;
diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
index f589fd6b10..cc293b777c 100644
--- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
+++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
@@ -289,7 +289,8 @@ HRESULT QWindowsUiaMainProvider::GetPatternProvider(PATTERNID idPattern, IUnknow
break;
case UIA_TogglePatternId:
// Checkbox controls.
- if (accessible->role() == QAccessible::CheckBox) {
+ if (accessible->role() == QAccessible::CheckBox
+ || (accessible->role() == QAccessible::MenuItem && accessible->state().checkable)) {
*pRetVal = new QWindowsUiaToggleProvider(id());
}
break;
@@ -390,7 +391,17 @@ HRESULT QWindowsUiaMainProvider::GetPropertyValue(PROPERTYID idProp, VARIANT *pR
setVariantI4(UIA_WindowControlTypeId, pRetVal);
} else {
// Control type converted from role.
- setVariantI4(roleToControlTypeId(accessible->role()), pRetVal);
+ auto controlType = roleToControlTypeId(accessible->role());
+
+ // The native OSK should be disbled if the Qt OSK is in use.
+ static bool imModuleEmpty = qEnvironmentVariableIsEmpty("QT_IM_MODULE");
+
+ // If we want to disable the native OSK auto-showing
+ // we have to report text fields as non-editable.
+ if (controlType == UIA_EditControlTypeId && !imModuleEmpty)
+ controlType = UIA_TextControlTypeId;
+
+ setVariantI4(controlType, pRetVal);
}
break;
case UIA_HelpTextPropertyId:
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index 8da299d491..7c60ca06f9 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -41,6 +41,7 @@
#include "qxcbwindow.h"
#include "qxcbcursor.h"
#include "qxcbimage.h"
+#include "qxcbintegration.h"
#include "qnamespace.h"
#include "qxcbxsettings.h"
@@ -49,6 +50,7 @@
#include <QDebug>
#include <QtAlgorithms>
+#include <qpa/qplatformservices.h>
#include <qpa/qwindowsysteminterface.h>
#include <private/qmath_p.h>
#include <QtGui/private/qhighdpiscaling_p.h>
@@ -356,6 +358,15 @@ static QFontEngine::SubpixelAntialiasingType parseXftRgba(const QByteArray& stri
void QXcbVirtualDesktop::readXResources()
{
+ const QPlatformServices *services = QXcbIntegration::instance()->services();
+ bool useXftConf = false;
+ if (services) {
+ const QList<QByteArray> desktopEnv = services->desktopEnvironment().split(':');
+ useXftConf = desktopEnv.contains("GNOME") || desktopEnv.contains("UNITY") || desktopEnv.contains("XFCE");
+ }
+ if (!useXftConf)
+ return;
+
int offset = 0;
QByteArray resources;
while (true) {
diff --git a/src/plugins/sqldrivers/README b/src/plugins/sqldrivers/README
index 7000fb5613..26418c5e36 100644
--- a/src/plugins/sqldrivers/README
+++ b/src/plugins/sqldrivers/README
@@ -1,5 +1,5 @@
-Please note that the DB2, Oracle and TDS client drivers are not distributed
-with the Qt Open Source Editions.
+Please note that the DB2, MySQL, Oracle and TDS client drivers are not
+distributed with the Qt Open Source Editions.
This is because the client libraries are distributed under a license which
is not compatible with the GPL license.
diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp
index 760685f64b..e0f82eee73 100644
--- a/src/plugins/sqldrivers/psql/qsql_psql.cpp
+++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp
@@ -692,40 +692,24 @@ QVariant QPSQLResult::data(int i)
return dbl;
}
case QVariant::Date:
- if (val[0] == '\0') {
- return QVariant(QDate());
- } else {
#if QT_CONFIG(datestring)
- return QVariant(QDate::fromString(QString::fromLatin1(val), Qt::ISODate));
+ return QVariant(QDate::fromString(QString::fromLatin1(val), Qt::ISODate));
#else
- return QVariant(QString::fromLatin1(val));
+ return QVariant(QString::fromLatin1(val));
#endif
- }
- case QVariant::Time: {
- const QString str = QString::fromLatin1(val);
+ case QVariant::Time:
#if QT_CONFIG(datestring)
- if (str.isEmpty())
- return QVariant(QTime());
- else
- return QVariant(QTime::fromString(str, Qt::ISODate));
+ return QVariant(QTime::fromString(QString::fromLatin1(val), Qt::ISODate));
#else
- return QVariant(str);
+ return QVariant(QString::fromLatin1(val));
#endif
- }
- case QVariant::DateTime: {
- QString dtval = QString::fromLatin1(val);
+ case QVariant::DateTime:
#if QT_CONFIG(datestring)
- if (dtval.length() < 10) {
- return QVariant(QDateTime());
- } else {
- QChar sign = dtval[dtval.size() - 3];
- if (sign == QLatin1Char('-') || sign == QLatin1Char('+')) dtval += QLatin1String(":00");
- return QVariant(QDateTime::fromString(dtval, Qt::ISODate).toLocalTime());
- }
+ return QVariant(QDateTime::fromString(QString::fromLatin1(val),
+ Qt::ISODate).toLocalTime());
#else
- return QVariant(dtval);
+ return QVariant(QString::fromLatin1(val));
#endif
- }
case QVariant::ByteArray: {
size_t len;
unsigned char *data = PQunescapeBytea((const unsigned char*)val, &len);
@@ -838,6 +822,7 @@ QSqlRecord QPSQLResult::record() const
}
int ptype = PQftype(d->result, i);
f.setType(qDecodePSQLType(ptype));
+ f.setValue(QVariant(f.type())); // only set in setType() when it's invalid before
int len = PQfsize(d->result, i);
int precision = PQfmod(d->result, i);
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
index 610329a350..ecdde06bb8 100644
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
@@ -1740,16 +1740,16 @@ QRectF QMacStylePrivate::comboboxEditBounds(const QRectF &outerBounds, const Coc
if (cw.type == ComboBox) {
switch (cw.size) {
case QStyleHelper::SizeLarge:
- ret = ret.adjusted(0, 0, -28, 0).translated(3, 4.5);
+ ret = ret.adjusted(0, 0, -25, 0).translated(2, 4.5);
ret.setHeight(16);
break;
case QStyleHelper::SizeSmall:
- ret = ret.adjusted(0, 0, -24, 0).translated(3, 2);
+ ret = ret.adjusted(0, 0, -22, 0).translated(2, 3);
ret.setHeight(14);
break;
case QStyleHelper::SizeMini:
- ret = ret.adjusted(0, 0, -21, 0).translated(2, 3);
- ret.setHeight(11);
+ ret = ret.adjusted(0, 0, -19, 0).translated(2, 2.5);
+ ret.setHeight(10.5);
break;
default:
break;
diff --git a/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc b/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc
index 9709deeccb..12a39d80b2 100644
--- a/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc
+++ b/src/sql/doc/snippets/code/doc_src_sql-driver.qdoc
@@ -70,7 +70,6 @@ BEGIN
END
//! [1]
-
//! [3]
cd $QTDIR/qtbase/src/plugins/sqldrivers
qmake -- MYSQL_PREFIX=/usr/local
@@ -86,14 +85,15 @@ make install
//! [5]
cd %QTDIR%\qtbase\src\plugins\sqldrivers
-qmake -- MYSQL_INCDIR=C:/MySQL/include "MYSQL_LIBDIR=C:/MYSQL/MySQL Server <version>/lib/opt"
+qmake -- MYSQL_INCDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/include" MYSQL_LIBDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/lib"
nmake sub-mysql
+nmake install
//! [5]
//! [6]
cd $QTDIR/qtbase/src/plugins/sqldrivers
-qmake -- "OCI_INCDIR=$ORACLE_HOME/rdbms/public" OCI_LIBDIR=$ORACLE_HOME/lib "OCI_LIBS=-lclntsh -lwtc9"
+qmake -- OCI_INCDIR="$ORACLE_HOME/rdbms/public" OCI_LIBDIR="$ORACLE_HOME/lib" OCI_LIBS="-lclntsh -lwtc9"
make sub-oci
//! [6]
@@ -142,6 +142,7 @@ make sub-psql
cd %QTDIR%\qtbase\src\plugins\sqldrivers
qmake -- PSQL_INCDIR=C:/psql/include PSQL_LIBDIR=C:/psql/lib/ms
nmake sub-psql
+nmake install
//! [15]
@@ -156,6 +157,7 @@ make sub-tds
cd %QTDIR%\qtbase\src\plugins\sqldrivers
qmake
nmake sub-tds
+nmake install
//! [17]
@@ -168,8 +170,9 @@ make sub-db2
//! [20]
cd %QTDIR%\qtbase\src\plugins\sqldrivers
-qmake -- "DB2_PREFIX=<DB2 home>/sqllib"
+qmake -- DB2_PREFIX="<DB2 home>/sqllib"
nmake sub-db2
+nmake install
//! [20]
@@ -184,6 +187,7 @@ make sub-sqlite
cd %QTDIR%\qtbase\src\plugins\sqldrivers
qmake -- -system-sqlite SQLITE3_PREFIX=C:/SQLITE
nmake sub-sqlite
+nmake install
//! [23]
@@ -205,6 +209,7 @@ make sub-ibase
cd %QTDIR%\qtbase\src\plugins\sqldrivers
qmake -- IBASE_INCDIR=C:/interbase/include
nmake sub-ibase
+nmake install
//! [29]
@@ -212,17 +217,18 @@ nmake sub-ibase
cd %QTDIR%\qtbase\src\plugins\sqldrivers
qmake -- IBASE_INCDIR=C:/interbase/include IBASE_LIBS=-lfbclient
nmake sub-ibase
+nmake install
//! [30]
//! [32]
-configure OCI_INCDIR=/usr/include/oracle/10.1.0.3/client OCI_LIBDIR=/usr/lib/oracle/10.1.0.3/client/lib -R /usr/lib/oracle/10.1.0.3/client/lib "OCI_LIBS=-lclntsh -lnnz10"
+configure OCI_INCDIR=/usr/include/oracle/10.1.0.3/client OCI_LIBDIR=/usr/lib/oracle/10.1.0.3/client/lib -R /usr/lib/oracle/10.1.0.3/client/lib OCI_LIBS="-lclntsh -lnnz10"
make
//! [32]
//! [33]
cd $QTDIR/qtbase/src/plugins/sqldrivers
-qmake -- OCI_INCDIR=/usr/include/oracle/10.1.0.3/client OCI_LIBDIR=/usr/lib/oracle/10.1.0.3/client/lib "OCI_LIBS=-Wl,-rpath,/usr/lib/oracle/10.1.0.3/client/lib -lclntsh -lnnz10"
+qmake -- OCI_INCDIR=/usr/include/oracle/10.1.0.3/client OCI_LIBDIR=/usr/lib/oracle/10.1.0.3/client/lib OCI_LIBS="-Wl,-rpath,/usr/lib/oracle/10.1.0.3/client/lib -lclntsh -lnnz10"
make sub-oci
//! [33]
@@ -250,3 +256,42 @@ q.exec(QString("CREATE TABLE %1 (id INTEGER)").arg(tableString));
// Call toLower() on the string so that it can be matched
QSqlRecord rec = database.record(tableString.toLower());
//! [40]
+
+//! [41]
+C:\Qt5\5.13.2\Src\qtbase\src\plugins\sqldrivers>qmake -version
+QMake version 3.1
+Using Qt version 5.13.2 in C:/Qt5/5.13.2/mingw73_64/lib
+C:\Qt5\5.13.2\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/include" MYSQL_LIBDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/lib"
+Info: creating stash file C:\Qt5\5.13.2\Src\qtbase\src\plugins\sqldrivers\.qmake.stash
+
+Running configuration tests...
+Checking for DB2 (IBM)... no
+Checking for InterBase... no
+Checking for MySQL... yes
+Checking for OCI (Oracle)... no
+Checking for ODBC... yes
+Checking for PostgreSQL... no
+Checking for SQLite (version 2)... no
+Checking for TDS (Sybase)... no
+Done running configuration tests.
+
+Configure summary:
+
+Qt Sql Drivers:
+ DB2 (IBM) .............................. no
+ InterBase .............................. no
+ MySql .................................. yes
+ OCI (Oracle) ........................... no
+ ODBC ................................... yes
+ PostgreSQL ............................. no
+ SQLite2 ................................ no
+ SQLite ................................. yes
+ Using system provided SQLite ......... no
+ TDS (Sybase) ........................... no
+
+Qt is now configured for building. Just run 'mingw32-make'.
+Once everything is built, you must run 'mingw32-make install'.
+Qt will be installed into 'C:\Qt5\5.13.2\mingw73_64'.
+
+Prior to reconfiguration, make sure you remove any leftovers from the previous build.
+//! [41]
diff --git a/src/sql/doc/src/sql-driver.qdoc b/src/sql/doc/src/sql-driver.qdoc
index c6ac4d17ff..9c26c4089c 100644
--- a/src/sql/doc/src/sql-driver.qdoc
+++ b/src/sql/doc/src/sql-driver.qdoc
@@ -48,7 +48,7 @@
\header \li Driver name \li DBMS
\row \li \l{#QDB2}{QDB2} \li IBM DB2 (version 7.1 and above)
\row \li \l{#QIBASE}{QIBASE} \li Borland InterBase
- \row \li \l{#QMYSQL}{QMYSQL} \li MySQL
+ \row \li \l{#QMYSQL}{QMYSQL} \li MySQL (version 5.0 and above)
\row \li \l{#QOCI}{QOCI} \li Oracle Call Interface Driver
\row \li \l{#QODBC}{QODBC}
\li Open Database Connectivity (ODBC) - Microsoft SQL Server and other
@@ -70,7 +70,8 @@
access to the API exposed by the DBMS, and is typically shipped with it.
Most installation programs also allow you to install "development
libraries", and these are what you need. These libraries are responsible
- for the low-level communication with the DBMS.
+ for the low-level communication with the DBMS. Also make sure to install
+ the correct database libraries for your Qt architecture (32 or 64 bit).
\note When using Qt under Open Source terms but with a proprietary
database, verify the client library's license compatibility with
@@ -91,11 +92,21 @@
may be necessary to specify these paths using the \c *_INCDIR=,
\c *_LIBDIR=, or \c *_PREFIX= command-line options. For example,
if your MySQL files are installed in \c /usr/local/mysql (or in
- \c{C:\mysql} on Windows), then pass the following parameter to
- configure: \c MYSQL_PREFIX=/usr/local/mysql
- (or \c{MYSQL_PREFIX=C:\mysql} for Windows).
+ \c{C:/Program Files/MySQL/MySQL Connector C 6.1} on Windows), then pass the
+ following parameter to configure: \c MYSQL_PREFIX=/usr/local/mysql
+ (or \c{MYSQL_PREFIX="C:/Program Files/MySQL/MySQL Connector C 6.1"} for Windows).
The particulars for each driver are explained below.
+ If something goes wrong and you want qmake to recheck your
+ available drivers, you must remove \e{config.cache} in
+ \e{<QTDIR>/qtbase/src/plugins/sqldrivers} - otherwise qmake will not
+ search for the available drivers again. If you encounter an error during
+ the qmake stage, open \e{config.log} to see what went wrong.
+
+ A typical qmake run (in this case to configure for MySQL) looks like this:
+
+ \snippet code/doc_src_sql-driver.qdoc 41
+
Due to the practicalities of dealing with external dependencies,
only the SQLite3 plugin is shipped with binary builds of Qt.
To be able to add additional drivers to the Qt installation
@@ -112,11 +123,11 @@
\section1 Driver Specifics
\target QMYSQL
- \section2 QMYSQL for MySQL 4 and higher
+ \section2 QMYSQL for MySQL 5 and higher
\section3 QMYSQL Stored Procedure Support
- MySQL 5 introduces stored procedure support at the SQL level, but no
+ MySQL 5 has stored procedure support at the SQL level, but no
API to control IN, OUT, and INOUT parameters. Therefore, parameters
have to be set and read using SQL commands instead of QSqlQuery::bindValue().
@@ -159,16 +170,32 @@
\section3 How to Build the QMYSQL Plugin on Windows
- You need to get the MySQL installation files. Run \c SETUP.EXE and
- choose "Custom Install". Install the "Libs & Include Files" Module.
- Build the plugin as follows (here it is assumed that MySQL is
- installed in \c{C:\MySQL}):
+ You need to get the MySQL installation files (e.g.
+ \e{mysql-installer-web-community-8.0.18.0.msi}). Run the installer,
+ select custom installation and install the MySQL C Connector
+ which matches your Qt installation (x86 or x64).
+ After installation make sure that the needed files are there:
+ \list
+ \li \c {<MySQL dir>/lib/libmysql.lib}
+ \li \c {<MySQL dir>/lib/libmysql.dll}
+ \li \c {<MySQL dir>/include/mysql.h}
+ \endlist
+
+ Build the plugin as follows (here it is assumed that the MySQL
+ C Connector is installed in
+ \c{C:/Program Files/MySQL/MySQL Connector C 6.1}):
\snippet code/doc_src_sql-driver.qdoc 5
If you are not using a Microsoft compiler, replace \c nmake with \c
mingw32-make in the line above.
+ When you distribute your application, remember to include libmysql.dll
+ in your installation package. It must be placed in the same folder
+ as the application executable. libmysql.dll additionally needs the
+ MSVC runtime libraries which can be installed with vcredist.exe
+ (\l {https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads}(vcredist.exe)
+
\target QOCI
\section2 QOCI for the Oracle Call Interface (OCI)
@@ -398,11 +425,6 @@
\snippet code/doc_src_sql-driver.qdoc 40
- \section3 QPSQL BLOB Support
-
- Binary Large Objects are supported through the \c BYTEA field type in
- PostgreSQL server versions >= 7.1.
-
\section3 QPSQL Forward-only query support
To use forward-only queries, you must build the QPSQL plugin with
@@ -463,6 +485,10 @@
Users of MinGW may wish to consult the following online document:
\l{http://www.postgresql.org/docs/current/static/installation-platform-notes.html#INSTALLATION-NOTES-MINGW}{PostgreSQL MinGW/Native Windows}.
+ When you distribute your application, remember to include libpq.dll
+ in your installation package. It must be placed in the same folder
+ as the application executable.
+
\target QTDS
\section2 QTDS for Sybase Adaptive Server
diff --git a/src/testlib/doc/snippets/code/doc_src_cmakelists.txt b/src/testlib/doc/snippets/code/doc_src_cmakelists.txt
new file mode 100644
index 0000000000..96dbe1acee
--- /dev/null
+++ b/src/testlib/doc/snippets/code/doc_src_cmakelists.txt
@@ -0,0 +1,14 @@
+project(mytest LANGUAGES CXX)
+
+find_package(Qt5Test REQUIRED)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(CMAKE_AUTOMOC ON)
+
+enable_testing(true)
+
+add_executable(mytest tst_mytest.cpp)
+add_test(NAME mytest COMMAND mytest)
+
+target_link_libraries(mytest PRIVATE Qt5::Test)
diff --git a/src/testlib/doc/src/qttest-best-practices.qdoc b/src/testlib/doc/src/qttest-best-practices.qdoc
index c7fee93c80..8ad67acce6 100644
--- a/src/testlib/doc/src/qttest-best-practices.qdoc
+++ b/src/testlib/doc/src/qttest-best-practices.qdoc
@@ -278,8 +278,8 @@
\section2 Avoid Fixed Timeouts
Avoid using hard-coded timeouts, such as QTest::qWait() to wait for some
- conditions to become true. Consider using the \l QtSignalSpy class,
- the \l QTRY_VERIFY() or \l QTRY_COMPARE() macros, or the \c QtSignalSpy
+ conditions to become true. Consider using the \l QSignalSpy class,
+ the \l QTRY_VERIFY() or \l QTRY_COMPARE() macros, or the \c QSignalSpy
class in conjunction with the \c QTRY_ macro variants.
The \c qWait() function can be used to set a delay for a fixed period
diff --git a/src/testlib/doc/src/qttestlib-manual.qdoc b/src/testlib/doc/src/qttestlib-manual.qdoc
index 19d871d404..688cc2f2f6 100644
--- a/src/testlib/doc/src/qttestlib-manual.qdoc
+++ b/src/testlib/doc/src/qttestlib-manual.qdoc
@@ -83,6 +83,10 @@
\li Custom types can easily be added to the test data and test output.
\endtable
+ You can use a Qt Creator wizard to create a project that contains Qt tests
+ and build and run them directly from Qt Creator. For more information, see
+ \l {Running Autotests}.
+
\section1 Creating a Test
To create a test, subclass QObject and add one or more private slots to it. Each
@@ -133,6 +137,41 @@
\if !defined(qtforpython)
\section1 Building a Test
+ You can build an executable that contains one test class that typically
+ tests one class of production code. However, usually you would want to
+ test several classes in a project by running one command.
+
+ See \l {Chapter 1: Writing a Unit Test}{Writing a Unit Test} for a step by
+ step explanation.
+
+ \section2 Building with CMake and CTest
+
+ You can use \l {CMake and CTest} to create a test.
+ \l{https://cmake.org/cmake/help/latest/manual/ctest.1.html}{CTest} enables
+ you to include or exclude tests based on a regular expression that is
+ matched against the test name. You can further apply the \c LABELS property
+ to a test and CTest can then include or exclude tests based on those labels.
+ All labeled targets will be run when \c {test} target is called on the
+ command line.
+
+ There are several other advantages with CMake. For example, the result of
+ a test run can be published on a web server using CDash with virtually no
+ effort.
+
+ CTest scales to very different unit test frameworks, and works out of the
+ box with QTest.
+
+ The following is an example of a CMakeLists.txt file that specifies the
+ project name and the language used (here, \e mytest and C++), the Qt
+ modules required for building the test (Qt5Test), and the files that are
+ included in the test (\e tst_mytest.cpp).
+
+ \quotefile code/doc_src_cmakelists.txt
+
+ For more information about the options you have, see \l {Build with CMake}.
+
+ \section2 Building with qmake
+
If you are using \c qmake as your build tool, just add the
following to your project file:
@@ -146,14 +185,14 @@
See the \l{Building a Testcase}{qmake manual} for
more information about \c{make check}.
+ \section2 Building with Other Tools
+
If you are using other build tools, make sure that you add the location
of the Qt Test header files to your include path (usually \c{include/QtTest}
under your Qt installation directory). If you are using a release build
of Qt, link your test to the \c QtTest library. For debug builds, use
\c{QtTest_debug}.
- See \l {Chapter 1: Writing a Unit Test}{Writing a Unit Test} for a step by
- step explanation.
\endif
\section1 Qt Test Command Line Arguments
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h
index 27fe08e8f4..3b1ffb389e 100644
--- a/src/testlib/qtest.h
+++ b/src/testlib/qtest.h
@@ -95,7 +95,7 @@ template<> inline char *toString(const QByteArray &ba)
template<> inline char *toString(const QBitArray &ba)
{
qsizetype size = ba.size();
- char *str = static_cast<char *>(malloc(size + 1));
+ char *str = new char[size + 1];
for (qsizetype i = 0; i < size; ++i)
str[i] = "01"[ba.testBit(i)];
str[size] = '\0';
diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp
index 550ed0832f..6fd32c2d29 100644
--- a/src/tools/androiddeployqt/main.cpp
+++ b/src/tools/androiddeployqt/main.cpp
@@ -1717,17 +1717,18 @@ bool scanImports(Options *options, QSet<QString> *usedDependencies)
qmlImportScanner += QLatin1String(" -qrcFiles");
for (const QString &qrcFile : options->qrcFiles)
qmlImportScanner += QLatin1Char(' ') + shellQuote(qrcFile);
- } else {
- if (rootPath.isEmpty())
- rootPath = QFileInfo(options->inputFileName).absolutePath();
- else
- rootPath = QFileInfo(rootPath).absoluteFilePath();
-
- if (!rootPath.endsWith(QLatin1Char('/')))
- rootPath += QLatin1Char('/');
- qmlImportScanner += QLatin1String(" -rootPath %1").arg(shellQuote(rootPath));
}
+ if (rootPath.isEmpty())
+ rootPath = QFileInfo(options->inputFileName).absolutePath();
+ else
+ rootPath = QFileInfo(rootPath).absoluteFilePath();
+
+ if (!rootPath.endsWith(QLatin1Char('/')))
+ rootPath += QLatin1Char('/');
+
+ qmlImportScanner += QLatin1String(" -rootPath %1").arg(shellQuote(rootPath));
+
QStringList importPaths;
importPaths += shellQuote(options->qtInstallDirectory + QLatin1String("/qml"));
if (!rootPath.isEmpty())
diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp
index 9acbce25ff..7185219d34 100644
--- a/src/tools/rcc/rcc.cpp
+++ b/src/tools/rcc/rcc.cpp
@@ -1478,13 +1478,19 @@ bool RCCResourceLibrary::writeInitializer()
writeString(" return 1;\n");
writeString("}\n\n");
- writeByteArray(
- "namespace {\n"
- " struct initializer {\n"
- " initializer() { QT_RCC_MANGLE_NAMESPACE(" + initResources + ")(); }\n"
- " ~initializer() { QT_RCC_MANGLE_NAMESPACE(" + cleanResources + ")(); }\n"
- " } dummy;\n"
- "}\n");
+
+ writeString("namespace {\n"
+ " struct initializer {\n");
+
+ if (m_useNameSpace) {
+ writeByteArray(" initializer() { QT_RCC_MANGLE_NAMESPACE(" + initResources + ")(); }\n"
+ " ~initializer() { QT_RCC_MANGLE_NAMESPACE(" + cleanResources + ")(); }\n");
+ } else {
+ writeByteArray(" initializer() { " + initResources + "(); }\n"
+ " ~initializer() { " + cleanResources + "(); }\n");
+ }
+ writeString(" } dummy;\n"
+ "}\n");
} else if (m_format == Binary) {
int i = 4;
diff --git a/src/widgets/accessible/qaccessiblemenu.cpp b/src/widgets/accessible/qaccessiblemenu.cpp
index 7f87288520..048d4062b8 100644
--- a/src/widgets/accessible/qaccessiblemenu.cpp
+++ b/src/widgets/accessible/qaccessiblemenu.cpp
@@ -299,6 +299,8 @@ QAccessible::State QAccessibleMenuItem::state() const
s.disabled = true;
if (m_action->isChecked())
s.checked = true;
+ if (m_action->isCheckable())
+ s.checkable = true;
return s;
}
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp
index e1a6bce5b1..9507053ffe 100644
--- a/src/widgets/dialogs/qprogressdialog.cpp
+++ b/src/widgets/dialogs/qprogressdialog.cpp
@@ -708,14 +708,17 @@ void QProgressDialog::setValue(int progress)
QSize QProgressDialog::sizeHint() const
{
Q_D(const QProgressDialog);
- QSize sh = d->label ? d->label->sizeHint() : QSize(0, 0);
- QSize bh = d->bar->sizeHint();
- int margin = style()->pixelMetric(QStyle::PM_DefaultTopLevelMargin);
- int spacing = style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing);
- int h = margin * 2 + bh.height() + sh.height() + spacing;
+ QSize labelSize = d->label ? d->label->sizeHint() : QSize(0, 0);
+ QSize barSize = d->bar->sizeHint();
+ int marginBottom = style()->pixelMetric(QStyle::PM_LayoutBottomMargin, 0, this);
+ int spacing = style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing, 0, this);
+ int marginLeft = style()->pixelMetric(QStyle::PM_LayoutLeftMargin, 0, this);
+ int marginRight = style()->pixelMetric(QStyle::PM_LayoutRightMargin, 0, this);
+
+ int height = marginBottom * 2 + barSize.height() + labelSize.height() + spacing;
if (d->cancel)
- h += d->cancel->sizeHint().height() + spacing;
- return QSize(qMax(200, sh.width() + 2 * margin), h);
+ height += d->cancel->sizeHint().height() + spacing;
+ return QSize(qMax(200, labelSize.width() + marginLeft + marginRight), height);
}
/*!\reimp
diff --git a/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp b/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp
index 7ccd827a04..4b4fb869f9 100644
--- a/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_dialogs_qfiledialog.cpp
@@ -146,13 +146,13 @@ dialog.exec();
//! [14]
//! [15]
-auto fileOpenCompleted = [](const QString &fileName, const QByteArray &fileContent) {
+auto fileContentReady = [](const QString &fileName, const QByteArray &fileContent) {
if (fileName.isEmpty()) {
// No file was selected
} else {
// Use fileName and fileContent
}
-}
+};
QFileDialog::getOpenFileContent("Images (*.png *.xpm *.jpg)", fileContentReady);
//! [15]
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index b1557e9af4..b07faf8be4 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -3318,6 +3318,8 @@ void QAbstractItemView::update(const QModelIndex &index)
The \a roles which have been changed can either be an empty container (meaning everything
has changed), or a non-empty container with the subset of roles which have changed.
+
+ \note: Qt::ToolTipRole is not honored by dataChanged() in the views provided by Qt.
*/
void QAbstractItemView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
{
@@ -4451,7 +4453,9 @@ QItemViewPaintPairs QAbstractItemViewPrivate::draggablePaintPairs(const QModelIn
rect |= current;
}
}
- rect &= viewportRect;
+ QRect clipped = rect & viewportRect;
+ rect.setLeft(clipped.left());
+ rect.setRight(clipped.right());
return ret;
}
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index 04cddf2926..62fffc17df 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -664,7 +664,9 @@ QItemViewPaintPairs QListViewPrivate::draggablePaintPairs(const QModelIndexList
rect |= current;
}
}
- rect &= viewportRect;
+ QRect clipped = rect & viewportRect;
+ rect.setLeft(clipped.left());
+ rect.setRight(clipped.right());
return ret;
}
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index 034c1f4b4f..442369c2ec 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -1892,6 +1892,8 @@ void QTreeView::mousePressEvent(QMouseEvent *event)
handled = d->expandOrCollapseItemAtPos(event->pos());
if (!handled && d->itemDecorationAt(event->pos()) == -1)
QAbstractItemView::mousePressEvent(event);
+ else
+ d->pressedIndex = QModelIndex();
}
/*!
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index dfa1bc23b1..2a1a21596c 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -142,16 +142,19 @@ QApplicationPrivate *QApplicationPrivate::self = 0;
static void initSystemPalette()
{
- if (!QApplicationPrivate::sys_pal) {
- QPalette defaultPlatte;
- if (QApplicationPrivate::app_style)
- defaultPlatte = QApplicationPrivate::app_style->standardPalette();
- if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) {
- QApplicationPrivate::setSystemPalette(themePalette->resolve(defaultPlatte));
- QApplicationPrivate::initializeWidgetPaletteHash();
- } else {
- QApplicationPrivate::setSystemPalette(defaultPlatte);
- }
+ if (QApplicationPrivate::sys_pal)
+ return; // Already initialized
+
+ QPalette defaultPalette;
+ if (QApplicationPrivate::app_style)
+ defaultPalette = QApplicationPrivate::app_style->standardPalette();
+
+ auto *platformTheme = QGuiApplicationPrivate::platformTheme();
+ if (const QPalette *themePalette = platformTheme ? platformTheme->palette() : nullptr) {
+ QApplicationPrivate::setSystemPalette(themePalette->resolve(defaultPalette));
+ QApplicationPrivate::initializeWidgetPaletteHash();
+ } else {
+ QApplicationPrivate::setSystemPalette(defaultPalette);
}
}
@@ -431,13 +434,6 @@ void QApplicationPrivate::process_cmdline()
if (styleOverride.isEmpty() && qEnvironmentVariableIsSet("QT_STYLE_OVERRIDE"))
styleOverride = QString::fromLocal8Bit(qgetenv("QT_STYLE_OVERRIDE"));
- if (!styleOverride.isEmpty()) {
- if (app_style) {
- delete app_style;
- app_style = 0;
- }
- }
-
// process platform-indep command line
if (!qt_is_gui_used || !argc)
return;
@@ -552,6 +548,12 @@ void QApplicationPrivate::init()
// Must be called before initialize()
QColormap::initialize();
+ if (sys_pal) {
+ // Now that we have a platform theme we need to reset
+ // the system palette to pick up the theme colors.
+ clearSystemPalette();
+ initSystemPalette();
+ }
qt_init_tooltip_palette();
QApplicationPrivate::initializeWidgetFontHash();
@@ -597,8 +599,20 @@ void QApplicationPrivate::initialize()
// needed for widgets in QML
QAbstractDeclarativeData::setWidgetParent = QWidgetPrivate::setWidgetParentHelper;
- if (application_type != QApplicationPrivate::Tty)
- (void) QApplication::style(); // trigger creation of application style
+ if (application_type != QApplicationPrivate::Tty) {
+ if (!styleOverride.isEmpty()) {
+ if (auto *style = QStyleFactory::create(styleOverride.toLower())) {
+ QApplication::setStyle(style);
+ } else {
+ qWarning("QApplication: invalid style override '%s' passed, ignoring it.\n"
+ "\tAvailable styles: %s", qPrintable(styleOverride),
+ qPrintable(QStyleFactory::keys().join(QLatin1String(", "))));
+ }
+ }
+
+ // Trigger default style if none was set already
+ Q_UNUSED(QApplication::style());
+ }
#if QT_CONFIG(statemachine)
// trigger registering of QStateMachine's GUI types
qRegisterGuiStateMachine();
@@ -1016,55 +1030,45 @@ void QApplication::setStyleSheet(const QString& styleSheet)
*/
QStyle *QApplication::style()
{
- if (QApplicationPrivate::app_style)
- return QApplicationPrivate::app_style;
- if (!qobject_cast<QApplication *>(QCoreApplication::instance())) {
- Q_ASSERT(!"No style available without QApplication!");
- return 0;
- }
-
if (!QApplicationPrivate::app_style) {
- // Compile-time search for default style
- //
- QStyle *&app_style = QApplicationPrivate::app_style;
-
- if (!QApplicationPrivate::styleOverride.isEmpty()) {
- const QString style = QApplicationPrivate::styleOverride.toLower();
- app_style = QStyleFactory::create(style);
- if (Q_UNLIKELY(!app_style)) {
- qWarning("QApplication: invalid style override passed, ignoring it.\n"
- " Available styles: %s", qPrintable(QStyleFactory::keys().join(QLatin1String(", "))));
- }
+ // Create default style
+ if (!qobject_cast<QApplication *>(QCoreApplication::instance())) {
+ Q_ASSERT(!"No style available without QApplication!");
+ return nullptr;
}
- if (!app_style)
- app_style = QStyleFactory::create(QApplicationPrivate::desktopStyleKey());
- if (!app_style) {
+ auto &defaultStyle = QApplicationPrivate::app_style;
+
+ defaultStyle = QStyleFactory::create(QApplicationPrivate::desktopStyleKey());
+ if (!defaultStyle) {
const QStringList styles = QStyleFactory::keys();
for (const auto &style : styles) {
- if ((app_style = QStyleFactory::create(style)))
+ if ((defaultStyle = QStyleFactory::create(style)))
break;
}
}
- if (!app_style) {
+ if (!defaultStyle) {
Q_ASSERT(!"No styles available!");
return 0;
}
- }
- // take ownership of the style
- QApplicationPrivate::app_style->setParent(qApp);
- initSystemPalette();
+ // Take ownership of the style
+ defaultStyle->setParent(qApp);
+
+ initSystemPalette();
- if (QApplicationPrivate::set_pal) // repolish set palette with the new style
- QApplication::setPalette(*QApplicationPrivate::set_pal);
+ if (auto *explicitlySetPalette = QApplicationPrivate::set_pal)
+ defaultStyle->polish(*explicitlySetPalette);
#ifndef QT_NO_STYLE_STYLESHEET
- if (!QApplicationPrivate::styleSheet.isEmpty()) {
- qApp->setStyleSheet(QApplicationPrivate::styleSheet);
- } else
+ if (!QApplicationPrivate::styleSheet.isEmpty()) {
+ qApp->setStyleSheet(QApplicationPrivate::styleSheet);
+ } else
#endif
- QApplicationPrivate::app_style->polish(qApp);
+ {
+ defaultStyle->polish(qApp);
+ }
+ }
return QApplicationPrivate::app_style;
}
@@ -1128,17 +1132,21 @@ void QApplication::setStyle(QStyle *style)
// take care of possible palette requirements of certain gui
// styles. Do it before polishing the application since the style
// might call QApplication::setPalette() itself
- if (QApplicationPrivate::set_pal) {
- QApplication::setPalette(*QApplicationPrivate::set_pal);
- } else if (QApplicationPrivate::sys_pal) {
- clearSystemPalette();
+ if (auto *explicitlySetPalette = QApplicationPrivate::set_pal) {
+ QApplicationPrivate::app_style->polish(*explicitlySetPalette);
+ } else {
+ if (QApplicationPrivate::sys_pal)
+ clearSystemPalette();
initSystemPalette();
- QApplicationPrivate::initializeWidgetFontHash();
- } else if (!QApplicationPrivate::sys_pal) {
- // Initialize the sys_pal if it hasn't happened yet...
- QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette());
}
+ // The default widget font hash is based on the platform theme,
+ // not the style, but the widget fonts could in theory have been
+ // affected by polish of the previous style, without a proper
+ // cleanup in unpolish, so reset it now before polishing the
+ // new style.
+ QApplicationPrivate::initializeWidgetFontHash();
+
// initialize the application with the new style
QApplicationPrivate::app_style->polish(qApp);
diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp
index 97a279d65d..1ec3612457 100644
--- a/src/widgets/kernel/qtooltip.cpp
+++ b/src/widgets/kernel/qtooltip.cpp
@@ -53,11 +53,14 @@
#endif
#include <qtextdocument.h>
#include <qdebug.h>
+#include <qpa/qplatformscreen.h>
+#include <qpa/qplatformcursor.h>
#include <private/qstylesheetstyle_p.h>
#ifndef QT_NO_TOOLTIP
#include <qlabel.h>
#include <QtWidgets/private/qlabel_p.h>
+#include <QtGui/private/qhighdpiscaling_p.h>
#include <qtooltip.h>
QT_BEGIN_NAMESPACE
@@ -398,24 +401,34 @@ void QTipLabel::placeTip(const QPoint &pos, QWidget *w)
}
#endif //QT_NO_STYLE_STYLESHEET
-
- QRect screen = QDesktopWidgetPrivate::screenGeometry(getTipScreen(pos, w));
-
QPoint p = pos;
- p += QPoint(2, 16);
-
- if (p.x() + this->width() > screen.x() + screen.width())
+ int screenNumber = getTipScreen(pos, w);
+ QScreen *screen = QGuiApplication::screens().at(screenNumber);
+ if (screen) {
+ const QPlatformScreen *platformScreen = screen->handle();
+ const QSize cursorSize = QHighDpi::fromNativePixels(platformScreen->cursor()->size(),
+ platformScreen);
+ QPoint offset(2, cursorSize.height());
+ // assuming an arrow shape, we can just move to the side for very large cursors
+ if (cursorSize.height() > 2 * this->height())
+ offset = QPoint(cursorSize.width() / 2, 0);
+
+ p += offset;
+
+ QRect screenRect = screen->geometry();
+ if (p.x() + this->width() > screenRect.x() + screenRect.width())
p.rx() -= 4 + this->width();
- if (p.y() + this->height() > screen.y() + screen.height())
+ if (p.y() + this->height() > screenRect.y() + screenRect.height())
p.ry() -= 24 + this->height();
- if (p.y() < screen.y())
- p.setY(screen.y());
- if (p.x() + this->width() > screen.x() + screen.width())
- p.setX(screen.x() + screen.width() - this->width());
- if (p.x() < screen.x())
- p.setX(screen.x());
- if (p.y() + this->height() > screen.y() + screen.height())
- p.setY(screen.y() + screen.height() - this->height());
+ if (p.y() < screenRect.y())
+ p.setY(screenRect.y());
+ if (p.x() + this->width() > screenRect.x() + screenRect.width())
+ p.setX(screenRect.x() + screenRect.width() - this->width());
+ if (p.x() < screenRect.x())
+ p.setX(screenRect.x());
+ if (p.y() + this->height() > screenRect.y() + screenRect.height())
+ p.setY(screenRect.y() + screenRect.height() - this->height());
+ }
this->move(p);
}
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index e9968e41b4..dcc694efe4 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -7005,8 +7005,10 @@ void QWidget::resize(const QSize &s)
d->setGeometry_sys(geometry().x(), geometry().y(), s.width(), s.height(), false);
d->setDirtyOpaqueRegion();
} else {
+ const auto oldRect = data->crect;
data->crect.setSize(s.boundedTo(maximumSize()).expandedTo(minimumSize()));
- setAttribute(Qt::WA_PendingResizeEvent);
+ if (oldRect != data->crect)
+ setAttribute(Qt::WA_PendingResizeEvent);
}
}
@@ -7021,10 +7023,13 @@ void QWidget::setGeometry(const QRect &r)
d->setGeometry_sys(r.x(), r.y(), r.width(), r.height(), true);
d->setDirtyOpaqueRegion();
} else {
+ const auto oldRect = data->crect;
data->crect.setTopLeft(r.topLeft());
data->crect.setSize(r.size().boundedTo(maximumSize()).expandedTo(minimumSize()));
- setAttribute(Qt::WA_PendingMoveEvent);
- setAttribute(Qt::WA_PendingResizeEvent);
+ if (oldRect != data->crect) {
+ setAttribute(Qt::WA_PendingMoveEvent);
+ setAttribute(Qt::WA_PendingResizeEvent);
+ }
}
if (d->extra && d->extra->hasWindowContainer)
@@ -8619,6 +8624,23 @@ bool QWidget::event(QEvent *event)
}
}
switch (event->type()) {
+ case QEvent::PlatformSurface: {
+ // Sync up QWidget's view of whether or not the widget has been created
+ switch (static_cast<QPlatformSurfaceEvent*>(event)->surfaceEventType()) {
+ case QPlatformSurfaceEvent::SurfaceCreated:
+ if (!testAttribute(Qt::WA_WState_Created))
+ create();
+ break;
+ case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
+ if (testAttribute(Qt::WA_WState_Created)) {
+ // Child windows have already been destroyed by QWindow,
+ // so we skip them here.
+ destroy(false, false);
+ }
+ break;
+ }
+ break;
+ }
case QEvent::MouseMove:
mouseMoveEvent((QMouseEvent*)event);
break;
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 271b43fe89..09d65f0346 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -1363,7 +1363,6 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
if (!button->icon.isNull()) {
//Center both icon and text
- QRect iconRect;
QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled;
if (mode == QIcon::Normal && button->state & State_HasFocus)
mode = QIcon::Active;
@@ -1372,28 +1371,29 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
state = QIcon::On;
QPixmap pixmap = button->icon.pixmap(qt_getWindow(widget), button->iconSize, mode, state);
-
int pixmapWidth = pixmap.width() / pixmap.devicePixelRatio();
int pixmapHeight = pixmap.height() / pixmap.devicePixelRatio();
int labelWidth = pixmapWidth;
int labelHeight = pixmapHeight;
int iconSpacing = 4;//### 4 is currently hardcoded in QPushButton::sizeHint()
- int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width();
- if (!button->text.isEmpty())
+ if (!button->text.isEmpty()) {
+ int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width();
labelWidth += (textWidth + iconSpacing);
+ }
- iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2,
- textRect.y() + (textRect.height() - labelHeight) / 2,
- pixmapWidth, pixmapHeight);
+ QRect iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2,
+ textRect.y() + (textRect.height() - labelHeight) / 2,
+ pixmapWidth, pixmapHeight);
iconRect = visualRect(button->direction, textRect, iconRect);
- tf |= Qt::AlignLeft; //left align, we adjust the text-rect instead
-
- if (button->direction == Qt::RightToLeft)
+ if (button->direction == Qt::RightToLeft) {
+ tf |= Qt::AlignRight;
textRect.setRight(iconRect.left() - iconSpacing);
- else
+ } else {
+ tf |= Qt::AlignLeft; //left align, we adjust the text-rect instead
textRect.setLeft(iconRect.left() + iconRect.width() + iconSpacing);
+ }
if (button->state & (State_On | State_Sunken))
iconRect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, widget),
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index b58dc1660a..3bffd7873f 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -1770,59 +1770,10 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
break;
case CE_PushButtonLabel:
if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- QRect ir = button->rect;
- uint tf = Qt::AlignVCenter;
- if (styleHint(SH_UnderlineShortcut, button, widget))
- tf |= Qt::TextShowMnemonic;
- else
- tf |= Qt::TextHideMnemonic;
-
- if (!button->icon.isNull()) {
- //Center both icon and text
- QPoint point;
-
- QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal
- : QIcon::Disabled;
- if (mode == QIcon::Normal && button->state & State_HasFocus)
- mode = QIcon::Active;
- QIcon::State state = QIcon::Off;
- if (button->state & State_On)
- state = QIcon::On;
-
- QPixmap pixmap = button->icon.pixmap(qt_getWindow(widget), button->iconSize, mode, state);
- int w = pixmap.width() / pixmap.devicePixelRatio();
- int h = pixmap.height() / pixmap.devicePixelRatio();
-
- if (!button->text.isEmpty())
- w += button->fontMetrics.boundingRect(option->rect, tf, button->text).width() + 2;
-
- point = QPoint(ir.x() + ir.width() / 2 - w / 2,
- ir.y() + ir.height() / 2 - h / 2);
-
- w = pixmap.width() / pixmap.devicePixelRatio();
-
- if (button->direction == Qt::RightToLeft)
- point.rx() += w;
-
- painter->drawPixmap(visualPos(button->direction, button->rect, point), pixmap);
-
- if (button->direction == Qt::RightToLeft)
- ir.translate(-point.x() - 2, 0);
- else
- ir.translate(point.x() + w, 0);
-
- // left-align text if there is
- if (!button->text.isEmpty())
- tf |= Qt::AlignLeft;
-
- } else {
- tf |= Qt::AlignHCenter;
- }
-
- if (button->features & QStyleOptionButton::HasMenu)
- ir = ir.adjusted(0, 0, -proxy()->pixelMetric(PM_MenuButtonIndicator, button, widget), 0);
- proxy()->drawItemText(painter, ir, tf, button->palette, (button->state & State_Enabled),
- button->text, QPalette::ButtonText);
+ QStyleOptionButton b(*button);
+ // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+ b.state &= ~(State_On | State_Sunken);
+ QCommonStyle::drawControl(element, &b, painter, widget);
}
break;
case CE_MenuBarEmptyArea:
diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp
index 4e61b2d1ec..9477ca86da 100644
--- a/src/widgets/styles/qstylehelper.cpp
+++ b/src/widgets/styles/qstylehelper.cpp
@@ -274,6 +274,12 @@ void drawDial(const QStyleOptionSlider *option, QPainter *painter)
painter->drawLines(QStyleHelper::calcLines(option));
}
+ // setting color before BEGIN_STYLE_PIXMAPCACHE since
+ // otherwise it is not set when the image is in the cache
+ buttonColor.setHsv(buttonColor .hue(),
+ qMin(140, buttonColor .saturation()),
+ qMax(180, buttonColor.value()));
+
// Cache dial background
BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("qdial"));
p->setRenderHint(QPainter::Antialiasing);
@@ -285,9 +291,6 @@ void drawDial(const QStyleOptionSlider *option, QPainter *painter)
QRectF br = QRectF(dx + 0.5, dy + 0.5,
int(r * 2 - 2 * d_ - 2),
int(r * 2 - 2 * d_ - 2));
- buttonColor.setHsv(buttonColor .hue(),
- qMin(140, buttonColor .saturation()),
- qMax(180, buttonColor.value()));
if (enabled) {
// Drop shadow
diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp
index 01cadd9a86..237d496e0e 100644
--- a/src/widgets/styles/qstyleoption.cpp
+++ b/src/widgets/styles/qstyleoption.cpp
@@ -1453,7 +1453,7 @@ QStyleOptionTab::QStyleOptionTab(int version)
\value None A normal tab button.
\value HasFrame The tab button is positioned on a tab frame
- \sa features
+ \sa QStyleOptionToolBar::features
*/
/*!
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 3f57992311..98c85684ae 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -3493,6 +3493,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
} else {
QWindowsStyle::drawControl(ce, &btnOpt, p, w);
}
+ rule.drawImage(p, rule.contentsRect(opt->rect));
if (!customMenu)
return;
} else {
@@ -3711,6 +3712,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
bool dis = !(opt->state & QStyle::State_Enabled),
act = opt->state & QStyle::State_Selected;
+ int textRectOffset = m->maxIconWidth;
if (!mi.icon.isNull()) {
QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
if (act && !dis)
@@ -3736,19 +3738,21 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
p->drawPixmap(pmr.topLeft(), pixmap);
} else if (checkable) {
QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark);
+ const QRect cmRect = positionRect(w, subRule, subSubRule, PseudoElement_MenuCheckMark, opt->rect, opt->direction);
if (subSubRule.hasDrawable() || checked) {
QStyleOptionMenuItem newMi = mi;
if (!dis)
newMi.state |= State_Enabled;
- if (act)
+ if (mi.checked)
newMi.state |= State_On;
- newMi.rect = positionRect(w, subRule, subSubRule, PseudoElement_MenuCheckMark, opt->rect, opt->direction);
+ newMi.rect = cmRect;
drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, w);
}
+ textRectOffset = std::max(textRectOffset, cmRect.width());
}
QRect textRect = subRule.contentsRect(opt->rect);
- textRect.setLeft(textRect.left() + m->maxIconWidth);
+ textRect.setLeft(textRect.left() + textRectOffset);
textRect.setWidth(textRect.width() - mi.tabWidth);
const QRect vTextRect = visualRect(opt->direction, m->rect, textRect);
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp
index e26993fb23..9189319364 100644
--- a/src/widgets/widgets/qdatetimeedit.cpp
+++ b/src/widgets/widgets/qdatetimeedit.cpp
@@ -90,12 +90,10 @@ QT_BEGIN_NAMESPACE
today's date, and restricted the valid date range to today plus or
minus 365 days. We've set the order to month, day, year.
- The minimum value for QDateTimeEdit is 14 September 1752. You can
- change this by calling setMinimumDate(), taking into account that
- the minimum value for QDate is 2 January 4713BC.
-
- Other useful functions are setMaximumDate(), setMinimumTime()
- and setMaximumTime().
+ The range of valid values for a QDateTimeEdit is controlled by the properties
+ \l minimumDateTime, \l maximumDateTime, and their respective date and time
+ components. By default, any date-time from the start of 100 CE to the end of
+ 9999 CE is valid.
\section1 Using a Pop-up Calendar Widget
@@ -223,10 +221,16 @@ QDateTimeEdit::~QDateTimeEdit()
When setting this property the timespec of the QDateTimeEdit remains the same
and the timespec of the new QDateTime is ignored.
- By default, this property contains a date that refers to January 1,
- 2000 and a time of 00:00:00 and 0 milliseconds.
+ By default, this property is set to the start of 2000 CE. It can only be set
+ to a valid QDateTime value. If any operation causes this property to have an
+ invalid date-time as value, it is reset to the value of the \l minimumDateTime
+ property.
+
+ If the QDateTimeEdit has no date fields, setting this property sets the
+ widget's date-range to start and end on the date of the new value of this
+ property.
- \sa date, time
+ \sa date, time, minimumDateTime, maximumDateTime
*/
QDateTime QDateTimeEdit::dateTime() const
@@ -329,25 +333,23 @@ void QDateTimeEdit::setCalendar(QCalendar calendar)
}
/*!
- \property QDateTimeEdit::minimumDateTime
\since 4.4
+ \property QDateTimeEdit::minimumDateTime
\brief the minimum datetime of the date time edit
- When setting this property the \l maximumDateTime() is adjusted if
- necessary to ensure that the range remains valid. If the datetime is
- not a valid QDateTime object, this function does nothing.
-
- The default minimumDateTime can be restored with
- clearMinimumDateTime()
+ Changing this property implicitly updates the \l minimumDate and \l
+ minimumTime properties to the date and time parts of this property,
+ respectively. When setting this property, the \l maximumDateTime is adjusted,
+ if necessary, to ensure that the range remains valid. Otherwise, changing this
+ property preserves the \l minimumDateTime property.
- By default, this property contains a date that refers to September 14,
- 1752 and a time of 00:00:00 and 0 milliseconds.
+ This property can only be set to a valid QDateTime value. The earliest
+ date-time that setMinimumDateTime() accepts is the start of 100 CE. The
+ property's default is the start of September 14, 1752 CE. This default can be
+ restored with clearMinimumDateTime().
- \sa maximumDateTime(), minimumTime(), maximumTime(), minimumDate(),
- maximumDate(), setDateTimeRange(), setDateRange(), setTimeRange(),
- clearMaximumDateTime(), clearMinimumDate(),
- clearMaximumDate(), clearMinimumTime(), clearMaximumTime()
+ \sa maximumDateTime, minimumTime, minimumDate, setDateTimeRange(), QDateTime::isValid()
*/
QDateTime QDateTimeEdit::minimumDateTime() const
@@ -372,25 +374,23 @@ void QDateTimeEdit::setMinimumDateTime(const QDateTime &dt)
}
/*!
- \property QDateTimeEdit::maximumDateTime
\since 4.4
+ \property QDateTimeEdit::maximumDateTime
\brief the maximum datetime of the date time edit
- When setting this property the \l minimumDateTime() is adjusted if
- necessary to ensure that the range remains valid. If the datetime is
- not a valid QDateTime object, this function does nothing.
+ Changing this property implicitly updates the \l maximumDate and \l
+ maximumTime properties to the date and time parts of this property,
+ respectively. When setting this property, the \l minimumDateTime is adjusted,
+ if necessary, to ensure that the range remains valid. Otherwise, changing this
+ property preserves the \l minimumDateTime property.
- The default maximumDateTime can be restored with
+ This property can only be set to a valid QDateTime value. The latest
+ date-time that setMaximumDateTime() accepts is the end of 9999 CE. This is the
+ default for this property. This default can be restored with
clearMaximumDateTime().
- By default, this property contains a date that refers to 31 December,
- 9999 and a time of 23:59:59 and 999 milliseconds.
-
- \sa minimumDateTime(), minimumTime(), maximumTime(), minimumDate(),
- maximumDate(), setDateTimeRange(), setDateRange(), setTimeRange(),
- clearMinimumDateTime(), clearMinimumDate(),
- clearMaximumDate(), clearMinimumTime(), clearMaximumTime()
+ \sa minimumDateTime, maximumTime, maximumDate(), setDateTimeRange(), QDateTime::isValid()
*/
QDateTime QDateTimeEdit::maximumDateTime() const
@@ -414,11 +414,12 @@ void QDateTimeEdit::setMaximumDateTime(const QDateTime &dt)
}
}
-
/*!
- Convenience function to set minimum and maximum date time with one
- function call.
\since 4.4
+ \brief Set the range of allowed date-times for the date time edit.
+
+ This convenience function sets the \l minimumDateTime and \l maximumDateTime
+ properties.
\snippet code/src_gui_widgets_qdatetimeedit.cpp 1
@@ -426,21 +427,18 @@ void QDateTimeEdit::setMaximumDateTime(const QDateTime &dt)
\snippet code/src_gui_widgets_qdatetimeedit.cpp 2
- If either \a min or \a max are not valid, this function does
- nothing.
+ If either \a min or \a max is invalid, this function does nothing. If \a max
+ is less than \a min, \a min is used also as \a max.
- \sa setMinimumDate(), maximumDate(), setMaximumDate(),
- clearMinimumDate(), setMinimumTime(), maximumTime(),
- setMaximumTime(), clearMinimumTime(), QDateTime::isValid()
+ \sa minimumDateTime, maximumDateTime, setDateRange(), setTimeRange(), QDateTime::isValid()
*/
void QDateTimeEdit::setDateTimeRange(const QDateTime &min, const QDateTime &max)
{
Q_D(QDateTimeEdit);
+ // FIXME: does none of the range checks applied to setMin/setMax methods !
const QDateTime minimum = min.toTimeSpec(d->spec);
- QDateTime maximum = max.toTimeSpec(d->spec);
- if (min > max)
- maximum = minimum;
+ const QDateTime maximum = (min > max ? minimum : max.toTimeSpec(d->spec));
d->setRange(minimum, maximum);
}
@@ -449,15 +447,20 @@ void QDateTimeEdit::setDateTimeRange(const QDateTime &min, const QDateTime &max)
\brief the minimum date of the date time edit
- When setting this property the \l maximumDate is adjusted if
- necessary, to ensure that the range remains valid. If the date is
- not a valid QDate object, this function does nothing.
+ Changing this property updates the date of the \l minimumDateTime property
+ while preserving the \l minimumTime property. When setting this property,
+ the \l maximumDate is adjusted, if necessary, to ensure that the range remains
+ valid. When this happens, the \l maximumTime property is also adjusted if it
+ is less than the \l minimumTime property. Otherwise, changes to this property
+ preserve the \l maximumDateTime property.
- By default, this property contains a date that refers to September 14, 1752.
- The minimum date must be at least the first day in year 100, otherwise
- setMinimumDate() has no effect.
+ This property can only be set to a valid QDate object describing a date on
+ which the current \l minimumTime property makes a valid QDateTime object. The
+ earliest date that setMinimumDate() accepts is the start of 100 CE. The
+ default for this property is September 14, 1752 CE. This default can be
+ restored with clearMinimumDateTime().
- \sa minimumTime(), maximumTime(), setDateRange()
+ \sa maximumDate, minimumTime, minimumDateTime, setDateRange(), QDate::isValid()
*/
QDate QDateTimeEdit::minimumDate() const
@@ -484,13 +487,20 @@ void QDateTimeEdit::clearMinimumDate()
\brief the maximum date of the date time edit
- When setting this property the \l minimumDate is adjusted if
- necessary to ensure that the range remains valid. If the date is
- not a valid QDate object, this function does nothing.
-
- By default, this property contains a date that refers to December 31, 9999.
+ Changing this property updates the date of the \l maximumDateTime property
+ while preserving the \l maximumTime property. When setting this property, the
+ \l minimumDate is adjusted, if necessary, to ensure that the range remains
+ valid. When this happens, the \l minimumTime property is also adjusted if it
+ is greater than the \l maximumTime property. Otherwise, changes to this
+ property preserve the \l minimumDateTime property.
+
+ This property can only be set to a valid QDate object describing a date on
+ which the current \l maximumTime property makes a valid QDateTime object. The
+ latest date that setMaximumDate() accepts is the end of 9999 CE. This is the
+ default for this property. This default can be restored with
+ clearMaximumDateTime().
- \sa minimumDate, minimumTime, maximumTime, setDateRange()
+ \sa minimumDate, maximumTime, maximumDateTime, setDateRange(), QDate::isValid()
*/
QDate QDateTimeEdit::maximumDate() const
@@ -502,9 +512,8 @@ QDate QDateTimeEdit::maximumDate() const
void QDateTimeEdit::setMaximumDate(const QDate &max)
{
Q_D(QDateTimeEdit);
- if (max.isValid()) {
+ if (max.isValid())
setMaximumDateTime(QDateTime(max, d->maximum.toTime(), d->spec));
- }
}
void QDateTimeEdit::clearMaximumDate()
@@ -517,13 +526,18 @@ void QDateTimeEdit::clearMaximumDate()
\brief the minimum time of the date time edit
- When setting this property the \l maximumTime is adjusted if
- necessary, to ensure that the range remains valid. If the time is
- not a valid QTime object, this function does nothing.
+ Changing this property updates the time of the \l minimumDateTime property
+ while preserving the \l minimumDate and \l maximumDate properties. If those
+ date properties coincide, when setting this property, the \l maximumTime
+ property is adjusted, if necessary, to ensure that the range remains
+ valid. Otherwise, changing this property preserves the \l maximumDateTime
+ property.
- By default, this property contains a time of 00:00:00 and 0 milliseconds.
+ This property can be set to any valid QTime value. By default, this property
+ contains a time of 00:00:00 and 0 milliseconds. This default can be restored
+ with clearMinimumTime().
- \sa maximumTime, minimumDate, maximumDate, setTimeRange()
+ \sa maximumTime, minimumDate, minimumDateTime, setTimeRange(), QTime::isValid()
*/
QTime QDateTimeEdit::minimumTime() const
@@ -551,13 +565,18 @@ void QDateTimeEdit::clearMinimumTime()
\brief the maximum time of the date time edit
- When setting this property, the \l minimumTime is adjusted if
- necessary to ensure that the range remains valid. If the time is
- not a valid QTime object, this function does nothing.
+ Changing this property updates the time of the \l maximumDateTime property
+ while preserving the \l minimumDate and \l maximumDate properties. If those
+ date properties coincide, when setting this property, the \l minimumTime
+ property is adjusted, if necessary, to ensure that the range remains
+ valid. Otherwise, changing this property preserves the \l minimumDateTime
+ property.
- By default, this property contains a time of 23:59:59 and 999 milliseconds.
+ This property can be set to any valid QTime value. By default, this property
+ contains a time of 23:59:59 and 999 milliseconds. This default can be restored
+ with clearMaximumTime().
- \sa minimumTime, minimumDate, maximumDate, setTimeRange()
+ \sa minimumTime, maximumDate, maximumDateTime, setTimeRange(), QTime::isValid()
*/
QTime QDateTimeEdit::maximumTime() const
{
@@ -580,8 +599,10 @@ void QDateTimeEdit::clearMaximumTime()
}
/*!
- Convenience function to set minimum and maximum date with one
- function call.
+ \brief Set the range of allowed dates for the date time edit.
+
+ This convenience function sets the \l minimumDate and \l maximumDate
+ properties.
\snippet code/src_gui_widgets_qdatetimeedit.cpp 3
@@ -589,12 +610,14 @@ void QDateTimeEdit::clearMaximumTime()
\snippet code/src_gui_widgets_qdatetimeedit.cpp 4
- If either \a min or \a max are not valid, this function does
- nothing.
+ If either \a min or \a max is invalid, this function does nothing. This
+ function preserves the \l minimumTime property. If \a max is less than \a min,
+ the new maximumDateTime property shall be the new minimumDateTime property. If
+ \a max is equal to \a min and the \l maximumTime property was less then the \l
+ minimumTime property, the \l maximumTime property is set to the \l minimumTime
+ property. Otherwise, this preserves the \l maximumTime property.
- \sa setMinimumDate(), maximumDate(), setMaximumDate(),
- clearMinimumDate(), setMinimumTime(), maximumTime(),
- setMaximumTime(), clearMinimumTime(), QDate::isValid()
+ \sa minimumDate, maximumDate, setDateTimeRange(), QDate::isValid()
*/
void QDateTimeEdit::setDateRange(const QDate &min, const QDate &max)
@@ -607,8 +630,16 @@ void QDateTimeEdit::setDateRange(const QDate &min, const QDate &max)
}
/*!
- Convenience function to set minimum and maximum time with one
- function call.
+ \brief Set the range of allowed times for the date time edit.
+
+ This convenience function sets the \l minimumTime and \l maximumTime
+ properties.
+
+ Note that these only constrain the date time edit's value on,
+ respectively, the \l minimumDate and \l maximumDate. When these date
+ properties do not coincide, times after \a maximumTime are allowed on dates
+ before \l maximumDate and times before \a minimumTime are allowed on dates
+ after \l minimumDate.
\snippet code/src_gui_widgets_qdatetimeedit.cpp 5
@@ -616,12 +647,11 @@ void QDateTimeEdit::setDateRange(const QDate &min, const QDate &max)
\snippet code/src_gui_widgets_qdatetimeedit.cpp 6
- If either \a min or \a max are not valid, this function does
- nothing.
+ If either \a min or \a max is invalid, this function does nothing. This
+ function preserves the \l minimumDate and \l maximumDate properties. If those
+ properties coincide and max is \a less than \a min, \a min is used as \a max.
- \sa setMinimumDate(), maximumDate(), setMaximumDate(),
- clearMinimumDate(), setMinimumTime(), maximumTime(),
- setMaximumTime(), clearMinimumTime(), QTime::isValid()
+ \sa minimumTime, maximumTime, setDateTimeRange(), QTime::isValid()
*/
void QDateTimeEdit::setTimeRange(const QTime &min, const QTime &max)
@@ -865,7 +895,7 @@ QString QDateTimeEdit::sectionText(Section section) const
Note that if you specify a two digit year, it will be interpreted
to be in the century in which the date time edit was initialized.
- The default century is the 21 (2000-2099).
+ The default century is the 21st (2000-2099).
If you specify an invalid format the format will not be set.
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index fb67936768..658315028a 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -1198,12 +1198,18 @@ QMargins QLineEdit::textMargins() const
Unset the mask and return to normal QLineEdit operation by passing
an empty string ("").
- The table below shows the characters that can be used in an input mask.
- A space character, the default character for a blank, is needed for cases
- where a character is \e{permitted but not required}.
+ The input mask is an input template string. It can contain the following elements:
+ \table
+ \row \li Mask Characters \li Defines the class of input characters that are
+ considered valid in this position
+ \row \li Meta Characters \li Various special meanings
+ \row \li Separators \li All other characters are regarded as immutable separators
+ \endtable
+
+ The following table shows the mask and meta characters that can be used in an input mask.
\table
- \header \li Character \li Meaning
+ \header \li Mask Character \li Meaning
\row \li \c A \li ASCII alphabetic character required. A-Z, a-z.
\row \li \c a \li ASCII alphabetic character permitted but not required.
\row \li \c N \li ASCII alphanumeric character required. A-Z, a-z, 0-9.
@@ -1219,19 +1225,28 @@ QMargins QLineEdit::textMargins() const
\row \li \c h \li Hexadecimal character permitted but not required.
\row \li \c B \li Binary character required. 0-1.
\row \li \c b \li Binary character permitted but not required.
+ \header \li Meta Character \li Meaning
\row \li \c > \li All following alphabetic characters are uppercased.
\row \li \c < \li All following alphabetic characters are lowercased.
\row \li \c ! \li Switch off case conversion.
+ \row \li \c {;c} \li Terminates the input mask and sets the \e{blank} character to \e{c}.
\row \li \c {[ ] { }} \li Reserved.
\row \li \tt{\\} \li Use \tt{\\} to escape the special
characters listed above to use them as
separators.
\endtable
- The mask consists of a string of mask characters and separators,
- optionally followed by a semicolon and the character used for
- blanks. The blank characters are always removed from the text
- after editing.
+ When created or cleared, the line edit will be filled with a copy of the
+ input mask string where the meta characters have been removed, and the mask
+ characters have been replaced with the \e{blank} character (by default, a
+ \c space).
+
+ When an input mask is set, the text() method returns a modified copy of the
+ line edit content where all the \e{blank} characters have been removed. The
+ unmodified content can be read using displayText().
+
+ The hasAcceptableInput() method returns false if the current content of the
+ line edit does not fulfil the requirements of the input mask.
Examples:
\table
@@ -1240,7 +1255,7 @@ QMargins QLineEdit::textMargins() const
\row \li \c HH:HH:HH:HH:HH:HH;_ \li MAC address
\row \li \c 0000-00-00 \li ISO Date; blanks are \c space
\row \li \c >AAAAA-AAAAA-AAAAA-AAAAA-AAAAA;# \li License number;
- blanks are \c - and all (alphabetic) characters are converted to
+ blanks are \c{#} and all (alphabetic) characters are converted to
uppercase.
\endtable
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 51b458f03a..57ef7905d9 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -789,6 +789,8 @@ void QMenuSloppyState::setSubMenuPopup(const QRect &actionRect, QAction *resetAc
m_use_reset_action = true;
m_time.stop();
m_action_rect = actionRect;
+ if (m_sub_menu)
+ QMenuPrivate::get(m_sub_menu)->sloppyState.m_parent = nullptr;
m_sub_menu = subMenu;
QMenuPrivate::get(subMenu)->sloppyState.m_parent = this;
m_reset_action = resetAction;
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index 3d31a3b73a..7a751597bc 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -851,7 +851,8 @@ QMenu *QMenuBar::addMenu(const QIcon &icon, const QString &title)
}
/*!
- Appends \a menu to the menu bar. Returns the menu's menuAction().
+ Appends \a menu to the menu bar. Returns the menu's menuAction(). The menu bar
+ does not take ownership of the menu.
\note The returned QAction object can be used to hide the corresponding
menu.
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index 0a81931b57..e8da720b58 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -2328,6 +2328,7 @@ void QPlainTextEdit::changeEvent(QEvent *e)
d->autoScrollTimer.stop();
} else if (e->type() == QEvent::EnabledChange) {
e->setAccepted(isEnabled());
+ d->control->setPalette(palette());
d->sendControlEvent(e);
} else if (e->type() == QEvent::PaletteChange) {
d->control->setPalette(palette());
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index 1c169c3325..83e2315c36 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -1283,6 +1283,8 @@ void QWidgetTextControlPrivate::keyPressEvent(QKeyEvent *e)
} else {
QTextCursor localCursor = cursor;
localCursor.deletePreviousChar();
+ if (cursor.d)
+ cursor.d->setX();
}
goto accept;
}
@@ -1322,9 +1324,13 @@ void QWidgetTextControlPrivate::keyPressEvent(QKeyEvent *e)
else if (e == QKeySequence::Delete) {
QTextCursor localCursor = cursor;
localCursor.deleteChar();
+ if (cursor.d)
+ cursor.d->setX();
} else if (e == QKeySequence::Backspace) {
QTextCursor localCursor = cursor;
localCursor.deletePreviousChar();
+ if (cursor.d)
+ cursor.d->setX();
}else if (e == QKeySequence::DeleteEndOfWord) {
if (!cursor.hasSelection())
cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor);