summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/forkfd/forkfd.c4
-rw-r--r--src/3rdparty/harfbuzz/src/harfbuzz-impl.h2
-rw-r--r--src/corelib/doc/src/qtcore-index.qdoc5
-rw-r--r--src/corelib/global/qflags.h4
-rw-r--r--src/corelib/global/qglobal.h3
-rw-r--r--src/corelib/global/qisenum.h18
-rw-r--r--src/corelib/global/qlibraryinfo.cpp79
-rw-r--r--src/corelib/global/qnamespace.h1
-rw-r--r--src/corelib/global/qnumeric_p.h4
-rw-r--r--src/corelib/global/qt_windows.h3
-rw-r--r--src/corelib/global/qtypeinfo.h9
-rw-r--r--src/corelib/global/qtypetraits.h489
-rw-r--r--src/corelib/io/qfilesystemengine.cpp4
-rw-r--r--src/corelib/io/qfilesystemiterator_p.h8
-rw-r--r--src/corelib/io/qfilesystemiterator_unix.cpp38
-rw-r--r--src/corelib/io/qstandardpaths_win.cpp79
-rw-r--r--src/corelib/io/qurl.cpp2
-rw-r--r--src/corelib/json/qjson.cpp25
-rw-r--r--src/corelib/json/qjson_p.h37
-rw-r--r--src/corelib/json/qjsonobject.cpp4
-rw-r--r--src/corelib/json/qjsonparser.cpp94
-rw-r--r--src/corelib/json/qjsonparser_p.h4
-rw-r--r--src/corelib/json/qjsonvalue.cpp8
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp2
-rw-r--r--src/corelib/kernel/qeventdispatcher_winrt.cpp33
-rw-r--r--src/corelib/kernel/qmetatype.h12
-rw-r--r--src/corelib/kernel/qobject.h12
-rw-r--r--src/corelib/kernel/qpointer.h2
-rw-r--r--src/corelib/kernel/qtimer.h8
-rw-r--r--src/corelib/kernel/qvariant.cpp1
-rw-r--r--src/corelib/kernel/qvariant_p.h12
-rw-r--r--src/corelib/thread/qmutex.cpp3
-rw-r--r--src/corelib/tools/qalgorithms.h2
-rw-r--r--src/corelib/tools/qbytearray_p.h3
-rw-r--r--src/corelib/tools/qhash.h9
-rw-r--r--src/corelib/tools/qlist.h4
-rw-r--r--src/corelib/tools/qmap.h7
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h2
-rw-r--r--src/corelib/tools/qstring.cpp33
-rw-r--r--src/corelib/tools/qstringalgorithms_p.h4
-rw-r--r--src/corelib/xml/qxmlstream.cpp2
-rw-r--r--src/gui/configure.json10
-rw-r--r--src/gui/configure.pri2
-rw-r--r--src/gui/image/qicon.cpp2
-rw-r--r--src/gui/image/qiconloader.cpp6
-rw-r--r--src/gui/image/qpixmapcache.cpp19
-rw-r--r--src/gui/kernel/kernel.pri2
-rw-r--r--src/gui/kernel/qhighdpiscaling.cpp6
-rw-r--r--src/gui/kernel/qopenglcontext.cpp5
-rw-r--r--src/gui/kernel/qopenglcontext_p.h2
-rw-r--r--src/gui/kernel/qwindow.cpp3
-rw-r--r--src/gui/opengl/opengl.pri2
-rw-r--r--src/gui/opengl/qopengl.cpp6
-rw-r--r--src/gui/opengl/qopengl.h18
-rw-r--r--src/gui/opengl/qopenglframebufferobject.cpp6
-rw-r--r--src/gui/opengl/qopenglshaderprogram.cpp81
-rw-r--r--src/gui/painting/painting.pri12
-rw-r--r--src/gui/painting/qdrawhelper.cpp12
-rw-r--r--src/gui/text/qfontengine_ft.cpp112
-rw-r--r--src/gui/text/qfontengine_ft_p.h8
-rw-r--r--src/gui/text/qrawfont.cpp13
-rw-r--r--src/gui/text/qrawfont.h2
-rw-r--r--src/gui/text/qtextdocument.cpp4
-rw-r--r--src/gui/text/qtextformat.cpp3
-rw-r--r--src/gui/text/qtextlayout.cpp17
-rw-r--r--src/gui/text/text.pri24
-rw-r--r--src/network/access/qnetworkcookiejar.cpp2
-rw-r--r--src/network/socket/qnativesocketengine_winrt.cpp4
-rw-r--r--src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc29
-rw-r--r--src/platformsupport/eglconvenience/qt_egl_p.h2
-rw-r--r--src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp52
-rw-r--r--src/platformsupport/fontdatabases/fontdatabases.pro4
-rw-r--r--src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp7
-rw-r--r--src/platformsupport/fontdatabases/winrt/qwinrtfontdatabase.cpp (renamed from src/plugins/platforms/winrt/qwinrtfontdatabase.cpp)2
-rw-r--r--src/platformsupport/fontdatabases/winrt/qwinrtfontdatabase_p.h (renamed from src/plugins/platforms/winrt/qwinrtfontdatabase.h)11
-rw-r--r--src/platformsupport/fontdatabases/winrt/winrt.pri11
-rw-r--r--src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm124
-rw-r--r--src/plugins/platforms/cocoa/qcocoacursor.mm9
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm13
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm5
-rw-r--r--src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm131
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.h23
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm114
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenu.mm17
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.mm6
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm60
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h1
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm23
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dhelpers.h7
-rw-r--r--src/plugins/platforms/directfb/directfb.pro2
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsintegration.cpp12
-rw-r--r--src/plugins/platforms/ios/optional/optional.pro2
-rw-r--r--src/plugins/platforms/ios/qiostextresponder.mm2
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp12
-rw-r--r--src/plugins/platforms/mirclient/qmirclientcursor.cpp2
-rw-r--r--src/plugins/platforms/vnc/qvnc.cpp8
-rw-r--r--src/plugins/platforms/winrt/qwinrtbackingstore.h1
-rw-r--r--src/plugins/platforms/winrt/qwinrtdrag.cpp8
-rw-r--r--src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp16
-rw-r--r--src/plugins/platforms/winrt/qwinrtfileengine.cpp2
-rw-r--r--src/plugins/platforms/winrt/qwinrtintegration.cpp2
-rw-r--r--src/plugins/platforms/winrt/qwinrtscreen.cpp2
-rw-r--r--src/plugins/platforms/winrt/winrt.pro4
-rw-r--r--src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp7
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.cpp6
-rw-r--r--src/plugins/platforms/xcb/qxcbcursor.cpp4
-rw-r--r--src/plugins/platforms/xcb/xcb-static/xcb-static.pro2
-rw-r--r--src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp18
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog_mac.mm5
-rw-r--r--src/printsupport/dialogs/qprintdialog_mac.mm5
-rw-r--r--src/src.pro4
-rw-r--r--src/testlib/qtestcase.h3
-rw-r--r--src/tools/bootstrap/bootstrap.pro5
-rw-r--r--src/widgets/accessible/itemviews.cpp7
-rw-r--r--src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp8
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.h4
-rw-r--r--src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp8
-rw-r--r--src/widgets/graphicsview/qgraphicstransform_p.h2
-rw-r--r--src/widgets/graphicsview/qgraphicswidget.cpp1
-rw-r--r--src/widgets/graphicsview/qgraphicswidget_p.cpp3
-rw-r--r--src/widgets/kernel/qapplication.cpp2
-rw-r--r--src/widgets/kernel/qwidget.cpp7
-rw-r--r--src/widgets/styles/qpixmapstyle.cpp6
-rw-r--r--src/widgets/styles/qstylehelper.cpp22
-rw-r--r--src/widgets/styles/qstyleoption.h8
-rw-r--r--src/widgets/widgets/qcombobox.cpp14
-rw-r--r--src/widgets/widgets/qlabel.cpp1
-rw-r--r--src/widgets/widgets/qmainwindow.cpp2
-rw-r--r--src/widgets/widgets/qmdisubwindow_p.h2
-rw-r--r--src/widgets/widgets/qmenu.h4
-rw-r--r--src/widgets/widgets/qsizegrip.cpp5
-rw-r--r--src/widgets/widgets/qtoolbar.h4
-rw-r--r--src/winmain/qtmain_winrt.cpp6
136 files changed, 1115 insertions, 1250 deletions
diff --git a/src/3rdparty/forkfd/forkfd.c b/src/3rdparty/forkfd/forkfd.c
index 7b711e197b..e57d9aa1e0 100644
--- a/src/3rdparty/forkfd/forkfd.c
+++ b/src/3rdparty/forkfd/forkfd.c
@@ -162,7 +162,7 @@ static ProcessInfo *tryAllocateInSection(Header *header, ProcessInfo entries[],
}
/* there isn't an available entry, undo our increment */
- ffd_atomic_add_fetch(&header->busyCount, -1, FFD_ATOMIC_RELAXED);
+ (void)ffd_atomic_add_fetch(&header->busyCount, -1, FFD_ATOMIC_RELAXED);
return NULL;
}
@@ -267,7 +267,7 @@ static void freeInfo(Header *header, ProcessInfo *entry)
entry->deathPipe = -1;
entry->pid = 0;
- ffd_atomic_add_fetch(&header->busyCount, -1, FFD_ATOMIC_RELEASE);
+ (void)ffd_atomic_add_fetch(&header->busyCount, -1, FFD_ATOMIC_RELEASE);
assert(header->busyCount >= 0);
}
diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-impl.h b/src/3rdparty/harfbuzz/src/harfbuzz-impl.h
index 5f430498c4..f98594ac91 100644
--- a/src/3rdparty/harfbuzz/src/harfbuzz-impl.h
+++ b/src/3rdparty/harfbuzz/src/harfbuzz-impl.h
@@ -59,7 +59,7 @@ HB_BEGIN_HEADER
#endif
#ifndef HB_UNUSED
-# define HB_UNUSED(arg) ((arg) = (arg))
+# define HB_UNUSED(arg) ((void)(arg))
#endif
#define HB_LIKELY(cond) (cond)
diff --git a/src/corelib/doc/src/qtcore-index.qdoc b/src/corelib/doc/src/qtcore-index.qdoc
index fe9b43507c..9004c018ed 100644
--- a/src/corelib/doc/src/qtcore-index.qdoc
+++ b/src/corelib/doc/src/qtcore-index.qdoc
@@ -109,6 +109,11 @@
the \l{GNU General Public License, version 2}.
See \l{Qt Licensing} for further details.
+ Executables on Windows potentially link
+ against \l{The qtmain Library}. This library is available
+ under commercial licenses, and in addition under the
+ \l{BSD 3-clause "New" or "Revised" License}.
+
Furthermore Qt Core potentially contains third party
modules under following permissive licenses:
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h
index a6bd37c33f..b871c90c9d 100644
--- a/src/corelib/global/qflags.h
+++ b/src/corelib/global/qflags.h
@@ -102,8 +102,8 @@ public:
// the definition below is too complex for qdoc
typedef int Int;
#else
- typedef typename QtPrivate::if_<
- QtPrivate::is_unsigned<Enum>::value,
+ typedef typename std::conditional<
+ QtPrivate::QIsUnsignedEnum<Enum>::value,
unsigned int,
signed int
>::type Int;
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 1bcd30e0b3..99be82f8c3 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -42,6 +42,7 @@
#define QGLOBAL_H
#ifdef __cplusplus
+# include <type_traits>
# include <cstddef>
#endif
@@ -963,7 +964,7 @@ public:
// - if there was a break inside the inner loop, it will exit with control still
// set to 1; in that case, the outer loop will invert it to 0 and will exit too
#define Q_FOREACH(variable, container) \
-for (QForeachContainer<typename QtPrivate::remove_reference<decltype(container)>::type> _container_((container)); \
+for (QForeachContainer<typename std::remove_reference<decltype(container)>::type> _container_((container)); \
_container_.control && _container_.i != _container_.e; \
++_container_.i, _container_.control ^= 1) \
for (variable = *_container_.i; _container_.control; _container_.control = 0)
diff --git a/src/corelib/global/qisenum.h b/src/corelib/global/qisenum.h
index 0a4d44619c..8f784ef6e3 100644
--- a/src/corelib/global/qisenum.h
+++ b/src/corelib/global/qisenum.h
@@ -42,22 +42,8 @@
#ifndef QISENUM_H
#define QISENUM_H
-#ifndef Q_IS_ENUM
-# if defined(Q_CC_GNU) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
-# define Q_IS_ENUM(x) __is_enum(x)
-# elif defined(Q_CC_MSVC) && defined(_MSC_FULL_VER) && (_MSC_FULL_VER >=140050215)
-# define Q_IS_ENUM(x) __is_enum(x)
-# elif defined(Q_CC_CLANG)
-# if __has_extension(is_enum)
-# define Q_IS_ENUM(x) __is_enum(x)
-# endif
-# endif
-#endif
-
-#ifndef Q_IS_ENUM
-# include <QtCore/qtypetraits.h>
-# define Q_IS_ENUM(x) QtPrivate::is_enum<x>::value
-#endif
+// Use of Q_IS_ENUM is deprecated since 5.8
+#define Q_IS_ENUM(x) std::is_enum<x>::value
// shut up syncqt
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 1a7d64780f..1469f5776b 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -163,14 +163,14 @@ void QLibrarySettings::load()
QSettings *QLibraryInfoPrivate::findConfiguration()
{
- QString qtconfig = QStringLiteral(":/qt/etc/qt.conf");
- if (QFile::exists(qtconfig))
- return new QSettings(qtconfig, QSettings::IniFormat);
#ifdef QT_BUILD_QMAKE
- qtconfig = qmake_libraryInfoFile();
+ QString qtconfig = qmake_libraryInfoFile();
if (QFile::exists(qtconfig))
return new QSettings(qtconfig, QSettings::IniFormat);
#else
+ QString qtconfig = QStringLiteral(":/qt/etc/qt.conf");
+ if (QFile::exists(qtconfig))
+ return new QSettings(qtconfig, QSettings::IniFormat);
#ifdef Q_OS_DARWIN
CFBundleRef bundleRef = CFBundleGetMainBundle();
if (bundleRef) {
@@ -449,6 +449,8 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
{
#endif // QT_BUILD_QMAKE, started inside location !
QString ret;
+ bool fromConf = false;
+#ifndef QT_NO_SETTINGS
#ifdef QT_BUILD_QMAKE
// Logic for choosing the right data source: if EffectivePaths are requested
// and qt.conf with that section is present, use it, otherwise fall back to
@@ -457,40 +459,18 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
// EffectiveSourcePaths falls back to EffectivePaths.
// DevicePaths falls back to FinalPaths.
PathGroup orig_group = group;
- if (!QLibraryInfoPrivate::haveGroup(group)
- && !(group == EffectiveSourcePaths
- && (group = EffectivePaths, QLibraryInfoPrivate::haveGroup(group)))
- && !((group == EffectivePaths || group == DevicePaths)
- && (group = FinalPaths, QLibraryInfoPrivate::haveGroup(group)))
- && (group = orig_group, true))
-#elif !defined(QT_NO_SETTINGS)
- if (!QLibraryInfoPrivate::configuration())
+ if (QLibraryInfoPrivate::haveGroup(group)
+ || (group == EffectiveSourcePaths
+ && (group = EffectivePaths, QLibraryInfoPrivate::haveGroup(group)))
+ || ((group == EffectivePaths || group == DevicePaths)
+ && (group = FinalPaths, QLibraryInfoPrivate::haveGroup(group)))
+ || (group = orig_group, false))
+#else
+ if (QLibraryInfoPrivate::configuration())
#endif
{
- const char * volatile path = 0;
- if (loc == PrefixPath) {
- path =
-#ifdef QT_BUILD_QMAKE
- (group != DevicePaths) ?
- QT_CONFIGURE_EXT_PREFIX_PATH :
-#endif
- QT_CONFIGURE_PREFIX_PATH;
- } else if (unsigned(loc) <= sizeof(qt_configure_str_offsets)/sizeof(qt_configure_str_offsets[0])) {
- path = qt_configure_strs + qt_configure_str_offsets[loc - 1];
-#ifndef Q_OS_WIN // On Windows we use the registry
- } else if (loc == SettingsPath) {
- path = QT_CONFIGURE_SETTINGS_PATH;
-#endif
-#ifdef QT_BUILD_QMAKE
- } else if (loc == HostPrefixPath) {
- path = QT_CONFIGURE_HOST_PREFIX_PATH;
-#endif
- }
+ fromConf = true;
- if (path)
- ret = QString::fromLocal8Bit(path);
-#ifndef QT_NO_SETTINGS
- } else {
QString key;
QString defaultValue;
if (unsigned(loc) < sizeof(qtConfEntries)/sizeof(qtConfEntries[0])) {
@@ -522,7 +502,9 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
ret = config->value(QLatin1String(qtConfEntries[PrefixPath].key),
QLatin1String(qtConfEntries[PrefixPath].value)).toString();
else if (loc == TargetSpecPath || loc == HostSpecPath)
- ret = QString::fromLocal8Bit(qt_configure_strs + qt_configure_str_offsets[loc - 1]);
+ fromConf = false;
+ // The last case here is SysrootPath, which can be legitimately empty.
+ // All other keys have non-empty fallbacks to start with.
}
#endif
@@ -540,7 +522,32 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
ret = QDir::fromNativeSeparators(ret);
}
+ }
#endif // QT_NO_SETTINGS
+
+ if (!fromConf) {
+ const char * volatile path = 0;
+ if (loc == PrefixPath) {
+ path =
+#ifdef QT_BUILD_QMAKE
+ (group != DevicePaths) ?
+ QT_CONFIGURE_EXT_PREFIX_PATH :
+#endif
+ QT_CONFIGURE_PREFIX_PATH;
+ } else if (unsigned(loc) <= sizeof(qt_configure_str_offsets)/sizeof(qt_configure_str_offsets[0])) {
+ path = qt_configure_strs + qt_configure_str_offsets[loc - 1];
+#ifndef Q_OS_WIN // On Windows we use the registry
+ } else if (loc == SettingsPath) {
+ path = QT_CONFIGURE_SETTINGS_PATH;
+#endif
+#ifdef QT_BUILD_QMAKE
+ } else if (loc == HostPrefixPath) {
+ path = QT_CONFIGURE_HOST_PREFIX_PATH;
+#endif
+ }
+
+ if (path)
+ ret = QString::fromLocal8Bit(path);
}
#ifdef QT_BUILD_QMAKE
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index e2b0d30db0..a30344995e 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -1679,6 +1679,7 @@ public:
QT_Q_ENUM(Orientation)
QT_Q_ENUM(DropAction)
QT_Q_FLAG(Alignment)
+ QT_Q_ENUM(TextFlag)
QT_Q_FLAG(Orientations)
QT_Q_FLAG(DropActions)
QT_Q_FLAG(Edges)
diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h
index ef40a45dc4..23fcf340f1 100644
--- a/src/corelib/global/qnumeric_p.h
+++ b/src/corelib/global/qnumeric_p.h
@@ -172,7 +172,7 @@ static inline bool qt_is_finite(float f)
// Unsigned overflow math
//
namespace {
-template <typename T> inline typename QtPrivate::QEnableIf<QtPrivate::is_unsigned<T>::value, bool>::Type
+template <typename T> inline typename QtPrivate::QEnableIf<std::is_unsigned<T>::value, bool>::Type
add_overflow(T v1, T v2, T *r)
{
// unsigned additions are well-defined
@@ -180,7 +180,7 @@ add_overflow(T v1, T v2, T *r)
return v1 > T(v1 + v2);
}
-template <typename T> inline typename QtPrivate::QEnableIf<QtPrivate::is_unsigned<T>::value, bool>::Type
+template <typename T> inline typename QtPrivate::QEnableIf<std::is_unsigned<T>::value, bool>::Type
mul_overflow(T v1, T v2, T *r)
{
// use the next biggest type
diff --git a/src/corelib/global/qt_windows.h b/src/corelib/global/qt_windows.h
index 7b95501c08..bc48104edc 100644
--- a/src/corelib/global/qt_windows.h
+++ b/src/corelib/global/qt_windows.h
@@ -53,6 +53,9 @@
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x600
# endif
+# ifndef NTDDI_VERSION
+# define NTDDI_VERSION 0x06000000
+# endif
#endif
#ifndef NOMINMAX
diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h
index e709050011..8aa5cb4fb4 100644
--- a/src/corelib/global/qtypeinfo.h
+++ b/src/corelib/global/qtypeinfo.h
@@ -38,8 +38,7 @@
**
****************************************************************************/
-#include <QtCore/qtypetraits.h>
-#include <QtCore/qisenum.h>
+#include <QtCore/qglobal.h>
#ifndef QTYPEINFO_H
#define QTYPEINFO_H
@@ -60,10 +59,10 @@ class QTypeInfo
public:
enum {
isPointer = false,
- isIntegral = QtPrivate::is_integral<T>::value,
+ isIntegral = std::is_integral<T>::value,
isComplex = true,
isStatic = true,
- isRelocatable = Q_IS_ENUM(T),
+ isRelocatable = std::is_enum<T>::value,
isLarge = (sizeof(T)>sizeof(void*)),
isDummy = false, //### Qt6: remove
sizeOf = sizeof(T)
@@ -247,7 +246,7 @@ public: \
isRelocatable = !isStatic || ((FLAGS) & Q_RELOCATABLE_TYPE), \
isLarge = (sizeof(TYPE)>sizeof(void*)), \
isPointer = false, \
- isIntegral = QtPrivate::is_integral< TYPE >::value, \
+ isIntegral = std::is_integral< TYPE >::value, \
isDummy = (((FLAGS) & Q_DUMMY_TYPE) != 0), \
sizeOf = sizeof(TYPE) \
}; \
diff --git a/src/corelib/global/qtypetraits.h b/src/corelib/global/qtypetraits.h
index c311303e27..9773db919b 100644
--- a/src/corelib/global/qtypetraits.h
+++ b/src/corelib/global/qtypetraits.h
@@ -37,501 +37,58 @@
**
****************************************************************************/
-// BEGIN Google Code
-
-// Copyright (c) 2006, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// ----
-//
-// This code is compiled directly on many platforms, including client
-// platforms like Windows, Mac, and embedded systems. Before making
-// any changes here, make sure that you're not breaking any platforms.
-//
-// Define a small subset of tr1 type traits. The traits we define are:
-// is_integral
-// is_floating_point
-// is_pointer
-// is_enum
-// is_reference
-// is_const
-// is_volatile
-// is_pod
-// has_trivial_constructor
-// has_trivial_copy
-// has_trivial_assign
-// has_trivial_destructor
-// is_signed
-// is_unsigned
-// remove_const
-// remove_volatile
-// remove_cv
-// remove_reference
-// add_reference
-// remove_pointer
-// is_same
-// is_convertible
-// We can add more type traits as required.
-
-// Changes from the original implementation:
-// - Move base types from template_util.h directly into this header.
-// - Use Qt macros for long long type differences on Windows.
-// - Enclose in QtPrivate namespace.
-
#include "QtCore/qglobal.h"
#ifndef QTYPETRAITS_H
#define QTYPETRAITS_H
-#include <utility> // For pair
-
QT_BEGIN_NAMESPACE
namespace QtPrivate {
-// Types small_ and big_ are guaranteed such that sizeof(small_) <
-// sizeof(big_)
-typedef char small_;
-
-struct big_ {
- char dummy[2];
-};
-
-// Identity metafunction.
-template <class T>
-struct identity_ {
- typedef T type;
-};
-
-// integral_constant, defined in tr1, is a wrapper for an integer
-// value. We don't really need this generality; we could get away
-// with hardcoding the integer type to bool. We use the fully
-// general integer_constant for compatibility with tr1.
-
-template<class T, T v>
-struct integral_constant {
- static const T value = v;
- typedef T value_type;
- typedef integral_constant<T, v> type;
-};
-
-template <class T, T v> const T integral_constant<T, v>::value;
-
-
-// Abbreviations: true_type and false_type are structs that represent boolean
-// true and false values. Also define the boost::mpl versions of those names,
-// true_ and false_.
-typedef integral_constant<bool, true> true_type;
-typedef integral_constant<bool, false> false_type;
-typedef true_type true_;
-typedef false_type false_;
-
-// if_ is a templatized conditional statement.
-// if_<cond, A, B> is a compile time evaluation of cond.
-// if_<>::type contains A if cond is true, B otherwise.
-template<bool cond, typename A, typename B>
-struct if_{
- typedef A type;
-};
-
-template<typename A, typename B>
-struct if_<false, A, B> {
- typedef B type;
-};
-
-
-// type_equals_ is a template type comparator, similar to Loki IsSameType.
-// type_equals_<A, B>::value is true iff "A" is the same type as "B".
//
-// New code should prefer base::is_same, defined in base/type_traits.h.
-// It is functionally identical, but is_same is the standard spelling.
-template<typename A, typename B>
-struct type_equals_ : public false_ {
-};
-
-template<typename A>
-struct type_equals_<A, A> : public true_ {
-};
-
-// and_ is a template && operator.
-// and_<A, B>::value evaluates "A::value && B::value".
-template<typename A, typename B>
-struct and_ : public integral_constant<bool, (A::value && B::value)> {
-};
-
-// or_ is a template || operator.
-// or_<A, B>::value evaluates "A::value || B::value".
-template<typename A, typename B>
-struct or_ : public integral_constant<bool, (A::value || B::value)> {
-};
-
-template <class T> struct is_integral;
-template <class T> struct is_floating_point;
-template <class T> struct is_pointer;
-// MSVC can't compile this correctly, and neither can gcc 3.3.5 (at least)
-#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
-// is_enum uses is_convertible, which is not available on MSVC.
-template <class T> struct is_enum;
-#endif
-template <class T> struct is_reference;
-template <class T> struct is_pod;
-template <class T> struct has_trivial_constructor;
-template <class T> struct has_trivial_copy;
-template <class T> struct has_trivial_assign;
-template <class T> struct has_trivial_destructor;
-template <class T> struct remove_const;
-template <class T> struct remove_volatile;
-template <class T> struct remove_cv;
-template <class T> struct remove_reference;
-template <class T> struct add_reference;
-template <class T> struct remove_pointer;
-template <class T, class U> struct is_same;
-#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
-template <class From, class To> struct is_convertible;
-#endif
-
-// is_integral is false except for the built-in integer types. A
-// cv-qualified type is integral if and only if the underlying type is.
-template <class T> struct is_integral : false_type { };
-template<> struct is_integral<bool> : true_type { };
-template<> struct is_integral<char> : true_type { };
-template<> struct is_integral<unsigned char> : true_type { };
-template<> struct is_integral<signed char> : true_type { };
-#if defined(_MSC_VER)
-// wchar_t is not by default a distinct type from unsigned short in
-// Microsoft C.
-// See http://msdn2.microsoft.com/en-us/library/dh8che7s(VS.80).aspx
-template<> struct is_integral<__wchar_t> : true_type { };
-#else
-template<> struct is_integral<wchar_t> : true_type { };
-#endif
-template<> struct is_integral<short> : true_type { };
-template<> struct is_integral<unsigned short> : true_type { };
-template<> struct is_integral<int> : true_type { };
-template<> struct is_integral<unsigned int> : true_type { };
-template<> struct is_integral<long> : true_type { };
-template<> struct is_integral<unsigned long> : true_type { };
-#if defined(Q_OS_WIN) && !defined(Q_CC_GNU)
-template<> struct is_integral<__int64> : true_type { };
-template<> struct is_integral<unsigned __int64> : true_type { };
-#else
-template<> struct is_integral<long long> : true_type { };
-template<> struct is_integral<unsigned long long> : true_type { };
-#endif
-template <class T> struct is_integral<const T> : is_integral<T> { };
-template <class T> struct is_integral<volatile T> : is_integral<T> { };
-template <class T> struct is_integral<const volatile T> : is_integral<T> { };
-#if defined (Q_COMPILER_UNICODE_STRINGS)
-template<> struct is_integral<char16_t> : true_type { };
-template<> struct is_integral<char32_t> : true_type { };
-#endif
-
-// is_floating_point is false except for the built-in floating-point types.
-// A cv-qualified type is integral if and only if the underlying type is.
-template <class T> struct is_floating_point : false_type { };
-template<> struct is_floating_point<float> : true_type { };
-template<> struct is_floating_point<double> : true_type { };
-template<> struct is_floating_point<long double> : true_type { };
-template <class T> struct is_floating_point<const T>
- : is_floating_point<T> { };
-template <class T> struct is_floating_point<volatile T>
- : is_floating_point<T> { };
-template <class T> struct is_floating_point<const volatile T>
- : is_floating_point<T> { };
-
-// is_pointer is false except for pointer types. A cv-qualified type (e.g.
-// "int* const", as opposed to "int const*") is cv-qualified if and only if
-// the underlying type is.
-template <class T> struct is_pointer : false_type { };
-template <class T> struct is_pointer<T*> : true_type { };
-template <class T> struct is_pointer<const T> : is_pointer<T> { };
-template <class T> struct is_pointer<volatile T> : is_pointer<T> { };
-template <class T> struct is_pointer<const volatile T> : is_pointer<T> { };
-
-#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
-
-namespace internal {
-
-template <class T> struct is_class_or_union {
- template <class U> static small_ tester(void (U::*)());
- template <class U> static big_ tester(...);
- static const bool value = sizeof(tester<T>(0)) == sizeof(small_);
-};
-
-// is_convertible chokes if the first argument is an array. That's why
-// we use add_reference here.
-template <bool NotUnum, class T> struct is_enum_impl
- : is_convertible<typename add_reference<T>::type, int> { };
-
-template <class T> struct is_enum_impl<true, T> : false_type { };
-
-} // namespace internal
-
-// Specified by TR1 [4.5.1] primary type categories.
-
-// Implementation note:
+// Define QIsUnsignedEnum, QIsSignedEnum -
+// std::is_signed, std::is_unsigned does not work for enum's
//
-// Each type is either void, integral, floating point, array, pointer,
-// reference, member object pointer, member function pointer, enum,
-// union or class. Out of these, only integral, floating point, reference,
-// class and enum types are potentially convertible to int. Therefore,
-// if a type is not a reference, integral, floating point or class and
-// is convertible to int, it's a enum. Adding cv-qualification to a type
-// does not change whether it's an enum.
-//
-// Is-convertible-to-int check is done only if all other checks pass,
-// because it can't be used with some types (e.g. void or classes with
-// inaccessible conversion operators).
-template <class T> struct is_enum
- : internal::is_enum_impl<
- is_same<T, void>::value ||
- is_integral<T>::value ||
- is_floating_point<T>::value ||
- is_reference<T>::value ||
- internal::is_class_or_union<T>::value,
- T> { };
-
-template <class T> struct is_enum<const T> : is_enum<T> { };
-template <class T> struct is_enum<volatile T> : is_enum<T> { };
-template <class T> struct is_enum<const volatile T> : is_enum<T> { };
-
-#endif
-
-// is_reference is false except for reference types.
-template<typename T> struct is_reference : false_type {};
-template<typename T> struct is_reference<T&> : true_type {};
-
-// Specified by TR1 [4.5.3] Type Properties
-template <typename T> struct is_const : false_type {};
-template <typename T> struct is_const<const T> : true_type {};
-template <typename T> struct is_volatile : false_type {};
-template <typename T> struct is_volatile<volatile T> : true_type {};
-
-// We can't get is_pod right without compiler help, so fail conservatively.
-// We will assume it's false except for arithmetic types, enumerations,
-// pointers and cv-qualified versions thereof. Note that std::pair<T,U>
-// is not a POD even if T and U are PODs.
-template <class T> struct is_pod
- : integral_constant<bool, (is_integral<T>::value ||
- is_floating_point<T>::value ||
-#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
- // is_enum is not available on MSVC.
- is_enum<T>::value ||
-#endif
- is_pointer<T>::value)> { };
-template <class T> struct is_pod<const T> : is_pod<T> { };
-template <class T> struct is_pod<volatile T> : is_pod<T> { };
-template <class T> struct is_pod<const volatile T> : is_pod<T> { };
-
-
-// We can't get has_trivial_constructor right without compiler help, so
-// fail conservatively. We will assume it's false except for: (1) types
-// for which is_pod is true. (2) std::pair of types with trivial
-// constructors. (3) array of a type with a trivial constructor.
-// (4) const versions thereof.
-template <class T> struct has_trivial_constructor : is_pod<T> { };
-template <class T, class U> struct has_trivial_constructor<std::pair<T, U> >
- : integral_constant<bool,
- (has_trivial_constructor<T>::value &&
- has_trivial_constructor<U>::value)> { };
-template <class A, int N> struct has_trivial_constructor<A[N]>
- : has_trivial_constructor<A> { };
-template <class T> struct has_trivial_constructor<const T>
- : has_trivial_constructor<T> { };
-
-// We can't get has_trivial_copy right without compiler help, so fail
-// conservatively. We will assume it's false except for: (1) types
-// for which is_pod is true. (2) std::pair of types with trivial copy
-// constructors. (3) array of a type with a trivial copy constructor.
-// (4) const versions thereof.
-template <class T> struct has_trivial_copy : is_pod<T> { };
-template <class T, class U> struct has_trivial_copy<std::pair<T, U> >
- : integral_constant<bool,
- (has_trivial_copy<T>::value &&
- has_trivial_copy<U>::value)> { };
-template <class A, int N> struct has_trivial_copy<A[N]>
- : has_trivial_copy<A> { };
-template <class T> struct has_trivial_copy<const T> : has_trivial_copy<T> { };
-
-// We can't get has_trivial_assign right without compiler help, so fail
-// conservatively. We will assume it's false except for: (1) types
-// for which is_pod is true. (2) std::pair of types with trivial copy
-// constructors. (3) array of a type with a trivial assign constructor.
-template <class T> struct has_trivial_assign : is_pod<T> { };
-template <class T, class U> struct has_trivial_assign<std::pair<T, U> >
- : integral_constant<bool,
- (has_trivial_assign<T>::value &&
- has_trivial_assign<U>::value)> { };
-template <class A, int N> struct has_trivial_assign<A[N]>
- : has_trivial_assign<A> { };
-
-// We can't get has_trivial_destructor right without compiler help, so
-// fail conservatively. We will assume it's false except for: (1) types
-// for which is_pod is true. (2) std::pair of types with trivial
-// destructors. (3) array of a type with a trivial destructor.
-// (4) const versions thereof.
-template <class T> struct has_trivial_destructor : is_pod<T> { };
-template <class T, class U> struct has_trivial_destructor<std::pair<T, U> >
- : integral_constant<bool,
- (has_trivial_destructor<T>::value &&
- has_trivial_destructor<U>::value)> { };
-template <class A, int N> struct has_trivial_destructor<A[N]>
- : has_trivial_destructor<A> { };
-template <class T> struct has_trivial_destructor<const T>
- : has_trivial_destructor<T> { };
-
-// Specified by TR1 [4.7.1]
-template<typename T> struct remove_const { typedef T type; };
-template<typename T> struct remove_const<T const> { typedef T type; };
-template<typename T> struct remove_volatile { typedef T type; };
-template<typename T> struct remove_volatile<T volatile> { typedef T type; };
-template<typename T> struct remove_cv {
- typedef typename remove_const<typename remove_volatile<T>::type>::type type;
-};
-
-
-// Specified by TR1 [4.7.2] Reference modifications.
-template<typename T> struct remove_reference { typedef T type; };
-template<typename T> struct remove_reference<T&> { typedef T type; };
-
-template <typename T> struct add_reference { typedef T& type; };
-template <typename T> struct add_reference<T&> { typedef T& type; };
-
-// Specified by TR1 [4.7.4] Pointer modifications.
-template<typename T> struct remove_pointer { typedef T type; };
-template<typename T> struct remove_pointer<T*> { typedef T type; };
-template<typename T> struct remove_pointer<T* const> { typedef T type; };
-template<typename T> struct remove_pointer<T* volatile> { typedef T type; };
-template<typename T> struct remove_pointer<T* const volatile> {
- typedef T type; };
-
-// Specified by TR1 [4.6] Relationships between types
-template<typename T, typename U> struct is_same : public false_type { };
-template<typename T> struct is_same<T, T> : public true_type { };
-
-// Specified by TR1 [4.6] Relationships between types
-#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
-namespace internal {
-
-// This class is an implementation detail for is_convertible, and you
-// don't need to know how it works to use is_convertible. For those
-// who care: we declare two different functions, one whose argument is
-// of type To and one with a variadic argument list. We give them
-// return types of different size, so we can use sizeof to trick the
-// compiler into telling us which function it would have chosen if we
-// had called it with an argument of type From. See Alexandrescu's
-// _Modern C++ Design_ for more details on this sort of trick.
-
-template <typename From, typename To>
-struct ConvertHelper {
- static small_ Test(To);
- static big_ Test(...);
- static From Create();
-};
-} // namespace internal
-
-// Inherits from true_type if From is convertible to To, false_type otherwise.
-template <typename From, typename To>
-struct is_convertible
- : integral_constant<bool,
- sizeof(internal::ConvertHelper<From, To>::Test(
- internal::ConvertHelper<From, To>::Create()))
- == sizeof(small_)> {
-};
-#endif
-
-// END Google Code
// a metafunction to invert an integral_constant:
template <typename T>
struct not_
- : integral_constant<bool, !T::value> {};
-
-// same, with a bool argument:
-template <bool B>
-struct not_c
- : integral_constant<bool, !B> {};
+ : std::integral_constant<bool, !T::value> {};
// Checks whether a type is unsigned (T must be convertible to unsigned int):
template <typename T>
-struct is_unsigned
- : integral_constant<bool, (T(0) < T(-1))> {};
+struct QIsUnsignedEnum
+ : std::integral_constant<bool, (T(0) < T(-1))> {};
// Checks whether a type is signed (T must be convertible to int):
template <typename T>
-struct is_signed
- : not_< is_unsigned<T> > {};
-
-Q_STATIC_ASSERT(( is_unsigned<quint8>::value));
-Q_STATIC_ASSERT((!is_unsigned<qint8>::value));
-
-Q_STATIC_ASSERT((!is_signed<quint8>::value));
-Q_STATIC_ASSERT(( is_signed<qint8>::value));
-
-Q_STATIC_ASSERT(( is_unsigned<quint16>::value));
-Q_STATIC_ASSERT((!is_unsigned<qint16>::value));
-
-Q_STATIC_ASSERT((!is_signed<quint16>::value));
-Q_STATIC_ASSERT(( is_signed<qint16>::value));
+struct QIsSignedEnum
+ : not_< QIsUnsignedEnum<T> > {};
-Q_STATIC_ASSERT(( is_unsigned<quint32>::value));
-Q_STATIC_ASSERT((!is_unsigned<qint32>::value));
+Q_STATIC_ASSERT(( QIsUnsignedEnum<quint8>::value));
+Q_STATIC_ASSERT((!QIsUnsignedEnum<qint8>::value));
-Q_STATIC_ASSERT((!is_signed<quint32>::value));
-Q_STATIC_ASSERT(( is_signed<qint32>::value));
+Q_STATIC_ASSERT((!QIsSignedEnum<quint8>::value));
+Q_STATIC_ASSERT(( QIsSignedEnum<qint8>::value));
-Q_STATIC_ASSERT(( is_unsigned<quint64>::value));
-Q_STATIC_ASSERT((!is_unsigned<qint64>::value));
+Q_STATIC_ASSERT(( QIsUnsignedEnum<quint16>::value));
+Q_STATIC_ASSERT((!QIsUnsignedEnum<qint16>::value));
-Q_STATIC_ASSERT((!is_signed<quint64>::value));
-Q_STATIC_ASSERT(( is_signed<qint64>::value));
+Q_STATIC_ASSERT((!QIsSignedEnum<quint16>::value));
+Q_STATIC_ASSERT(( QIsSignedEnum<qint16>::value));
-template<class T = void> struct is_default_constructible;
+Q_STATIC_ASSERT(( QIsUnsignedEnum<quint32>::value));
+Q_STATIC_ASSERT((!QIsUnsignedEnum<qint32>::value));
-template<> struct is_default_constructible<void>
-{
-protected:
- template<bool> struct test { typedef char type; };
-public:
- static bool const value = false;
-};
-template<> struct is_default_constructible<>::test<true> { typedef double type; };
+Q_STATIC_ASSERT((!QIsSignedEnum<quint32>::value));
+Q_STATIC_ASSERT(( QIsSignedEnum<qint32>::value));
-template<class T> struct is_default_constructible : is_default_constructible<>
-{
-private:
- template<class U> static typename test<!!sizeof(::new U())>::type sfinae(U*);
- template<class U> static char sfinae(...);
-public:
- static bool const value = sizeof(sfinae<T>(0)) > 1;
-};
+Q_STATIC_ASSERT(( QIsUnsignedEnum<quint64>::value));
+Q_STATIC_ASSERT((!QIsUnsignedEnum<qint64>::value));
+Q_STATIC_ASSERT((!QIsSignedEnum<quint64>::value));
+Q_STATIC_ASSERT(( QIsSignedEnum<qint64>::value));
} // namespace QtPrivate
diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp
index 6424012a9a..ccbcdb1037 100644
--- a/src/corelib/io/qfilesystemengine.cpp
+++ b/src/corelib/io/qfilesystemengine.cpp
@@ -222,7 +222,7 @@ bool QFileSystemEngine::fillMetaData(int fd, QFileSystemMetaData &data)
return false;
}
-#if defined(QT_EXT_QNX_READDIR_R)
+#if defined(_DEXTRA_FIRST)
static void fillStat64fromStat32(struct stat64 *statBuf64, const struct stat &statBuf32)
{
statBuf64->st_mode = statBuf32.st_mode;
@@ -308,7 +308,7 @@ void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer)
void QFileSystemMetaData::fillFromDirEnt(const QT_DIRENT &entry)
{
-#if defined(QT_EXT_QNX_READDIR_R)
+#if defined(_DEXTRA_FIRST)
knownFlagsMask = 0;
entryFlags = 0;
for (dirent_extra *extra = _DEXTRA_FIRST(&entry); _DEXTRA_VALID(extra, &entry);
diff --git a/src/corelib/io/qfilesystemiterator_p.h b/src/corelib/io/qfilesystemiterator_p.h
index 16830257e1..081487e66e 100644
--- a/src/corelib/io/qfilesystemiterator_p.h
+++ b/src/corelib/io/qfilesystemiterator_p.h
@@ -93,14 +93,6 @@ private:
#else
QT_DIR *dir;
QT_DIRENT *dirEntry;
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) || defined(QT_EXT_QNX_READDIR_R)
- // for readdir_r
- QScopedPointer<QT_DIRENT, QScopedPointerPodDeleter> mt_file;
-#if defined(QT_EXT_QNX_READDIR_R)
- // for _readdir_r
- size_t direntSize;
-#endif
-#endif
int lastError;
#endif
diff --git a/src/corelib/io/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp
index d7b21fac32..0d1438f137 100644
--- a/src/corelib/io/qfilesystemiterator_unix.cpp
+++ b/src/corelib/io/qfilesystemiterator_unix.cpp
@@ -52,9 +52,6 @@ QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Fi
: nativePath(entry.nativeFilePath())
, dir(0)
, dirEntry(0)
-#if defined(Q_OS_QNX) && defined(__EXT_QNX__READDIR_R)
- , direntSize(0)
-#endif
, lastError(0)
{
Q_UNUSED(filters)
@@ -64,32 +61,8 @@ QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Fi
if ((dir = QT_OPENDIR(nativePath.constData())) == 0) {
lastError = errno;
} else {
-
if (!nativePath.endsWith('/'))
nativePath.append('/');
-
-#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) || defined(QT_EXT_QNX_READDIR_R)
- // ### Race condition; we should use fpathconf and dirfd().
- size_t maxPathName = ::pathconf(nativePath.constData(), _PC_NAME_MAX);
- if (maxPathName == size_t(-1))
- maxPathName = FILENAME_MAX;
- maxPathName += sizeof(QT_DIRENT) + 1;
-
- QT_DIRENT *p = reinterpret_cast<QT_DIRENT*>(::malloc(maxPathName));
- Q_CHECK_PTR(p);
-
- mt_file.reset(p);
-#if defined(QT_EXT_QNX_READDIR_R)
- direntSize = maxPathName;
-
- // Include extra stat information in the readdir() call (d_stat member of
- // dirent_extra_stat). This is used in QFileSystemMetaData::fillFromDirEnt() to
- // avoid extra stat() calls when iterating over directories
- int flags = dircntl(dir, D_GETFLAG) | D_FLAG_STAT | D_FLAG_FILTER;
- if (dircntl(dir, D_SETFLAG, flags) == -1)
- lastError = errno;
-#endif
-#endif
}
}
@@ -104,18 +77,7 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa
if (!dir)
return false;
-#if defined(QT_EXT_QNX_READDIR_R)
- lastError = QT_EXT_QNX_READDIR_R(dir, mt_file.data(), &dirEntry, direntSize);
- if (lastError)
- return false;
-#elif defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN)
- lastError = QT_READDIR_R(dir, mt_file.data(), &dirEntry);
- if (lastError)
- return false;
-#else
- // ### add local lock to prevent breaking reentrancy
dirEntry = QT_READDIR(dir);
-#endif // _POSIX_THREAD_SAFE_FUNCTIONS
if (dirEntry) {
fileEntry = QFileSystemEntry(nativePath + QByteArray(dirEntry->d_name), QFileSystemEntry::FromNativePath());
diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp
index 38c63553ea..a64bde6fb4 100644
--- a/src/corelib/io/qstandardpaths_win.cpp
+++ b/src/corelib/io/qstandardpaths_win.cpp
@@ -47,17 +47,10 @@
#include <qcoreapplication.h>
#endif
-const GUID qCLSID_FOLDERID_Downloads = { 0x374de290, 0x123f, 0x4565, { 0x91, 0x64, 0x39, 0xc4, 0x92, 0x5e, 0x46, 0x7b } };
-
#include <qt_windows.h>
#include <shlobj.h>
#include <intshcut.h>
-#ifndef CSIDL_MYMUSIC
-#define CSIDL_MYMUSIC 13
-#define CSIDL_MYVIDEO 14
-#endif
-
#ifndef QT_NO_STANDARDPATHS
QT_BEGIN_NAMESPACE
@@ -108,47 +101,31 @@ static inline void appendTestMode(QString &path)
path += QLatin1String("/qttest");
}
-// Map QStandardPaths::StandardLocation to CLSID of SHGetSpecialFolderPath()
-static int writableSpecialFolderClsid(QStandardPaths::StandardLocation type)
+// Map QStandardPaths::StandardLocation to KNOWNFOLDERID of SHGetKnownFolderPath()
+static GUID writableSpecialFolderId(QStandardPaths::StandardLocation type)
{
- static const int clsids[] = {
- CSIDL_DESKTOPDIRECTORY, // DesktopLocation
- CSIDL_PERSONAL, // DocumentsLocation
- CSIDL_FONTS, // FontsLocation
- CSIDL_PROGRAMS, // ApplicationsLocation
- CSIDL_MYMUSIC, // MusicLocation
- CSIDL_MYVIDEO, // MoviesLocation
- CSIDL_MYPICTURES, // PicturesLocation
- -1, -1, // TempLocation/HomeLocation
- CSIDL_LOCAL_APPDATA, // AppLocalDataLocation ("Local" path), AppLocalDataLocation = DataLocation
- -1, // CacheLocation
- CSIDL_LOCAL_APPDATA, // GenericDataLocation ("Local" path)
- -1, // RuntimeLocation
- CSIDL_LOCAL_APPDATA, // ConfigLocation ("Local" path)
- -1, -1, // DownloadLocation/GenericCacheLocation
- CSIDL_LOCAL_APPDATA, // GenericConfigLocation ("Local" path)
- CSIDL_APPDATA, // AppDataLocation ("Roaming" path)
- CSIDL_LOCAL_APPDATA, // AppConfigLocation ("Local" path)
+ static const GUID folderIds[] = {
+ FOLDERID_Desktop, // DesktopLocation
+ FOLDERID_Documents, // DocumentsLocation
+ FOLDERID_Fonts, // FontsLocation
+ FOLDERID_Programs, // ApplicationsLocation
+ FOLDERID_Music, // MusicLocation
+ FOLDERID_Videos, // MoviesLocation
+ FOLDERID_Pictures, // PicturesLocation
+ GUID(), GUID(), // TempLocation/HomeLocation
+ FOLDERID_LocalAppData, // AppLocalDataLocation ("Local" path), AppLocalDataLocation = DataLocation
+ GUID(), // CacheLocation
+ FOLDERID_LocalAppData, // GenericDataLocation ("Local" path)
+ GUID(), // RuntimeLocation
+ FOLDERID_LocalAppData, // ConfigLocation ("Local" path)
+ GUID(), GUID(), // DownloadLocation/GenericCacheLocation
+ FOLDERID_LocalAppData, // GenericConfigLocation ("Local" path)
+ FOLDERID_RoamingAppData,// AppDataLocation ("Roaming" path)
+ FOLDERID_LocalAppData, // AppConfigLocation ("Local" path)
};
- Q_STATIC_ASSERT(sizeof(clsids) / sizeof(clsids[0]) == size_t(QStandardPaths::AppConfigLocation + 1));
- return size_t(type) < sizeof(clsids) / sizeof(clsids[0]) ? clsids[type] : -1;
-};
-
-// Convenience for SHGetSpecialFolderPath().
-static QString sHGetSpecialFolderPath(int clsid, QStandardPaths::StandardLocation type, bool warn = false)
-{
- QString result;
- wchar_t path[MAX_PATH];
- if (Q_LIKELY(clsid >= 0 && SHGetSpecialFolderPath(0, path, clsid, FALSE))) {
- result = convertCharArray(path);
- } else {
- if (warn) {
- qErrnoWarning("SHGetSpecialFolderPath() failed for standard location \"%s\", clsid=0x%x.",
- qPrintable(displayName(type)), clsid);
- }
- }
- return result;
+ Q_STATIC_ASSERT(sizeof(folderIds) / sizeof(folderIds[0]) == size_t(QStandardPaths::AppConfigLocation + 1));
+ return size_t(type) < sizeof(folderIds) / sizeof(folderIds[0]) ? folderIds[type] : GUID();
}
// Convenience for SHGetKnownFolderPath().
@@ -161,7 +138,7 @@ static QString sHGetKnownFolderPath(const GUID &clsid, QStandardPaths::StandardL
reinterpret_cast<GetKnownFolderPath>(QSystemLibrary::resolve(QLatin1String("shell32"), "SHGetKnownFolderPath"));
LPWSTR path;
- if (Q_LIKELY(sHGetKnownFolderPath && SUCCEEDED(sHGetKnownFolderPath(clsid, 0, 0, &path)))) {
+ if (Q_LIKELY(sHGetKnownFolderPath && SUCCEEDED(sHGetKnownFolderPath(clsid, KF_FLAG_DONT_VERIFY, 0, &path)))) {
result = convertCharArray(path);
CoTaskMemFree(path);
} else {
@@ -178,7 +155,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
QString result;
switch (type) {
case DownloadLocation:
- result = sHGetKnownFolderPath(qCLSID_FOLDERID_Downloads, type);
+ result = sHGetKnownFolderPath(FOLDERID_Downloads, type);
if (result.isEmpty())
result = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
break;
@@ -187,7 +164,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
// Although Microsoft has a Cache key it is a pointer to IE's cache, not a cache
// location for everyone. Most applications seem to be using a
// cache directory located in their AppData directory
- result = sHGetSpecialFolderPath(writableSpecialFolderClsid(AppLocalDataLocation), type, /* warn */ true);
+ result = sHGetKnownFolderPath(writableSpecialFolderId(AppLocalDataLocation), type, /* warn */ true);
if (!result.isEmpty()) {
appendTestMode(result);
appendOrganizationAndApp(result);
@@ -196,7 +173,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
break;
case GenericCacheLocation:
- result = sHGetSpecialFolderPath(writableSpecialFolderClsid(GenericDataLocation), type, /* warn */ true);
+ result = sHGetKnownFolderPath(writableSpecialFolderId(GenericDataLocation), type, /* warn */ true);
if (!result.isEmpty()) {
appendTestMode(result);
result += QLatin1String("/cache");
@@ -213,7 +190,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
break;
default:
- result = sHGetSpecialFolderPath(writableSpecialFolderClsid(type), type, /* warn */ isConfigLocation(type));
+ result = sHGetKnownFolderPath(writableSpecialFolderId(type), type, /* warn */ isConfigLocation(type));
if (!result.isEmpty() && isConfigLocation(type)) {
appendTestMode(result);
if (!isGenericConfigLocation(type))
@@ -233,7 +210,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
// type-specific handling goes here
if (isConfigLocation(type)) {
- QString programData = sHGetSpecialFolderPath(CSIDL_COMMON_APPDATA, type);
+ QString programData = sHGetKnownFolderPath(FOLDERID_ProgramData, type);
if (!programData.isEmpty()) {
if (!isGenericConfigLocation(type))
appendOrganizationAndApp(programData);
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index b7762c2ae6..5b34813a71 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -410,7 +410,9 @@
#include "qhash.h"
#include "qdir.h" // for QDir::fromNativeSeparators
#include "qdatastream.h"
+#if QT_CONFIG(topleveldomain)
#include "qtldurl_p.h"
+#endif
#include "private/qipaddress_p.h"
#include "qurlquery.h"
diff --git a/src/corelib/json/qjson.cpp b/src/corelib/json/qjson.cpp
index e9a1366af0..d509349a51 100644
--- a/src/corelib/json/qjson.cpp
+++ b/src/corelib/json/qjson.cpp
@@ -135,10 +135,12 @@ bool Data::valid() const
return false;
bool res = false;
- if (header->root()->is_object)
- res = static_cast<Object *>(header->root())->isValid();
+ Base *root = header->root();
+ int maxSize = alloc - sizeof(Header);
+ if (root->is_object)
+ res = static_cast<Object *>(root)->isValid(maxSize);
else
- res = static_cast<Array *>(header->root())->isValid();
+ res = static_cast<Array *>(root)->isValid(maxSize);
return res;
}
@@ -223,9 +225,9 @@ int Object::indexOf(QLatin1String key, bool *exists) const
return min;
}
-bool Object::isValid() const
+bool Object::isValid(int maxSize) const
{
- if (tableOffset + length*sizeof(offset) > size)
+ if (size > (uint)maxSize || tableOffset + length*sizeof(offset) > size)
return false;
QString lastKey;
@@ -234,8 +236,7 @@ bool Object::isValid() const
if (entryOffset + sizeof(Entry) >= tableOffset)
return false;
Entry *e = entryAt(i);
- int s = e->size();
- if (table()[i] + s > tableOffset)
+ if (!e->isValid(tableOffset - table()[i]))
return false;
QString key = e->key();
if (key < lastKey)
@@ -249,9 +250,9 @@ bool Object::isValid() const
-bool Array::isValid() const
+bool Array::isValid(int maxSize) const
{
- if (tableOffset + length*sizeof(offset) > size)
+ if (size > (uint)maxSize || tableOffset + length*sizeof(offset) > size)
return false;
for (uint i = 0; i < length; ++i) {
@@ -359,12 +360,12 @@ bool Value::isValid(const Base *b) const
int s = usedStorage(b);
if (!s)
return true;
- if (s < 0 || offset + s > (int)b->tableOffset)
+ if (s < 0 || s > (int)b->tableOffset - offset)
return false;
if (type == QJsonValue::Array)
- return static_cast<Array *>(base(b))->isValid();
+ return static_cast<Array *>(base(b))->isValid(s);
if (type == QJsonValue::Object)
- return static_cast<Object *>(base(b))->isValid();
+ return static_cast<Object *>(base(b))->isValid(s);
return true;
}
diff --git a/src/corelib/json/qjson_p.h b/src/corelib/json/qjson_p.h
index 4be62172a2..0c78fadfc7 100644
--- a/src/corelib/json/qjson_p.h
+++ b/src/corelib/json/qjson_p.h
@@ -326,12 +326,19 @@ public:
explicit String(const char *data) { d = (Data *)data; }
struct Data {
- qle_int length;
+ qle_uint length;
qle_ushort utf16[1];
};
Data *d;
+ int byteSize() const { return sizeof(uint) + sizeof(ushort) * d->length; }
+ bool isValid(int maxSize) const {
+ // Check byteSize() <= maxSize, avoiding integer overflow
+ maxSize -= sizeof(uint);
+ return maxSize >= 0 && uint(d->length) <= maxSize / sizeof(ushort);
+ }
+
inline String &operator=(const QString &str)
{
d->length = str.length();
@@ -400,11 +407,16 @@ public:
explicit Latin1String(const char *data) { d = (Data *)data; }
struct Data {
- qle_short length;
+ qle_ushort length;
char latin1[1];
};
Data *d;
+ int byteSize() const { return sizeof(ushort) + sizeof(char)*(d->length); }
+ bool isValid(int maxSize) const {
+ return byteSize() <= maxSize;
+ }
+
inline Latin1String &operator=(const QString &str)
{
int len = d->length = str.length();
@@ -606,7 +618,7 @@ public:
int indexOf(const QString &key, bool *exists) const;
int indexOf(QLatin1String key, bool *exists) const;
- bool isValid() const;
+ bool isValid(int maxSize) const;
};
@@ -616,7 +628,7 @@ public:
inline Value at(int i) const;
inline Value &operator [](int i);
- bool isValid() const;
+ bool isValid(int maxSize) const;
};
@@ -671,12 +683,12 @@ public:
// key
// value data follows key
- int size() const {
+ uint size() const {
int s = sizeof(Entry);
if (value.latinKey)
- s += sizeof(ushort) + qFromLittleEndian(*(ushort *) ((const char *)this + sizeof(Entry)));
+ s += shallowLatin1Key().byteSize();
else
- s += sizeof(uint) + sizeof(ushort)*qFromLittleEndian(*(int *) ((const char *)this + sizeof(Entry)));
+ s += shallowKey().byteSize();
return alignedSize(s);
}
@@ -702,6 +714,15 @@ public:
return shallowKey().toString();
}
+ bool isValid(int maxSize) const {
+ if (maxSize < (int)sizeof(Entry))
+ return false;
+ maxSize -= sizeof(Entry);
+ if (value.latinKey)
+ return shallowLatin1Key().isValid(maxSize);
+ return shallowKey().isValid(maxSize);
+ }
+
bool operator ==(const QString &key) const;
inline bool operator !=(const QString &key) const { return !operator ==(key); }
inline bool operator >=(const QString &key) const;
@@ -714,8 +735,6 @@ public:
bool operator >=(const Entry &other) const;
};
-inline bool operator!=(const Entry &lhs, const Entry &rhs) { return !(lhs == rhs); }
-
inline bool Entry::operator >=(const QString &key) const
{
if (value.latinKey)
diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp
index fb651f0f24..b5b6f36bc6 100644
--- a/src/corelib/json/qjsonobject.cpp
+++ b/src/corelib/json/qjsonobject.cpp
@@ -599,8 +599,8 @@ bool QJsonObject::operator==(const QJsonObject &other) const
for (uint i = 0; i < o->length; ++i) {
QJsonPrivate::Entry *e = o->entryAt(i);
- QJsonPrivate::Entry *oe = other.o->entryAt(i);
- if (*e != *oe || QJsonValue(d, o, e->value) != QJsonValue(other.d, other.o, oe->value))
+ QJsonValue v(d, o, e->value);
+ if (other.value(e->key()) != v)
return false;
}
diff --git a/src/corelib/json/qjsonparser.cpp b/src/corelib/json/qjsonparser.cpp
index 6a3d1de99a..0eb0d21ecf 100644
--- a/src/corelib/json/qjsonparser.cpp
+++ b/src/corelib/json/qjsonparser.cpp
@@ -283,7 +283,6 @@ char Parser::nextToken()
case ValueSeparator:
case EndArray:
case EndObject:
- eatSpace();
case Quote:
break;
default:
@@ -391,6 +390,8 @@ bool Parser::parseObject()
}
int objectOffset = reserveSpace(sizeof(QJsonPrivate::Object));
+ if (objectOffset < 0)
+ return false;
BEGIN << "parseObject pos=" << objectOffset << current << json;
ParsedObject parsedObject(this, objectOffset);
@@ -423,6 +424,9 @@ bool Parser::parseObject()
if (parsedObject.offsets.size()) {
int tableSize = parsedObject.offsets.size()*sizeof(uint);
table = reserveSpace(tableSize);
+ if (table < 0)
+ return false;
+
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
memcpy(data + table, parsedObject.offsets.constData(), tableSize);
#else
@@ -452,6 +456,8 @@ bool Parser::parseObject()
bool Parser::parseMember(int baseOffset)
{
int entryOffset = reserveSpace(sizeof(QJsonPrivate::Entry));
+ if (entryOffset < 0)
+ return false;
BEGIN << "parseMember pos=" << entryOffset;
bool latin1;
@@ -462,6 +468,10 @@ bool Parser::parseMember(int baseOffset)
lastError = QJsonParseError::MissingNameSeparator;
return false;
}
+ if (!eatSpace()) {
+ lastError = QJsonParseError::UnterminatedObject;
+ return false;
+ }
QJsonPrivate::Value val;
if (!parseValue(&val, baseOffset))
return false;
@@ -475,6 +485,42 @@ bool Parser::parseMember(int baseOffset)
return true;
}
+namespace {
+ struct ValueArray {
+ static const int prealloc = 128;
+ ValueArray() : data(stackValues), alloc(prealloc), size(0) {}
+ ~ValueArray() { if (data != stackValues) free(data); }
+
+ inline bool grow() {
+ alloc *= 2;
+ if (data == stackValues) {
+ QJsonPrivate::Value *newValues = static_cast<QJsonPrivate::Value *>(malloc(alloc*sizeof(QJsonPrivate::Value)));
+ if (!newValues)
+ return false;
+ memcpy(newValues, data, size*sizeof(QJsonPrivate::Value));
+ data = newValues;
+ } else {
+ data = static_cast<QJsonPrivate::Value *>(realloc(data, alloc*sizeof(QJsonPrivate::Value)));
+ if (!data)
+ return false;
+ }
+ return true;
+ }
+ bool append(const QJsonPrivate::Value &v) {
+ if (alloc == size && !grow())
+ return false;
+ data[size] = v;
+ ++size;
+ return true;
+ }
+
+ QJsonPrivate::Value stackValues[prealloc];
+ QJsonPrivate::Value *data;
+ int alloc;
+ int size;
+ };
+}
+
/*
array = begin-array [ value *( value-separator value ) ] end-array
*/
@@ -488,8 +534,10 @@ bool Parser::parseArray()
}
int arrayOffset = reserveSpace(sizeof(QJsonPrivate::Array));
+ if (arrayOffset < 0)
+ return false;
- QVarLengthArray<QJsonPrivate::Value, 64> values;
+ ValueArray values;
if (!eatSpace()) {
lastError = QJsonParseError::UnterminatedArray;
@@ -499,10 +547,17 @@ bool Parser::parseArray()
nextToken();
} else {
while (1) {
+ if (!eatSpace()) {
+ lastError = QJsonParseError::UnterminatedArray;
+ return false;
+ }
QJsonPrivate::Value val;
if (!parseValue(&val, arrayOffset))
return false;
- values.append(val);
+ if (!values.append(val)) {
+ lastError = QJsonParseError::DocumentTooLarge;
+ return false;
+ }
char token = nextToken();
if (token == EndArray)
break;
@@ -516,20 +571,22 @@ bool Parser::parseArray()
}
}
- DEBUG << "size =" << values.size();
+ DEBUG << "size =" << values.size;
int table = arrayOffset;
// finalize the object
- if (values.size()) {
- int tableSize = values.size()*sizeof(QJsonPrivate::Value);
+ if (values.size) {
+ int tableSize = values.size*sizeof(QJsonPrivate::Value);
table = reserveSpace(tableSize);
- memcpy(data + table, values.constData(), tableSize);
+ if (table < 0)
+ return false;
+ memcpy(data + table, values.data, tableSize);
}
QJsonPrivate::Array *a = (QJsonPrivate::Array *)(data + arrayOffset);
a->tableOffset = table - arrayOffset;
a->size = current - arrayOffset;
a->is_object = false;
- a->length = values.size();
+ a->length = values.size;
DEBUG << "current=" << current;
END;
@@ -636,6 +693,12 @@ bool Parser::parseValue(QJsonPrivate::Value *val, int baseOffset)
DEBUG << "value: object";
END;
return true;
+ case ValueSeparator:
+ // Essentially missing value, but after a colon, not after a comma
+ // like the other MissingObject errors.
+ lastError = QJsonParseError::IllegalValue;
+ return false;
+ case EndObject:
case EndArray:
lastError = QJsonParseError::MissingObject;
return false;
@@ -738,6 +801,8 @@ bool Parser::parseNumber(QJsonPrivate::Value *val, int baseOffset)
}
int pos = reserveSpace(sizeof(double));
+ if (pos < 0)
+ return false;
qToLittleEndian(ui, data + pos);
if (current - baseOffset >= Value::MaxSize) {
lastError = QJsonParseError::DocumentTooLarge;
@@ -856,6 +921,9 @@ bool Parser::parseString(bool *latin1)
// try to write out a latin1 string
int stringPos = reserveSpace(2);
+ if (stringPos < 0)
+ return false;
+
BEGIN << "parse string stringPos=" << stringPos << json;
while (json < end) {
uint ch = 0;
@@ -878,6 +946,8 @@ bool Parser::parseString(bool *latin1)
break;
}
int pos = reserveSpace(1);
+ if (pos < 0)
+ return false;
DEBUG << " " << ch << (char)ch;
data[pos] = (uchar)ch;
}
@@ -893,6 +963,8 @@ bool Parser::parseString(bool *latin1)
// write string length
*(QJsonPrivate::qle_ushort *)(data + stringPos) = ushort(current - outStart - sizeof(ushort));
int pos = reserveSpace((4 - current) & 3);
+ if (pos < 0)
+ return false;
while (pos & 3)
data[pos++] = 0;
END;
@@ -922,10 +994,14 @@ bool Parser::parseString(bool *latin1)
}
if (QChar::requiresSurrogates(ch)) {
int pos = reserveSpace(4);
+ if (pos < 0)
+ return false;
*(QJsonPrivate::qle_ushort *)(data + pos) = QChar::highSurrogate(ch);
*(QJsonPrivate::qle_ushort *)(data + pos + 2) = QChar::lowSurrogate(ch);
} else {
int pos = reserveSpace(2);
+ if (pos < 0)
+ return false;
*(QJsonPrivate::qle_ushort *)(data + pos) = (ushort)ch;
}
}
@@ -939,6 +1015,8 @@ bool Parser::parseString(bool *latin1)
// write string length
*(QJsonPrivate::qle_int *)(data + stringPos) = (current - outStart - sizeof(int))/2;
int pos = reserveSpace((4 - current) & 3);
+ if (pos < 0)
+ return false;
while (pos & 3)
data[pos++] = 0;
END;
diff --git a/src/corelib/json/qjsonparser_p.h b/src/corelib/json/qjsonparser_p.h
index e3b95109c6..afa2c1a8cf 100644
--- a/src/corelib/json/qjsonparser_p.h
+++ b/src/corelib/json/qjsonparser_p.h
@@ -109,6 +109,10 @@ private:
if (current + space >= dataLength) {
dataLength = 2*dataLength + space;
data = (char *)realloc(data, dataLength);
+ if (!data) {
+ lastError = QJsonParseError::DocumentTooLarge;
+ return -1;
+ }
}
int pos = current;
current += space;
diff --git a/src/corelib/json/qjsonvalue.cpp b/src/corelib/json/qjsonvalue.cpp
index 5a906dda7b..4b52014db1 100644
--- a/src/corelib/json/qjsonvalue.cpp
+++ b/src/corelib/json/qjsonvalue.cpp
@@ -349,6 +349,12 @@ QJsonValue &QJsonValue::operator =(const QJsonValue &other)
\row
\li
\list
+ \li QMetaType::Nullptr
+ \endlist
+ \li QJsonValue::Null
+ \row
+ \li
+ \list
\li QMetaType::Bool
\endlist
\li QJsonValue::Bool
@@ -393,6 +399,8 @@ QJsonValue &QJsonValue::operator =(const QJsonValue &other)
QJsonValue QJsonValue::fromVariant(const QVariant &variant)
{
switch (variant.userType()) {
+ case QMetaType::Nullptr:
+ return QJsonValue(Null);
case QVariant::Bool:
return QJsonValue(variant.toBool());
case QVariant::Int:
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index a4a4e50f10..3796df5614 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -2048,7 +2048,7 @@ QString QCoreApplication::translate(const char *context, const char *sourceText,
return ret;
}
-#endif //QT_NO_TRANSLATE
+#endif //QT_NO_TRANSLATION
// Makes it possible to point QCoreApplication to a custom location to ensure
// the directory is added to the patch, and qt.conf and deployed plugins are
diff --git a/src/corelib/kernel/qeventdispatcher_winrt.cpp b/src/corelib/kernel/qeventdispatcher_winrt.cpp
index 3b2321aa49..ff397fc750 100644
--- a/src/corelib/kernel/qeventdispatcher_winrt.cpp
+++ b/src/corelib/kernel/qeventdispatcher_winrt.cpp
@@ -42,6 +42,7 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QThread>
#include <QtCore/QHash>
+#include <QtCore/QMutex>
#include <QtCore/qfunctions_winrt.h>
#include <private/qabstracteventdispatcher_p.h>
#include <private/qcoreapplication_p.h>
@@ -151,6 +152,7 @@ public:
private:
QHash<int, QObject *> timerIdToObject;
QVector<WinRTTimerInfo> timerInfos;
+ mutable QMutex timerInfoLock;
QHash<HANDLE, int> timerHandleToId;
QHash<int, HANDLE> timerIdToHandle;
QHash<int, HANDLE> timerIdToCancelHandle;
@@ -167,6 +169,7 @@ private:
timerIdToObject.insert(id, obj);
const quint64 targetTime = qt_msectime() + interval;
const WinRTTimerInfo info(id, interval, type, obj, targetTime);
+ QMutexLocker locker(&timerInfoLock);
if (id >= timerInfos.size())
timerInfos.resize(id + 1);
timerInfos[id] = info;
@@ -175,6 +178,7 @@ private:
bool removeTimer(int id)
{
+ QMutexLocker locker(&timerInfoLock);
if (id >= timerInfos.size())
return false;
@@ -312,14 +316,18 @@ bool QEventDispatcherWinRT::processEvents(QEventLoop::ProcessEventsFlags flags)
if (timerId == INTERRUPT_HANDLE)
break;
- WinRTTimerInfo &info = d->timerInfos[timerId];
- Q_ASSERT(info.timerId != INVALID_TIMER_ID);
+ {
+ QMutexLocker locker(&d->timerInfoLock);
- QCoreApplication::postEvent(this, new QTimerEvent(timerId));
+ WinRTTimerInfo &info = d->timerInfos[timerId];
+ Q_ASSERT(info.timerId != INVALID_TIMER_ID);
- // Update timer's targetTime
- const quint64 targetTime = qt_msectime() + info.interval;
- info.targetTime = targetTime;
+ QCoreApplication::postEvent(this, new QTimerEvent(timerId));
+
+ // Update timer's targetTime
+ const quint64 targetTime = qt_msectime() + info.interval;
+ info.targetTime = targetTime;
+ }
waitResult = WaitForMultipleObjectsEx(timerHandles.count(), timerHandles.constData(), FALSE, 0, TRUE);
}
emit awake();
@@ -487,6 +495,7 @@ QList<QAbstractEventDispatcher::TimerInfo> QEventDispatcherWinRT::registeredTime
}
Q_D(const QEventDispatcherWinRT);
+ QMutexLocker locker(&d->timerInfoLock);
QList<TimerInfo> timerInfos;
for (const WinRTTimerInfo &info : d->timerInfos) {
if (info.object == object && info.timerId != INVALID_TIMER_ID)
@@ -518,6 +527,7 @@ int QEventDispatcherWinRT::remainingTime(int timerId)
}
Q_D(QEventDispatcherWinRT);
+ QMutexLocker locker(&d->timerInfoLock);
const WinRTTimerInfo timerInfo = d->timerInfos.at(timerId);
if (timerInfo.timerId == INVALID_TIMER_ID) {
#ifndef QT_NO_DEBUG
@@ -566,6 +576,9 @@ bool QEventDispatcherWinRT::event(QEvent *e)
case QEvent::Timer: {
QTimerEvent *timerEvent = static_cast<QTimerEvent *>(e);
const int id = timerEvent->timerId();
+
+ QMutexLocker locker(&d->timerInfoLock);
+
Q_ASSERT(id < d->timerInfos.size());
WinRTTimerInfo &info = d->timerInfos[id];
Q_ASSERT(info.timerId != INVALID_TIMER_ID);
@@ -574,17 +587,17 @@ bool QEventDispatcherWinRT::event(QEvent *e)
break;
info.inEvent = true;
+ locker.unlock();
+
QTimerEvent te(id);
QCoreApplication::sendEvent(d->timerIdToObject.value(id), &te);
+ locker.relock();
+
// The timer might have been removed in the meanwhile
if (id >= d->timerInfos.size())
break;
- info = d->timerInfos[id];
- if (info.timerId == INVALID_TIMER_ID)
- break;
-
if (info.interval == 0 && info.inEvent) {
// post the next zero timer event as long as the timer was not restarted
QCoreApplication::postEvent(this, new QTimerEvent(id));
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 9e2a5bf75d..e64812b3ae 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -45,8 +45,6 @@
#include <QtCore/qatomic.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qvarlengtharray.h>
-#include <QtCore/qisenum.h>
-#include <QtCore/qtypetraits.h>
#ifndef QT_NO_QOBJECT
#include <QtCore/qobjectdefs.h>
#endif
@@ -887,7 +885,7 @@ private:
// is void* to avoid overloads conflicts. We do it by injecting unaccessible Dummy
// type as part of the overload signature.
struct Dummy {};
- typedef typename QtPrivate::if_<QtPrivate::is_same<value_type, void*>::value, Dummy, value_type>::type value_type_OR_Dummy;
+ typedef typename std::conditional<std::is_same<value_type, void*>::value, Dummy, value_type>::type value_type_OR_Dummy;
public:
static void assign(void **ptr, const value_type_OR_Dummy *iterator )
{
@@ -1092,7 +1090,7 @@ struct QSequentialIterableConvertFunctor
}
namespace QtMetaTypePrivate {
-template<typename T, bool = QtPrivate::is_same<typename T::const_iterator::value_type, typename T::mapped_type>::value>
+template<typename T, bool = std::is_same<typename T::const_iterator::value_type, typename T::mapped_type>::value>
struct AssociativeContainerAccessor
{
static const typename T::key_type& getKey(const typename T::const_iterator &it)
@@ -1106,7 +1104,7 @@ struct AssociativeContainerAccessor
}
};
-template<typename T, bool = QtPrivate::is_same<typename T::const_iterator::value_type, std::pair<const typename T::key_type, typename T::mapped_type> >::value>
+template<typename T, bool = std::is_same<typename T::const_iterator::value_type, std::pair<const typename T::key_type, typename T::mapped_type> >::value>
struct StlStyleAssociativeContainerAccessor;
template<typename T>
@@ -1636,7 +1634,7 @@ namespace QtPrivate {
| (IsSharedPointerToTypeDerivedFromQObject<T>::Value ? QMetaType::SharedPointerToQObject : 0)
| (IsWeakPointerToTypeDerivedFromQObject<T>::Value ? QMetaType::WeakPointerToQObject : 0)
| (IsTrackingPointerToTypeDerivedFromQObject<T>::Value ? QMetaType::TrackingPointerToQObject : 0)
- | (Q_IS_ENUM(T) ? QMetaType::IsEnumeration : 0)
+ | (std::is_enum<T>::value ? QMetaType::IsEnumeration : 0)
| (IsGadgetHelper<T>::Value ? QMetaType::IsGadget : 0)
};
};
@@ -1787,7 +1785,7 @@ template <typename T>
struct QMetaTypeIdQObject<T, QMetaType::IsGadget>
{
enum {
- Defined = QtPrivate::is_default_constructible<T>::value
+ Defined = std::is_default_constructible<T>::value
};
static int qt_metatype_id()
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 75a7f63fbf..25acdefeaf 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -155,14 +155,14 @@ public:
template<typename T>
inline T findChild(const QString &aName = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
{
- typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type ObjType;
+ typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
return static_cast<T>(qt_qFindChild_helper(this, aName, ObjType::staticMetaObject, options));
}
template<typename T>
inline QList<T> findChildren(const QString &aName = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
{
- typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type ObjType;
+ typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
QList<T> list;
qt_qFindChildren_helper(this, aName, ObjType::staticMetaObject,
reinterpret_cast<QList<void *> *>(&list), options);
@@ -173,7 +173,7 @@ public:
template<typename T>
inline QList<T> findChildren(const QRegExp &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
{
- typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type ObjType;
+ typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
QList<T> list;
qt_qFindChildren_helper(this, re, ObjType::staticMetaObject,
reinterpret_cast<QList<void *> *>(&list), options);
@@ -185,7 +185,7 @@ public:
template<typename T>
inline QList<T> findChildren(const QRegularExpression &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
{
- typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type ObjType;
+ typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
QList<T> list;
qt_qFindChildren_helper(this, re, ObjType::staticMetaObject,
reinterpret_cast<QList<void *> *>(&list), options);
@@ -497,7 +497,7 @@ inline QT_DEPRECATED QList<T> qFindChildren(const QObject *o, const QRegExp &re)
template <class T>
inline T qobject_cast(QObject *object)
{
- typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type ObjType;
+ typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<ObjType>::Value,
"qobject_cast requires the type to have a Q_OBJECT macro");
return static_cast<T>(ObjType::staticMetaObject.cast(object));
@@ -506,7 +506,7 @@ inline T qobject_cast(QObject *object)
template <class T>
inline T qobject_cast(const QObject *object)
{
- typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type ObjType;
+ typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<ObjType>::Value,
"qobject_cast requires the type to have a Q_OBJECT macro");
return static_cast<T>(ObjType::staticMetaObject.cast(object));
diff --git a/src/corelib/kernel/qpointer.h b/src/corelib/kernel/qpointer.h
index b5c17ad394..b2b3cda4ab 100644
--- a/src/corelib/kernel/qpointer.h
+++ b/src/corelib/kernel/qpointer.h
@@ -52,7 +52,7 @@ class QVariant;
template <class T>
class QPointer
{
- Q_STATIC_ASSERT_X(!QtPrivate::is_pointer<T>::value, "QPointer's template type must not be a pointer type");
+ Q_STATIC_ASSERT_X(!std::is_pointer<T>::value, "QPointer's template type must not be a pointer type");
template<typename U>
struct TypeSelector
diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h
index 4f934d0367..96c7efd8f5 100644
--- a/src/corelib/kernel/qtimer.h
+++ b/src/corelib/kernel/qtimer.h
@@ -119,14 +119,14 @@ public:
// singleShot to a functor or function pointer (without context)
template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
- !QtPrivate::is_same<const char*, Func1>::value, void>::Type
+ !std::is_same<const char*, Func1>::value, void>::Type
singleShot(Duration interval, Func1 slot)
{
singleShot(interval, defaultTypeFor(interval), nullptr, slot);
}
template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
- !QtPrivate::is_same<const char*, Func1>::value, void>::Type
+ !std::is_same<const char*, Func1>::value, void>::Type
singleShot(Duration interval, Qt::TimerType timerType, Func1 slot)
{
singleShot(interval, timerType, nullptr, slot);
@@ -134,14 +134,14 @@ public:
// singleShot to a functor or function pointer (with context)
template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
- !QtPrivate::is_same<const char*, Func1>::value, void>::Type
+ !std::is_same<const char*, Func1>::value, void>::Type
singleShot(Duration interval, QObject *context, Func1 slot)
{
singleShot(interval, defaultTypeFor(interval), context, slot);
}
template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
- !QtPrivate::is_same<const char*, Func1>::value, void>::Type
+ !std::is_same<const char*, Func1>::value, void>::Type
singleShot(Duration interval, Qt::TimerType timerType, QObject *context, Func1 slot)
{
//compilation error if the slot has arguments.
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 72ae3b063f..ccfa7d0d38 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -3085,6 +3085,7 @@ bool QVariant::canConvert(int targetTypeId) const
if (currentType == QMetaType::QJsonValue) {
switch (targetTypeId) {
+ case QMetaType::Nullptr:
case QMetaType::QString:
case QMetaType::Bool:
case QMetaType::Int:
diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h
index d01f386032..bf88def438 100644
--- a/src/corelib/kernel/qvariant_p.h
+++ b/src/corelib/kernel/qvariant_p.h
@@ -65,8 +65,8 @@ template<typename T>
struct QVariantIntegrator
{
static const bool CanUseInternalSpace = sizeof(T) <= sizeof(QVariant::Private::Data)
- && ((QTypeInfoQuery<T>::isRelocatable) || Q_IS_ENUM(T));
- typedef QtPrivate::integral_constant<bool, CanUseInternalSpace> CanUseInternalSpace_t;
+ && ((QTypeInfoQuery<T>::isRelocatable) || std::is_enum<T>::value);
+ typedef std::integral_constant<bool, CanUseInternalSpace> CanUseInternalSpace_t;
};
Q_STATIC_ASSERT(QVariantIntegrator<double>::CanUseInternalSpace);
Q_STATIC_ASSERT(QVariantIntegrator<long int>::CanUseInternalSpace);
@@ -118,28 +118,28 @@ private:
};
template <class T>
-inline void v_construct_helper(QVariant::Private *x, const T &t, QtPrivate::true_type)
+inline void v_construct_helper(QVariant::Private *x, const T &t, std::true_type)
{
new (&x->data) T(t);
x->is_shared = false;
}
template <class T>
-inline void v_construct_helper(QVariant::Private *x, const T &t, QtPrivate::false_type)
+inline void v_construct_helper(QVariant::Private *x, const T &t, std::false_type)
{
x->data.shared = new QVariantPrivateSharedEx<T>(t);
x->is_shared = true;
}
template <class T>
-inline void v_construct_helper(QVariant::Private *x, QtPrivate::true_type)
+inline void v_construct_helper(QVariant::Private *x, std::true_type)
{
new (&x->data) T();
x->is_shared = false;
}
template <class T>
-inline void v_construct_helper(QVariant::Private *x, QtPrivate::false_type)
+inline void v_construct_helper(QVariant::Private *x, std::false_type)
{
x->data.shared = new QVariantPrivateSharedEx<T>;
x->is_shared = true;
diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp
index 366413e82e..6e0fa4eedb 100644
--- a/src/corelib/thread/qmutex.cpp
+++ b/src/corelib/thread/qmutex.cpp
@@ -48,7 +48,6 @@
#include "qelapsedtimer.h"
#include "qthread.h"
#include "qmutex_p.h"
-#include "qtypetraits.h"
#ifndef QT_LINUX_FUTEX
#include "private/qfreelist_p.h"
@@ -77,7 +76,7 @@ public:
// written to by the thread that first owns 'mutex';
// read during attempts to acquire ownership of 'mutex' from any other thread:
- QAtomicPointer<QtPrivate::remove_pointer<Qt::HANDLE>::type> owner;
+ QAtomicPointer<std::remove_pointer<Qt::HANDLE>::type> owner;
// only ever accessed from the thread that owns 'mutex':
uint count;
diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h
index 038f4149c3..38753a6726 100644
--- a/src/corelib/tools/qalgorithms.h
+++ b/src/corelib/tools/qalgorithms.h
@@ -42,7 +42,7 @@
#include <QtCore/qglobal.h>
-#if defined(Q_CC_MSVC)
+#if defined(Q_CC_MSVC) && _MSC_VER > 1500
#include <intrin.h>
#endif
diff --git a/src/corelib/tools/qbytearray_p.h b/src/corelib/tools/qbytearray_p.h
index 0824611d99..6ebff739cd 100644
--- a/src/corelib/tools/qbytearray_p.h
+++ b/src/corelib/tools/qbytearray_p.h
@@ -52,14 +52,13 @@
//
#include <QtCore/qbytearray.h>
-#include <QtCore/qtypetraits.h>
#include "qtools_p.h"
QT_BEGIN_NAMESPACE
enum {
// Define as enum to force inlining. Don't expose MaxAllocSize in a public header.
- MaxByteArraySize = MaxAllocSize - sizeof(QtPrivate::remove_pointer<QByteArray::DataPtr>::type)
+ MaxByteArraySize = MaxAllocSize - sizeof(std::remove_pointer<QByteArray::DataPtr>::type)
};
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 6a2d7bdd11..66b5e75a1a 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -744,7 +744,7 @@ Q_INLINE_TEMPLATE T &QHash<Key, T>::operator[](const Key &akey)
Node **node = findNode(akey, &h);
if (*node == e) {
if (d->willGrow())
- node = findNode(akey, &h);
+ node = findNode(akey, h);
return createNode(h, akey, T(), node)->value;
}
return (*node)->value;
@@ -760,11 +760,11 @@ Q_INLINE_TEMPLATE typename QHash<Key, T>::iterator QHash<Key, T>::insert(const K
Node **node = findNode(akey, &h);
if (*node == e) {
if (d->willGrow())
- node = findNode(akey, &h);
+ node = findNode(akey, h);
return iterator(createNode(h, akey, avalue, node));
}
- if (!QtPrivate::is_same<T, QHashDummyValue>::value)
+ if (!std::is_same<T, QHashDummyValue>::value)
(*node)->value = avalue;
return iterator(*node);
}
@@ -961,8 +961,7 @@ QPair<typename QHash<Key, T>::iterator, typename QHash<Key, T>::iterator> QHash<
template <class Key, class T>
QPair<typename QHash<Key, T>::const_iterator, typename QHash<Key, T>::const_iterator> QHash<Key, T>::equal_range(const Key &akey) const Q_DECL_NOTHROW
{
- uint h;
- Node *node = *findNode(akey, &h);
+ Node *node = *findNode(akey);
const_iterator firstIt = const_iterator(node);
if (node != e) {
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index c7f27abdd6..c0a92aaa10 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -125,10 +125,10 @@ class QList
{
public:
struct MemoryLayout
- : QtPrivate::if_<
+ : std::conditional<
QTypeInfo<T>::isStatic || QTypeInfo<T>::isLarge,
QListData::IndirectLayout,
- typename QtPrivate::if_<
+ typename std::conditional<
sizeof(T) == sizeof(void*),
QListData::ArrayCompatibleLayout,
QListData::InlineWithPaddingLayout
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index baa10b7a95..96ce787446 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -44,7 +44,6 @@
#include <QtCore/qlist.h>
#include <QtCore/qrefcount.h>
#include <QtCore/qpair.h>
-#include <QtCore/qtypetraits.h>
#ifdef Q_MAP_DEBUG
#include <QtCore/qdebug.h>
@@ -130,15 +129,15 @@ struct QMapNode : public QMapNodeBase
{
callDestructorIfNecessary(key);
callDestructorIfNecessary(value);
- doDestroySubTree(QtPrivate::integral_constant<bool, QTypeInfo<T>::isComplex || QTypeInfo<Key>::isComplex>());
+ doDestroySubTree(std::integral_constant<bool, QTypeInfo<T>::isComplex || QTypeInfo<Key>::isComplex>());
}
QMapNode<Key, T> *lowerBound(const Key &key);
QMapNode<Key, T> *upperBound(const Key &key);
private:
- void doDestroySubTree(QtPrivate::false_type) {}
- void doDestroySubTree(QtPrivate::true_type)
+ void doDestroySubTree(std::false_type) {}
+ void doDestroySubTree(std::true_type)
{
if (left)
leftNode()->destroySubTree();
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index a0c22c9179..5738413bfb 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -464,7 +464,7 @@ private:
template <class X>
inline void enableSharedFromThis(const QEnableSharedFromThis<X> *ptr)
{
- ptr->initializeFromSharedPointer(constCast<typename QtPrivate::remove_cv<T>::type>());
+ ptr->initializeFromSharedPointer(constCast<typename std::remove_cv<T>::type>());
}
inline void enableSharedFromThis(...) {}
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index c6af05c73e..94d2b5f65e 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -4830,6 +4830,39 @@ QString QString::fromUtf16(const ushort *unicode, int size)
return QUtf16::convertToUnicode((const char *)unicode, size*2, 0);
}
+/*!
+ \fn QString QString::fromUtf16(const char16_t *str, int size)
+ \since 5.3
+
+ Returns a QString initialized with the first \a size characters
+ of the Unicode string \a str (ISO-10646-UTF-16 encoded).
+
+ If \a size is -1 (default), \a str must be terminated
+ with a 0.
+
+ This function checks for a Byte Order Mark (BOM). If it is missing,
+ host byte order is assumed.
+
+ This function is slow compared to the other Unicode conversions.
+ Use QString(const QChar *, int) or QString(const QChar *) if possible.
+
+ QString makes a deep copy of the Unicode data.
+
+ \sa utf16(), setUtf16(), fromStdU16String()
+*/
+
+/*!
+ \fn QString QString::fromUcs4(const char32_t *str, int size)
+ \since 5.3
+
+ Returns a QString initialized with the first \a size characters
+ of the Unicode string \a str (ISO-10646-UCS-4 encoded).
+
+ If \a size is -1 (default), \a str must be terminated
+ with a 0.
+
+ \sa toUcs4(), fromUtf16(), utf16(), setUtf16(), fromWCharArray(), fromStdU32String()
+*/
/*!
\since 4.2
diff --git a/src/corelib/tools/qstringalgorithms_p.h b/src/corelib/tools/qstringalgorithms_p.h
index d7127517e0..c5470bc7ad 100644
--- a/src/corelib/tools/qstringalgorithms_p.h
+++ b/src/corelib/tools/qstringalgorithms_p.h
@@ -60,8 +60,8 @@ template <typename StringType> struct QStringAlgorithms
{
typedef typename StringType::value_type Char;
typedef typename StringType::size_type size_type;
- typedef typename QtPrivate::remove_cv<StringType>::type NakedStringType;
- static const bool isConst = QtPrivate::is_const<StringType>::value;
+ typedef typename std::remove_cv<StringType>::type NakedStringType;
+ static const bool isConst = std::is_const<StringType>::value;
static inline bool isSpace(char ch) { return ascii_isspace(ch); }
static inline bool isSpace(QChar ch) { return ch.isSpace(); }
diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp
index 1ffaeca852..af35193b13 100644
--- a/src/corelib/xml/qxmlstream.cpp
+++ b/src/corelib/xml/qxmlstream.cpp
@@ -886,7 +886,7 @@ inline void QXmlStreamReaderPrivate::reallocateStack()
sym_stack = reinterpret_cast<Value*> (realloc(sym_stack, stack_size * sizeof(Value)));
Q_CHECK_PTR(sym_stack);
state_stack = reinterpret_cast<int*> (realloc(state_stack, stack_size * sizeof(int)));
- Q_CHECK_PTR(sym_stack);
+ Q_CHECK_PTR(state_stack);
}
diff --git a/src/gui/configure.json b/src/gui/configure.json
index f4f099cc23..662e484271 100644
--- a/src/gui/configure.json
+++ b/src/gui/configure.json
@@ -9,6 +9,7 @@
"options": {
"android-style-assets": "boolean",
"angle": "boolean",
+ "direct2d": "boolean",
"directfb": "boolean",
"directwrite": "boolean",
"egl": "boolean",
@@ -446,8 +447,7 @@
},
"direct2d": {
"label": "Direct 2D",
- "autoDetect": false,
- "condition": "config.win32 && libs.direct2d",
+ "condition": "config.win32 && !config.winrt && libs.direct2d",
"output": [ "privateFeature" ]
},
"evdev": {
@@ -847,6 +847,12 @@
"condition": "features.library",
"output": [ "publicFeature", "feature" ]
},
+ "highdpiscaling": {
+ "label": "High DPI Scaling",
+ "purpose": "Provides automatic scaling of DPI-unaware applications on high-DPI displays.",
+ "section": "Kernel",
+ "output": [ "publicFeature", "feature" ]
+ },
"validator": {
"label": "QValidator",
"purpose": "Supports validation of input text.",
diff --git a/src/gui/configure.pri b/src/gui/configure.pri
index ee5c7730df..aaffa835dc 100644
--- a/src/gui/configure.pri
+++ b/src/gui/configure.pri
@@ -12,7 +12,7 @@ defineTest(qtConfLibrary_freetype) {
return(true)
}
}
- return(false)
+ return(true)
}
# Check for Direct X SDK (include, lib, and direct shader compiler 'fxc').
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 094f44b2ab..e8f2c878c8 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -303,7 +303,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St
QString key = QLatin1String("qt_")
% HexString<quint64>(pm.cacheKey())
- % HexString<uint>(pe->mode)
+ % HexString<uint>(pe ? pe->mode : QIcon::Normal)
% HexString<quint64>(QGuiApplication::palette().cacheKey())
% HexString<uint>(actualSize.width())
% HexString<uint>(actualSize.height());
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
index eda9d6f24e..324f13a17b 100644
--- a/src/gui/image/qiconloader.cpp
+++ b/src/gui/image/qiconloader.cpp
@@ -378,18 +378,14 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
QThemeIconInfo info;
Q_ASSERT(!themeName.isEmpty());
- QPixmap pixmap;
-
// Used to protect against potential recursions
visited << themeName;
- QIconTheme theme = themeList.value(themeName);
+ QIconTheme &theme = themeList[themeName];
if (!theme.isValid()) {
theme = QIconTheme(themeName);
if (!theme.isValid())
theme = QIconTheme(fallbackTheme());
-
- themeList.insert(themeName, theme);
}
const QStringList contentDirs = theme.contentDirs();
diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp
index 6d03332367..73448943e1 100644
--- a/src/gui/image/qpixmapcache.cpp
+++ b/src/gui/image/qpixmapcache.cpp
@@ -324,26 +324,23 @@ QPixmap *QPMCache::object(const QPixmapCache::Key &key) const
bool QPMCache::insert(const QString& key, const QPixmap &pixmap, int cost)
{
- QPixmapCache::Key cacheKey;
- QPixmapCache::Key oldCacheKey = cacheKeys.value(key);
+ QPixmapCache::Key &cacheKey = cacheKeys[key];
//If for the same key we add already a pixmap we should delete it
- if (oldCacheKey.d) {
- QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(oldCacheKey);
- cacheKeys.remove(key);
- }
+ if (cacheKey.d)
+ QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(cacheKey);
//we create a new key the old one has been removed
cacheKey = createKey();
bool success = QCache<QPixmapCache::Key, QPixmapCacheEntry>::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost);
if (success) {
- cacheKeys.insert(key, cacheKey);
if (!theid) {
theid = startTimer(flush_time);
t = false;
}
} else {
//Insertion failed we released the new allocated key
+ cacheKeys.remove(key);
releaseKey(cacheKey);
}
return success;
@@ -389,12 +386,12 @@ bool QPMCache::replace(const QPixmapCache::Key &key, const QPixmap &pixmap, int
bool QPMCache::remove(const QString &key)
{
- QPixmapCache::Key cacheKey = cacheKeys.value(key);
+ auto cacheKey = cacheKeys.constFind(key);
//The key was not in the cache
- if (!cacheKey.d)
+ if (cacheKey == cacheKeys.constEnd())
return false;
- cacheKeys.remove(key);
- return QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(cacheKey);
+ cacheKeys.erase(cacheKey);
+ return QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(cacheKey.value());
}
bool QPMCache::remove(const QPixmapCache::Key &key)
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index 3b7e03a0ff..792ca9fbaf 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -139,7 +139,7 @@ SOURCES += \
kernel/qhighdpiscaling.cpp
-qtConfig(opengl(es2)?) {
+qtConfig(opengl) {
HEADERS += \
kernel/qplatformopenglcontext.h \
kernel/qopenglcontext.h \
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
index 1085b546a7..085652879c 100644
--- a/src/gui/kernel/qhighdpiscaling.cpp
+++ b/src/gui/kernel/qhighdpiscaling.cpp
@@ -343,8 +343,10 @@ static const char scaleFactorProperty[] = "_q_scaleFactor";
*/
void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
{
- m_screenFactorSet = true;
- m_active = true;
+ if (!qFuzzyCompare(factor, qreal(1))) {
+ m_screenFactorSet = true;
+ m_active = true;
+ }
screen->setProperty(scaleFactorProperty, QVariant(factor));
// hack to force re-evaluation of screen geometry
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index 7e5697e5d8..8aea593bf0 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -848,14 +848,15 @@ QAbstractOpenGLFunctions *QOpenGLContext::versionFunctions(const QOpenGLVersionP
// Create object if suitable one not cached
QAbstractOpenGLFunctions* funcs = 0;
- if (!d->versionFunctions.contains(vp)) {
+ auto it = d->versionFunctions.constFind(vp);
+ if (it == d->versionFunctions.constEnd()) {
funcs = QOpenGLVersionFunctionsFactory::create(vp);
if (funcs) {
funcs->setOwningContext(this);
d->versionFunctions.insert(vp, funcs);
}
} else {
- funcs = d->versionFunctions.value(vp);
+ funcs = it.value();
}
if (funcs && QOpenGLContext::currentContext() == this)
diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h
index 57f70356b8..64bf55beee 100644
--- a/src/gui/kernel/qopenglcontext_p.h
+++ b/src/gui/kernel/qopenglcontext_p.h
@@ -266,7 +266,7 @@ public:
static QOpenGLContextPrivate *get(QOpenGLContext *context)
{
- return context->d_func();
+ return context ? context->d_func() : Q_NULLPTR;
}
#if !defined(QT_NO_DEBUG)
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index ca29906fad..124e997c58 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -2553,6 +2553,9 @@ void QWindowPrivate::_q_clearAlert()
See the \l{Qt::CursorShape}{list of predefined cursor objects} for a
range of useful shapes.
+ If no cursor has been set, or after a call to unsetCursor(), the
+ parent window's cursor is used.
+
By default, the cursor has the Qt::ArrowCursor shape.
Some underlying window implementations will reset the cursor if it
diff --git a/src/gui/opengl/opengl.pri b/src/gui/opengl/opengl.pri
index 2c3cca6b18..712cf144e0 100644
--- a/src/gui/opengl/opengl.pri
+++ b/src/gui/opengl/opengl.pri
@@ -3,7 +3,7 @@
qtConfig(opengl): CONFIG += opengl
qtConfig(opengles2): CONFIG += opengles2
-qtConfig(opengl(es2)?) {
+qtConfig(opengl) {
HEADERS += opengl/qopengl.h \
opengl/qopengl_p.h \
diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp
index 4f4f543ba8..e61473cb7b 100644
--- a/src/gui/opengl/qopengl.cpp
+++ b/src/gui/opengl/qopengl.cpp
@@ -136,9 +136,6 @@ QDebug operator<<(QDebug d, const QOpenGLConfig::Gpu &g)
return d;
}
-enum Operator { NotEqual, LessThan, LessEqualThan, Equals, GreaterThan, GreaterEqualThan };
-static const char operators[][3] = {"!=", "<", "<=", "=", ">", ">="};
-
typedef QJsonArray::ConstIterator JsonArrayConstIt;
static inline bool contains(const QJsonArray &haystack, unsigned needle)
@@ -160,6 +157,9 @@ static inline bool contains(const QJsonArray &haystack, const QString &needle)
}
namespace {
+enum Operator { NotEqual, LessThan, LessEqualThan, Equals, GreaterThan, GreaterEqualThan };
+static const char operators[][3] = {"!=", "<", "<=", "=", ">", ">="};
+
// VersionTerm describing a version term consisting of number and operator
// found in os.version and driver_version.
struct VersionTerm {
diff --git a/src/gui/opengl/qopengl.h b/src/gui/opengl/qopengl.h
index c7a3e79666..cd44ddfe4d 100644
--- a/src/gui/opengl/qopengl.h
+++ b/src/gui/opengl/qopengl.h
@@ -95,8 +95,11 @@ typedef void* GLeglImageOES;
// applications cannot target ES 3. Therefore QOpenGLFunctions and
// friends do everything dynamically and never rely on these macros.
+// Some Khronos headers use the ext proto guard in the standard headers as well,
+// which is bad. Work it around, but avoid spilling over to the ext header.
# ifndef GL_GLEXT_PROTOTYPES
# define GL_GLEXT_PROTOTYPES
+# define QGL_TEMP_GLEXT_PROTO
# endif
# if defined(QT_OPENGL_ES_3_1)
@@ -107,6 +110,11 @@ typedef void* GLeglImageOES;
# include <GLES2/gl2.h>
#endif
+# ifdef QGL_TEMP_GLEXT_PROTO
+# undef GL_GLEXT_PROTOTYPES
+# undef QGL_TEMP_GLEXT_PROTO
+# endif
+
/*
Some GLES2 implementations (like the one on Harmattan) are missing the
typedef for GLchar. Work around it here by adding it. The Kkronos headers
@@ -125,7 +133,15 @@ typedef char GLchar;
# include <OpenGL/glext.h>
# else
# define GL_GLEXT_LEGACY // Prevents GL/gl.h from #including system glext.h
-# include <GL/gl.h>
+// Some Khronos headers use the ext proto guard in the standard headers as well,
+// which is bad. Work it around, but avoid spilling over to the ext header.
+# ifndef GL_GLEXT_PROTOTYPES
+# define GL_GLEXT_PROTOTYPES
+# include <GL/gl.h>
+# undef GL_GLEXT_PROTOTYPES
+# else
+# include <GL/gl.h>
+# endif
# include <QtGui/qopenglext.h>
# endif // Q_OS_MAC
#endif // QT_OPENGL_ES_2
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp
index 4833617377..cedbe19191 100644
--- a/src/gui/opengl/qopenglframebufferobject.cpp
+++ b/src/gui/opengl/qopenglframebufferobject.cpp
@@ -950,6 +950,12 @@ QOpenGLFramebufferObject::~QOpenGLFramebufferObject()
d->stencil_buffer_guard->free();
if (d->fbo_guard)
d->fbo_guard->free();
+
+ QOpenGLContextPrivate *contextPrv = QOpenGLContextPrivate::get(QOpenGLContext::currentContext());
+ if (contextPrv && contextPrv->qgl_current_fbo == this) {
+ contextPrv->qgl_current_fbo_invalid = true;
+ contextPrv->qgl_current_fbo = Q_NULLPTR;
+ }
}
/*!
diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp
index 1ed5f7317a..b92d97c143 100644
--- a/src/gui/opengl/qopenglshaderprogram.cpp
+++ b/src/gui/opengl/qopenglshaderprogram.cpp
@@ -493,73 +493,84 @@ static QVersionDirectivePosition findVersionDirectivePosition(const char *source
{
Q_ASSERT(source);
- QString working = QString::fromUtf8(source);
-
// According to the GLSL spec the #version directive must not be
// preceded by anything but whitespace and comments.
// In order to not get confused by #version directives within a
- // multiline comment, we need to run a minimal preprocessor first.
+ // multiline comment, we need to do some minimal comment parsing
+ // while searching for the directive.
enum {
Normal,
+ StartOfLine,
+ PreprocessorDirective,
CommentStarting,
MultiLineComment,
SingleLineComment,
CommentEnding
- } state = Normal;
+ } state = StartOfLine;
- for (QChar *c = working.begin(); c != working.end(); ++c) {
+ const char *c = source;
+ while (*c) {
switch (state) {
+ case PreprocessorDirective:
+ if (*c == ' ' || *c == '\t')
+ break;
+ if (!strncmp(c, "version", strlen("version"))) {
+ // Found version directive
+ c += strlen("version");
+ while (*c && *c != '\n')
+ ++c;
+ int splitPosition = c - source + 1;
+ int linePosition = int(std::count(source, c, '\n')) + 1;
+ return QVersionDirectivePosition(splitPosition, linePosition);
+ } else if (*c == '/')
+ state = CommentStarting;
+ else if (*c == '\n')
+ state = StartOfLine;
+ else
+ state = Normal;
+ break;
+ case StartOfLine:
+ if (*c == ' ' || *c == '\t')
+ break;
+ else if (*c == '#') {
+ state = PreprocessorDirective;
+ break;
+ }
+ state = Normal;
+ // fall through
case Normal:
- if (*c == QLatin1Char('/'))
+ if (*c == '/')
state = CommentStarting;
+ else if (*c == '\n')
+ state = StartOfLine;
break;
case CommentStarting:
- if (*c == QLatin1Char('*'))
+ if (*c == '*')
state = MultiLineComment;
- else if (*c == QLatin1Char('/'))
+ else if (*c == '/')
state = SingleLineComment;
else
state = Normal;
break;
case MultiLineComment:
- if (*c == QLatin1Char('*'))
+ if (*c == '*')
state = CommentEnding;
- else if (*c == QLatin1Char('#'))
- *c = QLatin1Char('_');
break;
case SingleLineComment:
- if (*c == QLatin1Char('\n'))
+ if (*c == '\n')
state = Normal;
- else if (*c == QLatin1Char('#'))
- *c = QLatin1Char('_');
break;
case CommentEnding:
- if (*c == QLatin1Char('/')) {
+ if (*c == '/')
state = Normal;
- } else {
- if (*c == QLatin1Char('#'))
- *c = QLatin1Char('_');
- if (*c != QLatin1Char('*'))
- state = MultiLineComment;
- }
+ else if (*c != QLatin1Char('*'))
+ state = MultiLineComment;
break;
}
+ ++c;
}
- // Search for #version directive
- int splitPosition = 0;
- int linePosition = 1;
-
- static const QRegularExpression pattern(QStringLiteral("^\\s*#\\s*version.*(\\n)?"),
- QRegularExpression::MultilineOption
- | QRegularExpression::OptimizeOnFirstUsageOption);
- QRegularExpressionMatch match = pattern.match(working);
- if (match.hasMatch()) {
- splitPosition = match.capturedEnd();
- linePosition += int(std::count(working.begin(), working.begin() + splitPosition, QLatin1Char('\n')));
- }
-
- return QVersionDirectivePosition(splitPosition, linePosition);
+ return QVersionDirectivePosition(0, 1);
}
/*!
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
index a61865a0b6..86e35c39f8 100644
--- a/src/gui/painting/painting.pri
+++ b/src/gui/painting/painting.pri
@@ -65,7 +65,6 @@ SOURCES += \
painting/qcolor.cpp \
painting/qcompositionfunctions.cpp \
painting/qcosmeticstroker.cpp \
- painting/qcssutil.cpp \
painting/qdrawhelper.cpp \
painting/qemulationpaintengine.cpp \
painting/qgammatables.cpp \
@@ -104,6 +103,17 @@ darwin {
SOURCES += painting/qcoregraphics.mm
}
+qtConfig(cssparser) {
+ SOURCES += \
+ painting/qcssutil.cpp
+}
+
+# Causes internal compiler errors with at least GCC 5.3.1:
+gcc:equals(QT_GCC_MAJOR_VERSION, 5) {
+ SOURCES -= painting/qdrawhelper.cpp
+ NO_PCH_SOURCES += painting/qdrawhelper.cpp
+}
+
SSE2_SOURCES += painting/qdrawhelper_sse2.cpp
SSSE3_SOURCES += painting/qdrawhelper_ssse3.cpp
SSE4_1_SOURCES += painting/qdrawhelper_sse4.cpp \
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 2716d92d13..fe1ff6603d 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -4405,8 +4405,10 @@ static void blend_tiled_argb(int count, const QSpan *spans, void *userData)
uint *dest = ((uint *)data->rasterBuffer->scanLine(spans->y)) + x;
op.func(dest, src, l, coverage);
x += l;
+ sx += l;
length -= l;
- sx = 0;
+ if (sx >= image_width)
+ sx = 0;
}
++spans;
}
@@ -4464,7 +4466,9 @@ static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData)
memcpy(dest, src, l * sizeof(quint16));
length -= l;
tx += l;
- sx = 0;
+ sx += l;
+ if (sx >= image_width)
+ sx = 0;
}
// Now use the rasterBuffer as the source of the texture,
@@ -4497,8 +4501,10 @@ static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData)
const quint16 *src = (const quint16 *)data->texture.scanLine(sy) + sx;
blend_sourceOver_rgb16_rgb16(dest, src, l, alpha, ialpha);
x += l;
+ sx += l;
length -= l;
- sx = 0;
+ if (sx >= image_width)
+ sx = 0;
}
}
}
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 09b0475a84..de6da88245 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -320,8 +320,9 @@ void QFreetypeFace::release(const QFontEngine::FaceId &face_id)
cleanup();
- if (freetypeData->faces.contains(face_id))
- freetypeData->faces.take(face_id);
+ auto it = freetypeData->faces.constFind(face_id);
+ if (it != freetypeData->faces.constEnd())
+ freetypeData->faces.erase(it);
if (freetypeData->faces.isEmpty()) {
FT_Done_FreeType(freetypeData->library);
@@ -888,10 +889,47 @@ static inline bool areMetricsTooLarge(const QFontEngineFT::GlyphInfo &info)
|| (uchar)(info.height) != info.height;
}
+static inline void transformBoundingBox(int *left, int *top, int *right, int *bottom, FT_Matrix *matrix)
+{
+ int l, r, t, b;
+ FT_Vector vector;
+ vector.x = *left;
+ vector.y = *top;
+ FT_Vector_Transform(&vector, matrix);
+ l = r = vector.x;
+ t = b = vector.y;
+ vector.x = *right;
+ vector.y = *top;
+ FT_Vector_Transform(&vector, matrix);
+ if (l > vector.x) l = vector.x;
+ if (r < vector.x) r = vector.x;
+ if (t < vector.y) t = vector.y;
+ if (b > vector.y) b = vector.y;
+ vector.x = *right;
+ vector.y = *bottom;
+ FT_Vector_Transform(&vector, matrix);
+ if (l > vector.x) l = vector.x;
+ if (r < vector.x) r = vector.x;
+ if (t < vector.y) t = vector.y;
+ if (b > vector.y) b = vector.y;
+ vector.x = *left;
+ vector.y = *bottom;
+ FT_Vector_Transform(&vector, matrix);
+ if (l > vector.x) l = vector.x;
+ if (r < vector.x) r = vector.x;
+ if (t < vector.y) t = vector.y;
+ if (b > vector.y) b = vector.y;
+ *left = l;
+ *right = r;
+ *top = t;
+ *bottom = b;
+}
+
QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
QFixed subPixelPosition,
GlyphFormat format,
- bool fetchMetricsOnly) const
+ bool fetchMetricsOnly,
+ bool disableOutlineDrawing) const
{
// Q_ASSERT(freetype->lock == 1);
@@ -976,11 +1014,20 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
info.xOff = TRUNC(ROUND(slot->advance.x));
info.yOff = 0;
- if ((set && set->outline_drawing) || fetchMetricsOnly) {
- int left = FLOOR(slot->metrics.horiBearingX);
- int right = CEIL(slot->metrics.horiBearingX + slot->metrics.width);
- int top = CEIL(slot->metrics.horiBearingY);
- int bottom = FLOOR(slot->metrics.horiBearingY - slot->metrics.height);
+ if ((set && set->outline_drawing && !disableOutlineDrawing) || fetchMetricsOnly) {
+ int left = slot->metrics.horiBearingX;
+ int right = slot->metrics.horiBearingX + slot->metrics.width;
+ int top = slot->metrics.horiBearingY;
+ int bottom = slot->metrics.horiBearingY - slot->metrics.height;
+
+ if (transform && slot->format != FT_GLYPH_FORMAT_BITMAP)
+ transformBoundingBox(&left, &top, &right, &bottom, &matrix);
+
+ left = FLOOR(left);
+ right = CEIL(right);
+ bottom = FLOOR(bottom);
+ top = CEIL(top);
+
info.x = TRUNC(left);
info.y = TRUNC(top);
info.width = TRUNC(right - left);
@@ -1043,40 +1090,8 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
int right = slot->metrics.horiBearingX + slot->metrics.width;
int top = slot->metrics.horiBearingY;
int bottom = slot->metrics.horiBearingY - slot->metrics.height;
- if(transform && slot->format != FT_GLYPH_FORMAT_BITMAP) {
- int l, r, t, b;
- FT_Vector vector;
- vector.x = left;
- vector.y = top;
- FT_Vector_Transform(&vector, &matrix);
- l = r = vector.x;
- t = b = vector.y;
- vector.x = right;
- vector.y = top;
- FT_Vector_Transform(&vector, &matrix);
- if (l > vector.x) l = vector.x;
- if (r < vector.x) r = vector.x;
- if (t < vector.y) t = vector.y;
- if (b > vector.y) b = vector.y;
- vector.x = right;
- vector.y = bottom;
- FT_Vector_Transform(&vector, &matrix);
- if (l > vector.x) l = vector.x;
- if (r < vector.x) r = vector.x;
- if (t < vector.y) t = vector.y;
- if (b > vector.y) b = vector.y;
- vector.x = left;
- vector.y = bottom;
- FT_Vector_Transform(&vector, &matrix);
- if (l > vector.x) l = vector.x;
- if (r < vector.x) r = vector.x;
- if (t < vector.y) t = vector.y;
- if (b > vector.y) b = vector.y;
- left = l;
- right = r;
- top = t;
- bottom = b;
- }
+ if (transform && slot->format != FT_GLYPH_FORMAT_BITMAP)
+ transformBoundingBox(&left, &top, &right, &bottom, &matrix);
left = FLOOR(left);
right = CEIL(right);
bottom = FLOOR(bottom);
@@ -1917,10 +1932,11 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyphFor(glyph_t g,
QFixed subPixelPosition,
GlyphFormat format,
const QTransform &t,
- bool fetchBoundingBox)
+ bool fetchBoundingBox,
+ bool disableOutlineDrawing)
{
QGlyphSet *glyphSet = loadGlyphSet(t);
- if (glyphSet != 0 && glyphSet->outline_drawing && !fetchBoundingBox)
+ if (glyphSet != 0 && glyphSet->outline_drawing && !disableOutlineDrawing && !fetchBoundingBox)
return 0;
Glyph *glyph = glyphSet != 0 ? glyphSet->getGlyph(g, subPixelPosition) : 0;
@@ -1934,7 +1950,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyphFor(glyph_t g,
FT_Matrix ftMatrix = glyphSet != 0 ? glyphSet->transformationMatrix : QTransformToFTMatrix(t);
FT_Matrix_Multiply(&ftMatrix, &m);
freetype->matrix = m;
- glyph = loadGlyph(glyphSet, g, subPixelPosition, format, false);
+ glyph = loadGlyph(glyphSet, g, subPixelPosition, format, false, disableOutlineDrawing);
unlockFace();
}
@@ -1950,7 +1966,7 @@ QImage QFontEngineFT::alphaMapForGlyph(glyph_t g, QFixed subPixelPosition, const
{
const GlyphFormat neededFormat = antialias ? Format_A8 : Format_Mono;
- Glyph *glyph = loadGlyphFor(g, subPixelPosition, neededFormat, t);
+ Glyph *glyph = loadGlyphFor(g, subPixelPosition, neededFormat, t, false, true);
QImage img = alphaMapFromGlyphData(glyph, neededFormat);
img = img.copy();
@@ -1961,7 +1977,7 @@ QImage QFontEngineFT::alphaMapForGlyph(glyph_t g, QFixed subPixelPosition, const
if (!img.isNull())
return img;
- return QFontEngine::alphaMapForGlyph(g);
+ return QFontEngine::alphaMapForGlyph(g, subPixelPosition, t);
}
QImage QFontEngineFT::alphaRGBMapForGlyph(glyph_t g, QFixed subPixelPosition, const QTransform &t)
@@ -1971,7 +1987,7 @@ QImage QFontEngineFT::alphaRGBMapForGlyph(glyph_t g, QFixed subPixelPosition, co
const GlyphFormat neededFormat = Format_A32;
- Glyph *glyph = loadGlyphFor(g, subPixelPosition, neededFormat, t);
+ Glyph *glyph = loadGlyphFor(g, subPixelPosition, neededFormat, t, false, true);
QImage img = alphaMapFromGlyphData(glyph, neededFormat);
img = img.copy();
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index 5ca3721c71..32357d0076 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -272,10 +272,10 @@ private:
inline bool isBitmapFont() const { return defaultFormat == Format_Mono; }
inline bool isScalableBitmap() const { return freetype->isScalableBitmap(); }
- inline Glyph *loadGlyph(uint glyph, QFixed subPixelPosition, GlyphFormat format = Format_None, bool fetchMetricsOnly = false) const
- { return loadGlyph(cacheEnabled ? &defaultGlyphSet : 0, glyph, subPixelPosition, format, fetchMetricsOnly); }
- Glyph *loadGlyph(QGlyphSet *set, uint glyph, QFixed subPixelPosition, GlyphFormat = Format_None, bool fetchMetricsOnly = false) const;
- Glyph *loadGlyphFor(glyph_t g, QFixed subPixelPosition, GlyphFormat format, const QTransform &t, bool fetchBoundingBox = false);
+ inline Glyph *loadGlyph(uint glyph, QFixed subPixelPosition, GlyphFormat format = Format_None, bool fetchMetricsOnly = false, bool disableOutlineDrawing = false) const
+ { return loadGlyph(cacheEnabled ? &defaultGlyphSet : 0, glyph, subPixelPosition, format, fetchMetricsOnly, disableOutlineDrawing); }
+ Glyph *loadGlyph(QGlyphSet *set, uint glyph, QFixed subPixelPosition, GlyphFormat = Format_None, bool fetchMetricsOnly = false, bool disableOutlineDrawing = false) const;
+ Glyph *loadGlyphFor(glyph_t g, QFixed subPixelPosition, GlyphFormat format, const QTransform &t, bool fetchBoundingBox = false, bool disableOutlineDrawing = false);
QGlyphSet *loadGlyphSet(const QTransform &matrix);
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index 886cf5ef39..b2d8bf01af 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -316,6 +316,19 @@ bool QRawFont::operator==(const QRawFont &other) const
}
/*!
+ Returns the hash value for \a font. If specified, \a seed is used
+ to initialize the hash.
+
+ \relates QRawFont
+ \since 5.8
+*/
+uint qHash(const QRawFont &font, uint seed) Q_DECL_NOTHROW
+{
+ return qHash(QRawFontPrivate::get(font)->fontEngine, seed);
+}
+
+
+/*!
\fn bool QRawFont::operator!=(const QRawFont &other) const
Returns \c true if this QRawFont is not equal to \a other. Otherwise, returns \c false.
diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h
index 0252e62370..470f2694e4 100644
--- a/src/gui/text/qrawfont.h
+++ b/src/gui/text/qrawfont.h
@@ -158,6 +158,8 @@ Q_DECLARE_SHARED(QRawFont)
Q_DECLARE_OPERATORS_FOR_FLAGS(QRawFont::LayoutFlags)
+Q_GUI_EXPORT uint qHash(const QRawFont &font, uint seed = 0) Q_DECL_NOTHROW;
+
inline QVector<QPointF> QRawFont::advancesForGlyphIndexes(const QVector<quint32> &glyphIndexes, QRawFont::LayoutFlags layoutFlags) const
{
QVector<QPointF> advances(glyphIndexes.size());
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 61bab2dbfd..5e9fac5f86 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -1785,6 +1785,10 @@ QTextBlock QTextDocument::lastBlock() const
\property QTextDocument::pageSize
\brief the page size that should be used for laying out the document
+ The units are determined by the underlying paint device. The size is
+ measured in logical pixels when painting to the screen, and in points
+ (1/72 inch) when painting to a printer.
+
By default, for a newly-created, empty document, this property contains
an undefined size.
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index 8adeb3e659..39fec032dc 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -3409,8 +3409,7 @@ int QTextFormatCollection::indexForFormat(const QTextFormat &format)
f.d = new QTextFormatPrivate;
f.d->resolveFont(defaultFnt);
- if (!hashes.contains(hash, idx))
- hashes.insert(hash, idx);
+ hashes.insert(hash, idx);
} QT_CATCH(...) {
formats.pop_back();
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index adaac11517..023a1b7f52 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1059,9 +1059,10 @@ QList<QGlyphRun> QTextLayout::glyphRuns(int from, int length) const
QGlyphRun::GlyphRunFlags flags = glyphRun.flags();
QPair<QFontEngine *, int> key(fontEngine, int(flags));
// merge the glyph runs using the same font
- if (glyphRunHash.contains(key)) {
- QGlyphRun &oldGlyphRun = glyphRunHash[key];
-
+ QGlyphRun &oldGlyphRun = glyphRunHash[key];
+ if (oldGlyphRun.isEmpty()) {
+ oldGlyphRun = glyphRun;
+ } else {
QVector<quint32> indexes = oldGlyphRun.glyphIndexes();
QVector<QPointF> positions = oldGlyphRun.positions();
QRectF boundingRect = oldGlyphRun.boundingRect();
@@ -1073,8 +1074,6 @@ QList<QGlyphRun> QTextLayout::glyphRuns(int from, int length) const
oldGlyphRun.setGlyphIndexes(indexes);
oldGlyphRun.setPositions(positions);
oldGlyphRun.setBoundingRect(boundingRect);
- } else {
- glyphRunHash[key] = glyphRun;
}
}
}
@@ -1908,11 +1907,15 @@ void QTextLine::layout_helper(int maxGlyphs)
++lbh.glyphCount;
if (lbh.checkFullOtherwiseExtend(line))
goto found;
- } else if (attributes[lbh.currentPosition].whiteSpace) {
+ } else if (attributes[lbh.currentPosition].whiteSpace
+ && eng->layoutData->string.at(lbh.currentPosition).decompositionTag() != QChar::NoBreak) {
lbh.whiteSpaceOrObject = true;
- while (lbh.currentPosition < end && attributes[lbh.currentPosition].whiteSpace)
+ while (lbh.currentPosition < end
+ && attributes[lbh.currentPosition].whiteSpace
+ && eng->layoutData->string.at(lbh.currentPosition).decompositionTag() != QChar::NoBreak) {
addNextCluster(lbh.currentPosition, end, lbh.spaceData, lbh.glyphCount,
current, lbh.logClusters, lbh.glyphs);
+ }
if (!lbh.manualWrap && lbh.spaceData.textWidth > line.width) {
lbh.spaceData.textWidth = line.width; // ignore spaces that fall out of the line.
diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri
index c1c52f2d1a..a15793ec2f 100644
--- a/src/gui/text/text.pri
+++ b/src/gui/text/text.pri
@@ -32,11 +32,7 @@ HEADERS += \
text/qtextlist.h \
text/qsyntaxhighlighter.h \
text/qtextdocumentwriter.h \
- text/qcssparser_p.h \
text/qtexttable_p.h \
- text/qzipreader_p.h \
- text/qzipwriter_p.h \
- text/qtextodfwriter_p.h \
text/qstatictext_p.h \
text/qstatictext.h \
text/qrawfont.h \
@@ -70,9 +66,6 @@ SOURCES += \
text/qtextlist.cpp \
text/qtextdocumentwriter.cpp \
text/qsyntaxhighlighter.cpp \
- text/qcssparser.cpp \
- text/qzip.cpp \
- text/qtextodfwriter.cpp \
text/qstatictext.cpp \
text/qrawfont.cpp \
text/qglyphrun.cpp \
@@ -93,3 +86,20 @@ qtConfig(harfbuzz)|qtConfig(system-harfbuzz) {
SOURCES += text/qharfbuzzng.cpp
HEADERS += text/qharfbuzzng_p.h
}
+
+qtConfig(textodfwriter) {
+ HEADERS += \
+ text/qtextodfwriter_p.h \
+ text/qzipreader_p.h \
+ text/qzipwriter_p.h
+ SOURCES += \
+ text/qtextodfwriter.cpp \
+ text/qzip.cpp
+}
+
+qtConfig(cssparser) {
+ HEADERS += \
+ text/qcssparser_p.h
+ SOURCES += \
+ text/qcssparser.cpp
+}
diff --git a/src/network/access/qnetworkcookiejar.cpp b/src/network/access/qnetworkcookiejar.cpp
index 0540cb740f..232c2b47a5 100644
--- a/src/network/access/qnetworkcookiejar.cpp
+++ b/src/network/access/qnetworkcookiejar.cpp
@@ -43,7 +43,9 @@
#include "QtNetwork/qnetworkcookie.h"
#include "QtCore/qurl.h"
#include "QtCore/qdatetime.h"
+#if QT_CONFIG(topleveldomain)
#include "private/qtldurl_p.h"
+#endif
QT_BEGIN_NAMESPACE
diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp
index 62bc8ca683..3daca38959 100644
--- a/src/network/socket/qnativesocketengine_winrt.cpp
+++ b/src/network/socket/qnativesocketengine_winrt.cpp
@@ -662,10 +662,10 @@ qint64 QNativeSocketEngine::read(char *data, qint64 maxlen)
if (d->socketType != QAbstractSocket::TcpSocket)
return -1;
- QMutexLocker mutexLocker(&d->readMutex);
// There will be a read notification when the socket was closed by the remote host. If that
// happens and there isn't anything left in the buffer, we have to return -1 in order to signal
// the closing of the socket.
+ QMutexLocker mutexLocker(&d->readMutex);
if (d->readBytes.pos() == d->readBytes.size() && d->socketState != QAbstractSocket::ConnectedState) {
close();
return -1;
@@ -718,7 +718,7 @@ qint64 QNativeSocketEngine::readDatagram(char *data, qint64 maxlen, QIpPacketHea
QByteArray readOrigin;
// Do not read the whole datagram. Put the rest of it back into the "queue"
if (maxlen < datagram.data.length()) {
- QByteArray readOrigin = datagram.data.left(maxlen);
+ readOrigin = datagram.data.left(maxlen);
datagram.data = datagram.data.remove(0, maxlen);
d->pendingDatagrams.prepend(datagram);
} else {
diff --git a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc
index 241dff05da..f0ef5ee2a7 100644
--- a/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc
+++ b/src/platformheaders/xcbfunctions/qxcbwindowfunctions.qdoc
@@ -86,6 +86,35 @@
*/
/*!
+ \typedef QXcbWindowFunctions::SetWmWindowRole
+ \since 5.6.2
+
+ This is the typedef for the function returned by
+ QGuiApplication::platformFunction when passed the
+ value returned by setWmWindowRoleIdentifier().
+*/
+
+/*!
+ \fn QByteArray QXcbWindowFunctions::setWmWindowRoleIdentifier()
+ \since 5.6.2
+
+ This function returns the byte array that can be used to query
+ QGuiApplication::platformFunction to retrieve the SetWmWindowRole function.
+*/
+
+/*!
+ \fn void QXcbWindowFunctions::setWmWindowRole(QWindow *window, const QByteArray &role)
+ \since 5.6.2
+
+ Sets the WM_WINDOW_ROLE property from \role on the corresponding
+ X11 window.
+
+ This is a convenience function that can be used directly instead
+ of resolving the function pointer. \a window and \a role will be
+ relayed to the function retrieved by QGuiApplication.
+*/
+
+/*!
\typedef QXcbWindowFunctions::SetWmWindowIconText
This is the typedef for the function returned by
diff --git a/src/platformsupport/eglconvenience/qt_egl_p.h b/src/platformsupport/eglconvenience/qt_egl_p.h
index 615ee4b80a..b1495c9f9d 100644
--- a/src/platformsupport/eglconvenience/qt_egl_p.h
+++ b/src/platformsupport/eglconvenience/qt_egl_p.h
@@ -83,7 +83,7 @@ struct QtEglConverter<uint32_t, uintptr_t>
{ return v; }
};
-#if Q_PROCESSOR_WORDSIZE > 4
+#if QT_POINTER_SIZE > 4
template <>
struct QtEglConverter<uintptr_t, uint32_t>
{
diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
index d92b87c6da..65bc494e91 100644
--- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
@@ -117,7 +117,7 @@ static inline int stretchFromFcWidth(int fcwidth)
return qtstretch;
}
-static const char *specialLanguages[] = {
+static const char specialLanguages[][6] = {
"", // Unknown
"", // Inherited
"", // Common
@@ -251,12 +251,12 @@ static const char *specialLanguages[] = {
"", // OldHungarian
"" // SignWriting
};
-Q_STATIC_ASSERT(sizeof(specialLanguages) / sizeof(const char *) == QChar::ScriptCount);
+Q_STATIC_ASSERT(sizeof specialLanguages / sizeof *specialLanguages == QChar::ScriptCount);
// this could become a list of all languages used for each writing
// system, instead of using the single most common language.
-static const char *languageForWritingSystem[] = {
- 0, // Any
+static const char languageForWritingSystem[][6] = {
+ "", // Any
"en", // Latin
"el", // Greek
"ru", // Cyrillic
@@ -286,25 +286,25 @@ static const char *languageForWritingSystem[] = {
"ja", // Japanese
"ko", // Korean
"vi", // Vietnamese
- 0, // Symbol
+ "", // Symbol
"sga", // Ogham
"non", // Runic
"man" // N'Ko
};
-Q_STATIC_ASSERT(sizeof(languageForWritingSystem) / sizeof(const char *) == QFontDatabase::WritingSystemsCount);
+Q_STATIC_ASSERT(sizeof languageForWritingSystem / sizeof *languageForWritingSystem == QFontDatabase::WritingSystemsCount);
#if FC_VERSION >= 20297
// Newer FontConfig let's us sort out fonts that report certain scripts support,
// but no open type tables for handling them correctly.
// Check the reported script presence in the FC_CAPABILITY's "otlayout:" section.
-static const char *capabilityForWritingSystem[] = {
- 0, // Any
- 0, // Latin
- 0, // Greek
- 0, // Cyrillic
- 0, // Armenian
- 0, // Hebrew
- 0, // Arabic
+static const char capabilityForWritingSystem[][5] = {
+ "", // Any
+ "", // Latin
+ "", // Greek
+ "", // Cyrillic
+ "", // Armenian
+ "", // Hebrew
+ "", // Arabic
"syrc", // Syriac
"thaa", // Thaana
"deva", // Devanagari
@@ -317,20 +317,20 @@ static const char *capabilityForWritingSystem[] = {
"knda", // Kannada
"mlym", // Malayalam
"sinh", // Sinhala
- 0, // Thai
- 0, // Lao
+ "", // Thai
+ "", // Lao
"tibt", // Tibetan
"mymr", // Myanmar
- 0, // Georgian
+ "", // Georgian
"khmr", // Khmer
- 0, // SimplifiedChinese
- 0, // TraditionalChinese
- 0, // Japanese
- 0, // Korean
- 0, // Vietnamese
- 0, // Symbol
- 0, // Ogham
- 0, // Runic
+ "", // SimplifiedChinese
+ "", // TraditionalChinese
+ "", // Japanese
+ "", // Korean
+ "", // Vietnamese
+ "", // Symbol
+ "", // Ogham
+ "", // Runic
"nko " // N'Ko
};
Q_STATIC_ASSERT(sizeof(capabilityForWritingSystem) / sizeof(*capabilityForWritingSystem) == QFontDatabase::WritingSystemsCount);
@@ -436,7 +436,7 @@ static void populateFromPattern(FcPattern *pattern)
FcLangResult langRes = FcLangSetHasLang(langset, lang);
if (langRes != FcLangDifferentLang) {
#if FC_VERSION >= 20297
- if (capabilityForWritingSystem[j] != Q_NULLPTR && requiresOpenType(j)) {
+ if (*capabilityForWritingSystem[j] && requiresOpenType(j)) {
if (cap == Q_NULLPTR)
capRes = FcPatternGetString(pattern, FC_CAPABILITY, 0, &cap);
if (capRes == FcResultMatch && strstr(reinterpret_cast<const char *>(cap), capabilityForWritingSystem[j]) == 0)
diff --git a/src/platformsupport/fontdatabases/fontdatabases.pro b/src/platformsupport/fontdatabases/fontdatabases.pro
index f2c0ae4d96..49dead4668 100644
--- a/src/platformsupport/fontdatabases/fontdatabases.pro
+++ b/src/platformsupport/fontdatabases/fontdatabases.pro
@@ -24,6 +24,10 @@ darwin {
win32:!winrt {
include($$PWD/windows/windows.pri)
}
+
+ winrt {
+ include($$PWD/winrt/winrt.pri)
+ }
}
load(qt_module)
diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
index 434aa16d16..b8d997bc35 100644
--- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
+++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
@@ -524,10 +524,11 @@ namespace {
const void *key = *reinterpret_cast<void * const *>(fontFileReferenceKey);
*fontFileStream = NULL;
- if (!m_fontDatas.contains(key))
+ auto it = m_fontDatas.constFind(key);
+ if (it == m_fontDatas.constEnd())
return E_FAIL;
- QByteArray fontData = m_fontDatas.value(key);
+ QByteArray fontData = it.value();
DirectWriteFontFileStream *stream = new DirectWriteFontFileStream(fontData);
stream->AddRef();
*fontFileStream = stream;
@@ -1583,7 +1584,7 @@ QString QWindowsFontDatabase::fontDir() const
bool QWindowsFontDatabase::fontsAlwaysScalable() const
{
- return true;
+ return false;
}
void QWindowsFontDatabase::derefUniqueFont(const QString &uniqueFont)
diff --git a/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp b/src/platformsupport/fontdatabases/winrt/qwinrtfontdatabase.cpp
index d4f2ba1bd6..f214184c36 100644
--- a/src/plugins/platforms/winrt/qwinrtfontdatabase.cpp
+++ b/src/platformsupport/fontdatabases/winrt/qwinrtfontdatabase.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include "qwinrtfontdatabase.h"
+#include "qwinrtfontdatabase_p.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QFile>
diff --git a/src/plugins/platforms/winrt/qwinrtfontdatabase.h b/src/platformsupport/fontdatabases/winrt/qwinrtfontdatabase_p.h
index 8fed4a3fa7..9559bac0a8 100644
--- a/src/plugins/platforms/winrt/qwinrtfontdatabase.h
+++ b/src/platformsupport/fontdatabases/winrt/qwinrtfontdatabase_p.h
@@ -40,6 +40,17 @@
#ifndef QWINRTFONTDATABASE_H
#define QWINRTFONTDATABASE_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <QtFontDatabaseSupport/private/qbasicfontdatabase_p.h>
#include <QtCore/QLoggingCategory>
diff --git a/src/platformsupport/fontdatabases/winrt/winrt.pri b/src/platformsupport/fontdatabases/winrt/winrt.pri
new file mode 100644
index 0000000000..4875338182
--- /dev/null
+++ b/src/platformsupport/fontdatabases/winrt/winrt.pri
@@ -0,0 +1,11 @@
+QT *= gui-private
+
+SOURCES += \
+ $$PWD/qwinrtfontdatabase.cpp
+
+HEADERS += \
+ $$PWD/qwinrtfontdatabase_p.h
+
+DEFINES += __WRL_NO_DEFAULT_LIB__
+
+LIBS += $$QMAKE_LIBS_CORE -ldwrite
diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
index 3a5a0c8e78..e53c085e41 100644
--- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
@@ -45,36 +45,19 @@
#include "qcocoacolordialoghelper.h"
#include "qcocoahelpers.h"
+#include "qcocoaeventdispatcher.h"
#import <AppKit/AppKit.h>
QT_USE_NAMESPACE
-static NSButton *macCreateButton(const char *text, NSView *superview)
-{
- static const NSRect buttonFrameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } };
-
- NSButton *button = [[NSButton alloc] initWithFrame:buttonFrameRect];
- [button setButtonType:NSMomentaryLightButton];
- [button setBezelStyle:NSRoundedBezelStyle];
- [button setTitle:(NSString*)(CFStringRef)QCFString(
- QPlatformTheme::removeMnemonics(QCoreApplication::translate("QPlatformTheme", text)))];
- [[button cell] setFont:[NSFont systemFontOfSize:
- [NSFont systemFontSizeForControlSize:NSRegularControlSize]]];
- [superview addSubview:button];
- return button;
-}
-
-@class QT_MANGLE_NAMESPACE(QNSColorPanelDelegate);
-
-@interface QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) : NSObject<NSWindowDelegate>
+@interface QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) : NSObject<NSWindowDelegate, QT_MANGLE_NAMESPACE(QNSPanelDelegate)>
{
@public
NSColorPanel *mColorPanel;
QCocoaColorDialogHelper *mHelper;
NSView *mStolenContentView;
- NSButton *mOkButton;
- NSButton *mCancelButton;
+ QNSPanelContentsWrapper *mPanelButtons;
QColor mQtColor;
NSInteger mResultCode;
BOOL mDialogIsExecuting;
@@ -82,7 +65,6 @@ static NSButton *macCreateButton(const char *text, NSView *superview)
BOOL mClosingDueToKnownButton;
};
- (void)restoreOriginalContentView;
-- (void)relayout;
- (void)updateQtColor;
- (void)finishOffWithCode:(NSInteger)code;
@end
@@ -97,8 +79,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
mColorPanel = [NSColorPanel sharedColorPanel];
mHelper = 0;
mStolenContentView = 0;
- mOkButton = 0;
- mCancelButton = 0;
+ mPanelButtons = nil;
mResultCode = NSCancelButton;
mDialogIsExecuting = false;
mResultSet = false;
@@ -142,23 +123,10 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
[mColorPanel setContentView:0];
// create a new content view and add the stolen one as a subview
- NSRect frameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } };
- NSView *ourContentView = [[NSView alloc] initWithFrame:frameRect];
- [ourContentView addSubview:mStolenContentView];
-
- // create OK and Cancel buttons and add these as subviews
- mOkButton = macCreateButton("&OK", ourContentView);
- mCancelButton = macCreateButton("Cancel", ourContentView);
-
- [mColorPanel setContentView:ourContentView];
- [mColorPanel setDefaultButtonCell:[mOkButton cell]];
- [self relayout];
-
- [mOkButton setAction:@selector(onOkClicked)];
- [mOkButton setTarget:self];
-
- [mCancelButton setAction:@selector(onCancelClicked)];
- [mCancelButton setTarget:self];
+ mPanelButtons = [[QNSPanelContentsWrapper alloc] initWithPanelDelegate:self];
+ [mPanelButtons addSubview:mStolenContentView];
+ mColorPanel.contentView = mPanelButtons;
+ mColorPanel.defaultButtonCell = mPanelButtons.okButton.cell;
}
}
@@ -167,12 +135,6 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
[mColorPanel close];
}
-- (void)windowDidResize:(NSNotification *)notification
-{
- Q_UNUSED(notification);
- [self relayout];
-}
-
- (void)colorChanged:(NSNotification *)notification
{
Q_UNUSED(notification);
@@ -182,7 +144,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
- (void)windowWillClose:(NSNotification *)notification
{
Q_UNUSED(notification);
- if (mCancelButton && mHelper && !mClosingDueToKnownButton) {
+ if (mPanelButtons && mHelper && !mClosingDueToKnownButton) {
mClosingDueToKnownButton = true; // prevent repeating emit
emit mHelper->reject();
}
@@ -191,68 +153,16 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
- (void)restoreOriginalContentView
{
if (mStolenContentView) {
- NSView *ourContentView = [mColorPanel contentView];
-
// return stolen stuff to its rightful owner
[mStolenContentView removeFromSuperview];
[mColorPanel setContentView:mStolenContentView];
- [mOkButton release];
- [mCancelButton release];
- [ourContentView release];
- mOkButton = 0;
- mCancelButton = 0;
- mStolenContentView = 0;
+ [mStolenContentView release];
+ mStolenContentView = nil;
+ [mPanelButtons release];
+ mPanelButtons = nil;
}
}
-- (void)relayout
-{
- if (!mOkButton)
- return;
-
- NSRect rect = [[mStolenContentView superview] frame];
-
- // should a priori be kept in sync with qfontdialog_mac.mm
- const CGFloat ButtonMinWidth = 78.0; // 84.0 for Carbon
- const CGFloat ButtonMinHeight = 32.0;
- const CGFloat ButtonSpacing = 0.0;
- const CGFloat ButtonTopMargin = 0.0;
- const CGFloat ButtonBottomMargin = 7.0;
- const CGFloat ButtonSideMargin = 9.0;
-
- [mOkButton sizeToFit];
- NSSize okSizeHint = [mOkButton frame].size;
-
- [mCancelButton sizeToFit];
- NSSize cancelSizeHint = [mCancelButton frame].size;
-
- const CGFloat ButtonWidth = qMin(qMax(ButtonMinWidth,
- qMax(okSizeHint.width, cancelSizeHint.width)),
- CGFloat((rect.size.width - 2.0 * ButtonSideMargin - ButtonSpacing) * 0.5));
- const CGFloat ButtonHeight = qMax(ButtonMinHeight,
- qMax(okSizeHint.height, cancelSizeHint.height));
-
- NSRect okRect = { { rect.size.width - ButtonSideMargin - ButtonWidth,
- ButtonBottomMargin },
- { ButtonWidth, ButtonHeight } };
- [mOkButton setFrame:okRect];
- [mOkButton setNeedsDisplay:YES];
-
- NSRect cancelRect = { { okRect.origin.x - ButtonSpacing - ButtonWidth,
- ButtonBottomMargin },
- { ButtonWidth, ButtonHeight } };
- [mCancelButton setFrame:cancelRect];
- [mCancelButton setNeedsDisplay:YES];
-
- const CGFloat Y = ButtonBottomMargin + ButtonHeight + ButtonTopMargin;
- NSRect stolenCVRect = { { 0.0, Y },
- { rect.size.width, rect.size.height - Y } };
- [mStolenContentView setFrame:stolenCVRect];
- [mStolenContentView setNeedsDisplay:YES];
-
- [[mStolenContentView superview] setNeedsDisplay:YES];
-}
-
- (void)onOkClicked
{
mClosingDueToKnownButton = true;
@@ -263,7 +173,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
- (void)onCancelClicked
{
- if (mOkButton) {
+ if (mPanelButtons) {
mClosingDueToKnownButton = true;
[mColorPanel close];
mQtColor = QColor();
@@ -322,6 +232,10 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
// cleanup of modal sessions. Do this before showing the native dialog, otherwise it will
// close down during the cleanup.
qApp->processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers);
+
+ // Make sure we don't interrupt the runModalForWindow call.
+ QCocoaEventDispatcher::clearCurrentThreadCocoaEventDispatcherInterruptFlag();
+
[NSApp runModalForWindow:mColorPanel];
mDialogIsExecuting = false;
return (mResultCode == NSOKButton);
@@ -335,7 +249,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
- (BOOL)windowShouldClose:(id)window
{
Q_UNUSED(window);
- if (!mOkButton)
+ if (!mPanelButtons)
[self updateQtColor];
if (mDialogIsExecuting) {
[self finishOffWithCode:NSCancelButton];
diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm
index 8e523dfbbf..3df2a7c962 100644
--- a/src/plugins/platforms/cocoa/qcocoacursor.mm
+++ b/src/plugins/platforms/cocoa/qcocoacursor.mm
@@ -62,7 +62,7 @@ QCocoaCursor::~QCocoaCursor()
void QCocoaCursor::changeCursor(QCursor *cursor, QWindow *window)
{
- NSCursor * cocoaCursor = convertCursor(cursor);
+ NSCursor *cocoaCursor = convertCursor(cursor);
if (QPlatformWindow * platformWindow = window->handle())
static_cast<QCocoaWindow *>(platformWindow)->setWindowCursor(cocoaCursor);
@@ -84,9 +84,12 @@ void QCocoaCursor::setPos(const QPoint &position)
CFRelease(e);
}
-NSCursor *QCocoaCursor::convertCursor(QCursor * cursor)
+NSCursor *QCocoaCursor::convertCursor(QCursor *cursor)
{
- const Qt::CursorShape newShape = cursor ? cursor->shape() : Qt::ArrowCursor;
+ if (cursor == Q_NULLPTR)
+ return 0;
+
+ const Qt::CursorShape newShape = cursor->shape();
NSCursor *cocoaCursor;
// Check for a suitable built-in NSCursor first:
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
index 84880d51c5..70887c41c9 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
@@ -131,6 +131,8 @@ public:
void interrupt();
void flush();
+ static void clearCurrentThreadCocoaEventDispatcherInterruptFlag();
+
friend void qt_mac_maybeCancelWaitForMoreEventsForwarder(QAbstractEventDispatcher *eventDispatcher);
};
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
index b2b9fe2c1e..72c7856c2d 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
@@ -965,6 +965,19 @@ void QCocoaEventDispatcher::interrupt()
void QCocoaEventDispatcher::flush()
{ }
+// QTBUG-56746: The behavior of processEvents() has been changed to not clear
+// the interrupt flag. Use this function to clear it.
+ void QCocoaEventDispatcher::clearCurrentThreadCocoaEventDispatcherInterruptFlag()
+{
+ QCocoaEventDispatcher *cocoaEventDispatcher =
+ qobject_cast<QCocoaEventDispatcher *>(QThread::currentThread()->eventDispatcher());
+ if (!cocoaEventDispatcher)
+ return;
+ QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate =
+ static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher));
+ cocoaEventDispatcherPrivate->interrupt = false;
+}
+
QCocoaEventDispatcher::~QCocoaEventDispatcher()
{
Q_D(QCocoaEventDispatcher);
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
index 7706f39198..41a809cdd2 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
@@ -53,6 +53,7 @@
#include "qt_mac_p.h"
#include "qcocoahelpers.h"
#include "qcocoamenubar.h"
+#include "qcocoaeventdispatcher.h"
#include <qregexp.h>
#include <qbuffer.h>
#include <qdebug.h>
@@ -251,6 +252,10 @@ static QString strippedText(QString s)
// cleanup of modal sessions. Do this before showing the native dialog, otherwise it will
// close down during the cleanup.
qApp->processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers);
+
+ // Make sure we don't interrupt the runModal call below.
+ QCocoaEventDispatcher::clearCurrentThreadCocoaEventDispatcherInterruptFlag();
+
QCocoaMenuBar::redirectKnownMenuItemsToFirstResponder();
mReturnCode = [mSavePanel runModal];
QCocoaMenuBar::resetKnownMenuItemsToQt();
diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
index 0be931b54f..33dd4260a5 100644
--- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
@@ -49,6 +49,7 @@
#include "qcocoafontdialoghelper.h"
#include "qcocoahelpers.h"
+#include "qcocoaeventdispatcher.h"
#import <AppKit/AppKit.h>
@@ -58,33 +59,6 @@ typedef float CGFloat; // Should only not be defined on 32-bit platforms
QT_USE_NAMESPACE
-// should a priori be kept in sync with qcolordialog_mac.mm
-const CGFloat ButtonMinWidth = 78.0;
-const CGFloat ButtonMinHeight = 32.0;
-const CGFloat ButtonSpacing = 0.0;
-const CGFloat ButtonTopMargin = 0.0;
-const CGFloat ButtonBottomMargin = 7.0;
-const CGFloat ButtonSideMargin = 9.0;
-
-// looks better with some margins
-const CGFloat DialogTopMargin = 7.0;
-const CGFloat DialogSideMargin = 9.0;
-
-static NSButton *macCreateButton(const char *text, NSView *superview)
-{
- static const NSRect buttonFrameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } };
-
- NSButton *button = [[NSButton alloc] initWithFrame:buttonFrameRect];
- [button setButtonType:NSMomentaryLightButton];
- [button setBezelStyle:NSRoundedBezelStyle];
- [button setTitle:(NSString*)(CFStringRef)QCFString(
- QPlatformTheme::removeMnemonics(QCoreApplication::translate("QDialogButtonBox", text)))];
- [[button cell] setFont:[NSFont systemFontOfSize:
- [NSFont systemFontSizeForControlSize:NSRegularControlSize]]];
- [superview addSubview:button];
- return button;
-}
-
static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
{
QFont newFont;
@@ -103,22 +77,19 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
@class QT_MANGLE_NAMESPACE(QNSFontPanelDelegate);
-@interface QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) : NSObject<NSWindowDelegate>
+@interface QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) : NSObject<NSWindowDelegate, QT_MANGLE_NAMESPACE(QNSPanelDelegate)>
{
@public
NSFontPanel *mFontPanel;
QCocoaFontDialogHelper *mHelper;
NSView *mStolenContentView;
- NSButton *mOkButton;
- NSButton *mCancelButton;
+ QNSPanelContentsWrapper *mPanelButtons;
QFont mQtFont;
NSInteger mResultCode;
BOOL mDialogIsExecuting;
BOOL mResultSet;
};
- (void)restoreOriginalContentView;
-- (void)relayout;
-- (void)relayoutToContentSize:(NSSize)frameSize;
- (void)updateQtFont;
- (void)changeFont:(id)sender;
- (void)finishOffWithCode:(NSInteger)code;
@@ -134,8 +105,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
mFontPanel = [NSFontPanel sharedFontPanel];
mHelper = 0;
mStolenContentView = 0;
- mOkButton = 0;
- mCancelButton = 0;
+ mPanelButtons = 0;
mResultCode = NSCancelButton;
mDialogIsExecuting = false;
mResultSet = false;
@@ -173,23 +143,11 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
[mFontPanel setContentView:0];
// create a new content view and add the stolen one as a subview
- NSRect frameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } };
- NSView *ourContentView = [[NSView alloc] initWithFrame:frameRect];
- [ourContentView addSubview:mStolenContentView];
-
- // create OK and Cancel buttons and add these as subviews
- mOkButton = macCreateButton("&OK", ourContentView);
- mCancelButton = macCreateButton("Cancel", ourContentView);
-
- [mFontPanel setContentView:ourContentView];
- [mFontPanel setDefaultButtonCell:[mOkButton cell]];
- [self relayoutToContentSize:[[mStolenContentView superview] frame].size];
-
- [mOkButton setAction:@selector(onOkClicked)];
- [mOkButton setTarget:self];
-
- [mCancelButton setAction:@selector(onCancelClicked)];
- [mCancelButton setTarget:self];
+ mPanelButtons = [[QNSPanelContentsWrapper alloc] initWithPanelDelegate:self];
+ [mPanelButtons addSubview:mStolenContentView];
+ mPanelButtons.panelContentsMargins = NSEdgeInsetsMake(0, 0, 7, 0);
+ mFontPanel.contentView = mPanelButtons;
+ mFontPanel.defaultButtonCell = mPanelButtons.okButton.cell;
}
}
@@ -198,77 +156,18 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
[mFontPanel close];
}
-- (void)windowDidResize:(NSNotification *)notification
-{
- Q_UNUSED(notification);
- [self relayout];
-}
-
- (void)restoreOriginalContentView
{
if (mStolenContentView) {
- NSView *ourContentView = [mFontPanel contentView];
-
// return stolen stuff to its rightful owner
[mStolenContentView removeFromSuperview];
[mFontPanel setContentView:mStolenContentView];
- [mOkButton release];
- [mCancelButton release];
- [ourContentView release];
- mOkButton = 0;
- mCancelButton = 0;
mStolenContentView = 0;
+ [mPanelButtons release];
+ mPanelButtons = nil;
}
}
-- (void)relayout
-{
- if (!mOkButton)
- return;
-
- [self relayoutToContentSize:[[mStolenContentView superview] frame].size];
-}
-
-- (void)relayoutToContentSize:(NSSize)frameSize
-{
- Q_ASSERT(mOkButton);
-
- [mOkButton sizeToFit];
- NSSize okSizeHint = [mOkButton frame].size;
-
- [mCancelButton sizeToFit];
- NSSize cancelSizeHint = [mCancelButton frame].size;
-
- const CGFloat ButtonWidth = qMin(qMax(ButtonMinWidth,
- qMax(okSizeHint.width, cancelSizeHint.width)),
- CGFloat((frameSize.width - 2.0 * ButtonSideMargin - ButtonSpacing) * 0.5));
- const CGFloat ButtonHeight = qMax(ButtonMinHeight,
- qMax(okSizeHint.height, cancelSizeHint.height));
-
- const CGFloat X = DialogSideMargin;
- const CGFloat Y = ButtonBottomMargin + ButtonHeight + ButtonTopMargin;
-
- NSRect okRect = { { frameSize.width - ButtonSideMargin - ButtonWidth,
- ButtonBottomMargin },
- { ButtonWidth, ButtonHeight } };
- [mOkButton setFrame:okRect];
- [mOkButton setNeedsDisplay:YES];
-
- NSRect cancelRect = { { okRect.origin.x - ButtonSpacing - ButtonWidth,
- ButtonBottomMargin },
- { ButtonWidth, ButtonHeight } };
- [mCancelButton setFrame:cancelRect];
- [mCancelButton setNeedsDisplay:YES];
-
- NSRect stolenCVRect = { { X, Y },
- { frameSize.width - X - X, frameSize.height - Y - DialogTopMargin } };
- [mStolenContentView setFrame:stolenCVRect];
- [mStolenContentView setNeedsDisplay:YES];
-
- [[mStolenContentView superview] setNeedsDisplay:YES];
-}
-
-
- (void)onOkClicked
{
[mFontPanel close];
@@ -277,7 +176,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
- (void)onCancelClicked
{
- if (mOkButton) {
+ if (mPanelButtons) {
[mFontPanel close];
mQtFont = QFont();
[self finishOffWithCode:NSCancelButton];
@@ -319,6 +218,10 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
// cleanup of modal sessions. Do this before showing the native dialog, otherwise it will
// close down during the cleanup.
qApp->processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers);
+
+ // Make sure we don't interrupt the runModalForWindow call.
+ QCocoaEventDispatcher::clearCurrentThreadCocoaEventDispatcherInterruptFlag();
+
[NSApp runModalForWindow:mFontPanel];
mDialogIsExecuting = false;
return (mResultCode == NSOKButton);
@@ -332,7 +235,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
- (BOOL)windowShouldClose:(id)window
{
Q_UNUSED(window);
- if (!mOkButton)
+ if (!mPanelButtons)
[self updateQtFont];
if (mDialogIsExecuting) {
[self finishOffWithCode:NSCancelButton];
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h
index 1b038a6b5e..a2e0876073 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.h
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.h
@@ -158,7 +158,30 @@ T qt_mac_resolveOption(const T &fallback, QWindow *window, const QByteArray &pro
// return default value.
return fallback;
}
+
QT_END_NAMESPACE
+@protocol QT_MANGLE_NAMESPACE(QNSPanelDelegate)
+@required
+- (void)onOkClicked;
+- (void)onCancelClicked;
+@end
+
+@interface QT_MANGLE_NAMESPACE(QNSPanelContentsWrapper) : NSView
+
+@property (nonatomic, readonly) NSButton *okButton;
+@property (nonatomic, readonly) NSButton *cancelButton;
+@property (nonatomic, readonly) NSView *panelContents; // ARC: unretained, make it weak
+@property (nonatomic, assign) NSEdgeInsets panelContentsMargins;
+
+- (instancetype)initWithPanelDelegate:(id<QT_MANGLE_NAMESPACE(QNSPanelDelegate)>)panelDelegate;
+- (void)dealloc;
+
+- (NSButton *)createButtonWithTitle:(const char *)title;
+- (void)layout;
+@end
+
+QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSPanelContentsWrapper);
+
#endif //QCOCOAHELPERS_H
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm
index b092d013c5..fa0365dbf7 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.mm
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm
@@ -298,3 +298,117 @@ QString qt_mac_removeAmpersandEscapes(QString s)
}
QT_END_NAMESPACE
+
+/*! \internal
+
+ This NSView derived class is used to add OK/Cancel
+ buttons to NSColorPanel and NSFontPanel. It replaces
+ the panel's content view, while reparenting the former
+ content view into itself. It also takes care of setting
+ the target-action for the OK/Cancel buttons and making
+ sure the layout is consistent.
+ */
+@implementation QNSPanelContentsWrapper
+
+- (instancetype)initWithPanelDelegate:(id<QT_MANGLE_NAMESPACE(QNSPanelDelegate)>)panelDelegate
+{
+ if ((self = [super initWithFrame:NSZeroRect])) {
+ // create OK and Cancel buttons and add these as subviews
+ _okButton = [self createButtonWithTitle:"&OK"];
+ _okButton.action = @selector(onOkClicked);
+ _okButton.target = panelDelegate;
+
+ _cancelButton = [self createButtonWithTitle:"Cancel"];
+ _cancelButton.action = @selector(onCancelClicked);
+ _cancelButton.target = panelDelegate;
+
+ _panelContents = nil;
+
+ _panelContentsMargins = NSEdgeInsetsMake(0, 0, 0, 0);
+ }
+
+ return self;
+}
+
+- (void)dealloc
+{
+ [_okButton release];
+ _okButton = nil;
+ [_cancelButton release];
+ _cancelButton = nil;
+
+ _panelContents = nil;
+
+ [super dealloc];
+}
+
+- (NSButton *)createButtonWithTitle:(const char *)title
+{
+ NSButton *button = [[NSButton alloc] initWithFrame:NSZeroRect];
+ button.buttonType = NSMomentaryLightButton;
+ button.bezelStyle = NSRoundedBezelStyle;
+ const QString &cleanTitle = QPlatformTheme::removeMnemonics(QCoreApplication::translate("QDialogButtonBox", title));
+ // FIXME: Not obvious, from Cocoa's documentation, that QString::toNSString() makes a deep copy
+ button.title = (NSString *)cleanTitle.toCFString();
+ ((NSButtonCell *)button.cell).font =
+ [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]];
+ [self addSubview:button];
+ return button;
+}
+
+- (void)layout
+{
+ static const CGFloat ButtonMinWidth = 78.0; // 84.0 for Carbon
+ static const CGFloat ButtonMinHeight = 32.0;
+ static const CGFloat ButtonSpacing = 0.0;
+ static const CGFloat ButtonTopMargin = 0.0;
+ static const CGFloat ButtonBottomMargin = 7.0;
+ static const CGFloat ButtonSideMargin = 9.0;
+
+ NSSize frameSize = self.frame.size;
+
+ [self.okButton sizeToFit];
+ NSSize okSizeHint = self.okButton.frame.size;
+
+ [self.cancelButton sizeToFit];
+ NSSize cancelSizeHint = self.cancelButton.frame.size;
+
+ const CGFloat buttonWidth = qMin(qMax(ButtonMinWidth,
+ qMax(okSizeHint.width, cancelSizeHint.width)),
+ CGFloat((frameSize.width - 2.0 * ButtonSideMargin - ButtonSpacing) * 0.5));
+ const CGFloat buttonHeight = qMax(ButtonMinHeight,
+ qMax(okSizeHint.height, cancelSizeHint.height));
+
+ NSRect okRect = { { frameSize.width - ButtonSideMargin - buttonWidth,
+ ButtonBottomMargin },
+ { buttonWidth, buttonHeight } };
+ self.okButton.frame = okRect;
+ self.okButton.needsDisplay = YES;
+
+ NSRect cancelRect = { { okRect.origin.x - ButtonSpacing - buttonWidth,
+ ButtonBottomMargin },
+ { buttonWidth, buttonHeight } };
+ self.cancelButton.frame = cancelRect;
+ self.cancelButton.needsDisplay = YES;
+
+ // The third view should be the original panel contents. Cache it.
+ if (!self.panelContents)
+ for (NSView *view in self.subviews)
+ if (view != self.okButton && view != self.cancelButton) {
+ _panelContents = view;
+ break;
+ }
+
+ const CGFloat buttonBoxHeight = ButtonBottomMargin + buttonHeight + ButtonTopMargin;
+ const NSRect panelContentsFrame = NSMakeRect(
+ self.panelContentsMargins.left,
+ buttonBoxHeight + self.panelContentsMargins.bottom,
+ frameSize.width - (self.panelContentsMargins.left + self.panelContentsMargins.right),
+ frameSize.height - buttonBoxHeight - (self.panelContentsMargins.top + self.panelContentsMargins.bottom));
+ self.panelContents.frame = panelContentsFrame;
+ self.panelContents.needsDisplay = YES;
+
+ self.needsDisplay = YES;
+}
+
+@end
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm
index 566363e01f..88ffd48538 100644
--- a/src/plugins/platforms/cocoa/qcocoamenu.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenu.mm
@@ -147,6 +147,10 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaMenuDelegate);
- (void) itemFired:(NSMenuItem*) item
{
QCocoaMenuItem *cocoaItem = reinterpret_cast<QCocoaMenuItem *>([item tag]);
+ // Menu-holding items also get a target to play nicely
+ // with NSMenuValidation but should not trigger.
+ if (cocoaItem->menu())
+ return;
QScopedScopeLevelCounter scopeLevelCounter(QGuiApplicationPrivate::instance()->threadData);
QGuiApplicationPrivate::modifier_buttons = [QNSView convertKeyModifiers:[NSEvent modifierFlags]];
static QMetaMethod activatedSignal = QMetaMethod::fromSignal(&QCocoaMenuItem::activated);
@@ -156,7 +160,8 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaMenuDelegate);
- (BOOL)validateMenuItem:(NSMenuItem*)menuItem
{
QCocoaMenuItem *cocoaItem = reinterpret_cast<QCocoaMenuItem *>(menuItem.tag);
- if (!cocoaItem)
+ // Menu-holding items are always enabled, as it's conventional in Cocoa
+ if (!cocoaItem || cocoaItem->menu())
return YES;
return cocoaItem->isEnabled();
@@ -327,9 +332,9 @@ void QCocoaMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *
void QCocoaMenu::insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem)
{
item->nsItem().target = m_nativeMenu.delegate;
- if (!item->menu())
- [item->nsItem() setAction:@selector(itemFired:)];
- else if (isOpen() && item->nsItem()) // Someone's adding new items after aboutToShow() was emitted
+ item->nsItem().action = @selector(itemFired:);
+ // Someone's adding new items after aboutToShow() was emitted
+ if (isOpen() && item->menu() && item->nsItem())
item->menu()->setAttachedItem(item->nsItem());
item->setParentEnabled(isEnabled());
@@ -425,6 +430,10 @@ void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem)
QCocoaMenuItem* beforeItem = itemOrNull(m_menuItems.indexOf(cocoaItem) + 1);
insertNative(cocoaItem, beforeItem);
+ } else {
+ // Force NSMenuValidation to kick in. This is needed e.g.
+ // when an item's enabled state changes after menuWillOpen:
+ [m_nativeMenu update];
}
}
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h
index 477165607c..26fbe3e4bc 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.h
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h
@@ -100,6 +100,8 @@ private:
*/
Q_INVOKABLE QPixmap defaultBackgroundPixmapForQWizard();
+ Q_INVOKABLE void clearCurrentThreadCocoaEventDispatcherInterruptFlag();
+
// QMacPastebardMime support. The mac pasteboard void pointers are
// QMacPastebardMime instances from the cocoa plugin or qtmacextras
// These two classes are kept in sync and can be casted between.
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
index 10435d0b1d..972230349b 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
@@ -44,6 +44,7 @@
#include "qcocoahelpers.h"
#include "qcocoaapplication.h"
#include "qcocoaintegration.h"
+#include "qcocoaeventdispatcher.h"
#include <qbytearray.h>
#include <qwindow.h>
@@ -194,6 +195,11 @@ QPixmap QCocoaNativeInterface::defaultBackgroundPixmapForQWizard()
return QPixmap();
}
+void QCocoaNativeInterface::clearCurrentThreadCocoaEventDispatcherInterruptFlag()
+{
+ QCocoaEventDispatcher::clearCurrentThreadCocoaEventDispatcherInterruptFlag();
+}
+
void QCocoaNativeInterface::onAppFocusWindowChanged(QWindow *window)
{
Q_UNUSED(window);
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 1cd4c1905a..ac5f1a6851 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -238,6 +238,8 @@ public:
void setMenubar(QCocoaMenuBar *mb);
QCocoaMenuBar *menubar() const;
+ NSCursor *effectiveWindowCursor() const;
+ void applyEffectiveWindowCursor();
void setWindowCursor(NSCursor *cursor);
void registerTouch(bool enable);
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 30ac79f3a0..0b33b9255f 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -1859,31 +1859,53 @@ QCocoaMenuBar *QCocoaWindow::menubar() const
return m_menubar;
}
-void QCocoaWindow::setWindowCursor(NSCursor *cursor)
+// Finds the effective cursor for this window by walking up the
+// ancestor chain (including this window) until a set cursor is
+// found. Returns nil if there is not set cursor.
+NSCursor *QCocoaWindow::effectiveWindowCursor() const
{
- // This function is called (via QCocoaCursor) by Qt to set
- // the cursor for this window. It can be called for a window
- // that is not currenly under the mouse pointer (for example
- // for a popup window.) Qt expects the set cursor to "stick":
- // it should be accociated with the window until a different
- // cursor is set.
- if (m_windowCursor != cursor) {
- [m_windowCursor release];
- m_windowCursor = [cursor retain];
- }
- // Use the built in cursor rect API if the QCocoaWindow has a NSWindow.
- // Othervise, set the cursor if this window is under the mouse. In
- // this case QNSView::cursorUpdate will set the cursor as the pointer
- // moves.
- if (m_nsWindow && window()->type() != Qt::ForeignWindow) {
- [m_nsWindow invalidateCursorRectsForView:m_view];
+ if (m_windowCursor)
+ return m_windowCursor;
+ if (!QPlatformWindow::parent())
+ return nil;
+ return static_cast<QCocoaWindow *>(QPlatformWindow::parent())->effectiveWindowCursor();
+}
+
+// Applies the cursor as returned by effectiveWindowCursor(), handles
+// the special no-cursor-set case by setting the arrow cursor.
+void QCocoaWindow::applyEffectiveWindowCursor()
+{
+ NSCursor *effectiveCursor = effectiveWindowCursor();
+ if (effectiveCursor) {
+ [effectiveCursor set];
} else {
- if (m_windowUnderMouse)
- [cursor set];
+ // We wold like to _unset_ the cursor here; but there is no such
+ // API. Fall back to setting the default arrow cursor.
+ [[NSCursor arrowCursor] set];
}
}
+void QCocoaWindow::setWindowCursor(NSCursor *cursor)
+{
+ if (m_windowCursor == cursor)
+ return;
+
+ // Setting a cursor in a foregin view is not supported.
+ if (window()->type() == Qt::ForeignWindow)
+ return;
+
+ [m_windowCursor release];
+ m_windowCursor = cursor;
+ [m_windowCursor retain];
+
+ // The installed view tracking area (see QNSView updateTrackingAreas) will
+ // handle cursor updates on mouse enter/leave. Handle the case where the
+ // mouse is on the this window by changing the cursor immediately.
+ if (m_windowUnderMouse)
+ applyEffectiveWindowCursor();
+}
+
void QCocoaWindow::registerTouch(bool enable)
{
m_registerTouchCount += enable ? 1 : -1;
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h
index d911b804cc..84be7eb797 100644
--- a/src/plugins/platforms/cocoa/qnsview.h
+++ b/src/plugins/platforms/cocoa/qnsview.h
@@ -127,7 +127,6 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
- (void)mouseMovedImpl:(NSEvent *)theEvent;
- (void)mouseEnteredImpl:(NSEvent *)theEvent;
- (void)mouseExitedImpl:(NSEvent *)theEvent;
-- (void)cursorUpdateImpl:(NSEvent *)theEvent;
- (void)rightMouseDown:(NSEvent *)theEvent;
- (void)rightMouseDragged:(NSEvent *)theEvent;
- (void)rightMouseUp:(NSEvent *)theEvent;
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 73fe5d8526..689fd06d66 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -121,7 +121,7 @@ static bool _q_dontOverrideCtrlLMB = false;
- (void)cursorUpdate:(NSEvent *)theEvent
{
- [view cursorUpdateImpl:theEvent];
+ [self cursorUpdate:theEvent];
}
@end
@@ -954,21 +954,10 @@ static bool _q_dontOverrideCtrlLMB = false;
[self addTrackingArea:m_trackingArea];
}
--(void)cursorUpdateImpl:(NSEvent *)theEvent
-{
- Q_UNUSED(theEvent)
- // Set the cursor manually if there is no NSWindow.
- if (!m_platformWindow->m_nsWindow && m_platformWindow->m_windowCursor)
- [m_platformWindow->m_windowCursor set];
- else
- [super cursorUpdate:theEvent];
-}
-
--(void)resetCursorRects
+- (void)cursorUpdate:(NSEvent *)theEvent
{
- // Use the cursor rect API if there is a NSWindow
- if (m_platformWindow->m_nsWindow && m_platformWindow->m_windowCursor)
- [self addCursorRect:[self visibleRect] cursor:m_platformWindow->m_windowCursor];
+ Q_UNUSED(theEvent);
+ m_platformWindow->applyEffectiveWindowCursor();
}
- (void)mouseMovedImpl:(NSEvent *)theEvent
@@ -1792,9 +1781,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
- (NSRange) selectedRange
{
- NSRange selectedRange = {NSNotFound, 0};
- selectedRange.location = NSNotFound;
- selectedRange.length = 0;
+ NSRange selectedRange = {0, 0};
QObject *fo = QGuiApplication::focusObject();
if (!fo)
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dhelpers.h b/src/plugins/platforms/direct2d/qwindowsdirect2dhelpers.h
index 97715ad050..34225bba9a 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dhelpers.h
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dhelpers.h
@@ -46,6 +46,13 @@
#include <QtGui/QColor>
#include <QtGui/QTransform>
+#ifdef Q_CC_MINGW
+# include <qt_windows.h>
+# include <d2d1.h>
+# include <d2d1helper.h>
+# include <d2dbasetypes.h>
+# include <d2d1_1.h>
+#endif // Q_CC_MINGW
#include <d2d1_1helper.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/directfb/directfb.pro b/src/plugins/platforms/directfb/directfb.pro
index 406b89e3b2..4e95aebe35 100644
--- a/src/plugins/platforms/directfb/directfb.pro
+++ b/src/plugins/platforms/directfb/directfb.pro
@@ -27,7 +27,7 @@ HEADERS = qdirectfbintegration.h \
qdirectfbeglhooks.h
# ### port the GL context
-qtConfig(directfb_egl) {
+contains(QT_CONFIG, directfb_egl) {
HEADERS += qdirectfb_egl.h
SOURCES += qdirectfb_egl.cpp
DEFINES += DIRECTFB_GL_EGL
diff --git a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp
index 733f0bd139..7c88c73cc2 100644
--- a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp
@@ -418,15 +418,17 @@ void QEglFSIntegration::createInputHandlers()
}
#endif
-#if QT_CONFIG(evdev)
- m_kbdMgr = new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString() /* spec */, this);
- new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString() /* spec */, this);
+ bool useTslib = false;
#if QT_CONFIG(tslib)
- const bool useTslib = qEnvironmentVariableIntValue("QT_QPA_EGLFS_TSLIB");
+ useTslib = qEnvironmentVariableIntValue("QT_QPA_EGLFS_TSLIB");
if (useTslib)
new QTsLibMouseHandler(QLatin1String("TsLib"), QString() /* spec */);
- else
#endif
+
+#if QT_CONFIG(evdev)
+ m_kbdMgr = new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString() /* spec */, this);
+ new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString() /* spec */, this);
+ if (!useTslib)
new QEvdevTouchManager(QLatin1String("EvdevTouch"), QString() /* spec */, this);
#endif
}
diff --git a/src/plugins/platforms/ios/optional/optional.pro b/src/plugins/platforms/ios/optional/optional.pro
index 5e3421a025..6b4ae1ef5e 100644
--- a/src/plugins/platforms/ios/optional/optional.pro
+++ b/src/plugins/platforms/ios/optional/optional.pro
@@ -1,2 +1,2 @@
TEMPLATE = subdirs
-SUBDIRS = nsphotolibrarysupport
+ios: SUBDIRS = nsphotolibrarysupport
diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm
index e8d216fbc2..eab6792266 100644
--- a/src/plugins/platforms/ios/qiostextresponder.mm
+++ b/src/plugins/platforms/ios/qiostextresponder.mm
@@ -628,7 +628,7 @@
- (id<UITextInputTokenizer>)tokenizer
{
- return [[[UITextInputStringTokenizer alloc] initWithTextInput:id<UITextInput>(self)] autorelease];
+ return [[[UITextInputStringTokenizer alloc] initWithTextInput:self] autorelease];
}
- (UITextPosition *)beginningOfDocument
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp
index 893205177d..c1c235588e 100644
--- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp
+++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp
@@ -147,15 +147,17 @@ void QLinuxFbIntegration::createInputHandlers()
}
#endif
-#if QT_CONFIG(evdev) && !defined(Q_OS_ANDROID)
- new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString(), this);
- new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString(), this);
+ bool useTslib = false;
#if QT_CONFIG(tslib)
- const bool useTslib = qEnvironmentVariableIntValue("QT_QPA_FB_TSLIB");
+ useTslib = qEnvironmentVariableIntValue("QT_QPA_FB_TSLIB");
if (useTslib)
new QTsLibMouseHandler(QLatin1String("TsLib"), QString());
- else
#endif
+
+#if QT_CONFIG(evdev) && !defined(Q_OS_ANDROID)
+ new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString(), this);
+ new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString(), this);
+ if (!useTslib)
new QEvdevTouchManager(QLatin1String("EvdevTouch"), QString() /* spec */, this);
#endif
}
diff --git a/src/plugins/platforms/mirclient/qmirclientcursor.cpp b/src/plugins/platforms/mirclient/qmirclientcursor.cpp
index 83ea116c11..a0da3fdd77 100644
--- a/src/plugins/platforms/mirclient/qmirclientcursor.cpp
+++ b/src/plugins/platforms/mirclient/qmirclientcursor.cpp
@@ -167,7 +167,7 @@ void QMirClientCursor::configureMirCursorWithPixmapQCursor(MirSurface *surface,
QImage image = cursor.pixmap().toImage();
if (image.format() != QImage::Format_ARGB32) {
- image.convertToFormat(QImage::Format_ARGB32);
+ image = image.convertToFormat(QImage::Format_ARGB32);
}
MirBufferStream *bufferStream = mir_connection_create_buffer_stream_sync(mConnection,
diff --git a/src/plugins/platforms/vnc/qvnc.cpp b/src/plugins/platforms/vnc/qvnc.cpp
index f386be193d..a45bb1c19c 100644
--- a/src/plugins/platforms/vnc/qvnc.cpp
+++ b/src/plugins/platforms/vnc/qvnc.cpp
@@ -533,9 +533,11 @@ void QRfbRawEncoder::write()
QVncClientCursor::QVncClientCursor()
{
+#ifndef QT_NO_CURSOR
QWindow *w = QGuiApplication::focusWindow();
QCursor c = w ? w->cursor() : QCursor(Qt::ArrowCursor);
changeCursor(&c, 0);
+#endif
}
QVncClientCursor::~QVncClientCursor()
@@ -582,10 +584,10 @@ void QVncClientCursor::write(QVncClient *client) const
socket->write((const char*)bitmap.scanLine(i), width);
}
-#ifndef QT_NO_CURSOR
void QVncClientCursor::changeCursor(QCursor *widgetCursor, QWindow *window)
{
Q_UNUSED(window);
+#ifndef QT_NO_CURSOR
const Qt::CursorShape shape = widgetCursor ? widgetCursor->shape() : Qt::ArrowCursor;
if (shape == Qt::BitmapCursor) {
@@ -599,6 +601,9 @@ void QVncClientCursor::changeCursor(QCursor *widgetCursor, QWindow *window)
cursor = *platformImage.image();
hotspot = platformImage.hotspot();
}
+#else // !QT_NO_CURSOR
+ Q_UNUSED(widgetCursor);
+#endif
for (auto client : clients)
client->setDirtyCursor();
}
@@ -614,7 +619,6 @@ uint QVncClientCursor::removeClient(QVncClient *client)
clients.removeOne(client);
return clients.count();
}
-#endif
QVncServer::QVncServer(QVncScreen *screen, quint16 port)
: qvnc_screen(screen)
diff --git a/src/plugins/platforms/winrt/qwinrtbackingstore.h b/src/plugins/platforms/winrt/qwinrtbackingstore.h
index ce99718548..41b27debcc 100644
--- a/src/plugins/platforms/winrt/qwinrtbackingstore.h
+++ b/src/plugins/platforms/winrt/qwinrtbackingstore.h
@@ -40,6 +40,7 @@
#ifndef QWINRTBACKINGSTORE_H
#define QWINRTBACKINGSTORE_H
+#define GL_GLEXT_PROTOTYPES
#include <qpa/qplatformbackingstore.h>
#include <QtCore/QScopedPointer>
#include <QtCore/QLoggingCategory>
diff --git a/src/plugins/platforms/winrt/qwinrtdrag.cpp b/src/plugins/platforms/winrt/qwinrtdrag.cpp
index 055aacbf56..89ebf7d26f 100644
--- a/src/plugins/platforms/winrt/qwinrtdrag.cpp
+++ b/src/plugins/platforms/winrt/qwinrtdrag.cpp
@@ -322,9 +322,9 @@ QVariant QWinRTInternalMimeData::retrieveData_sys(const QString &mimetype, QVari
hr = res.As(&propertyValue);
if (SUCCEEDED(hr)) {
// We need to check which type of custom data we are receiving
- PropertyType type;
- propertyValue->get_Type(&type);
- switch (type) {
+ PropertyType propertyType;
+ propertyValue->get_Type(&propertyType);
+ switch (propertyType) {
case PropertyType_UInt8: {
quint8 v;
hr = propertyValue->GetUInt8(&v);
@@ -410,7 +410,7 @@ QVariant QWinRTInternalMimeData::retrieveData_sys(const QString &mimetype, QVari
return S_OK;
}
default:
- qCDebug(lcQpaMime) << "Unknown property type dropped:" << type;
+ qCDebug(lcQpaMime) << "Unknown property type dropped:" << propertyType;
}
return S_OK;
}
diff --git a/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp b/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp
index 038a6d32e8..417dbdc1db 100644
--- a/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp
+++ b/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp
@@ -195,8 +195,8 @@ static bool initializeOpenPickerOptions(T *picker, const QSharedPointer<QFileDia
ComPtr<IVector<HSTRING>> filters;
hr = picker->get_FileTypeFilter(&filters);
RETURN_FALSE_IF_FAILED("Failed to get file type filters list");
- foreach (const QString &namedFilter, options->nameFilters()) {
- foreach (const QString &filter, QPlatformFileDialogHelper::cleanFilterList(namedFilter)) {
+ for (const QString &namedFilter : options->nameFilters()) {
+ for (const QString &filter : QPlatformFileDialogHelper::cleanFilterList(namedFilter)) {
// Remove leading star
const int offset = (filter.length() > 1 && filter.startsWith(QLatin1Char('*'))) ? 1 : 0;
HStringReference filterRef(reinterpret_cast<const wchar_t *>(filter.utf16() + offset),
@@ -419,13 +419,15 @@ bool QWinRTFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModalit
ComPtr<IMap<HSTRING, IVector<HSTRING> *>> choices;
hr = picker->get_FileTypeChoices(&choices);
RETURN_FALSE_IF_FAILED("Failed to get file extension choices");
- foreach (const QString &namedFilter, dialogOptions->nameFilters()) {
+ const QStringList nameFilters = dialogOptions->nameFilters();
+ for (const QString &namedFilter : nameFilters) {
ComPtr<IVector<HSTRING>> entry = Make<WindowsStringVector>();
- foreach (const QString &filter, QPlatformFileDialogHelper::cleanFilterList(namedFilter)) {
+ const QStringList cleanFilter = QPlatformFileDialogHelper::cleanFilterList(namedFilter);
+ for (const QString &filter : cleanFilter) {
// Remove leading star
- const int offset = (filter.length() > 1 && filter.startsWith(QLatin1Char('*'))) ? 1 : 0;
- HStringReference filterRef(reinterpret_cast<const wchar_t *>(filter.utf16() + offset),
- filter.length() - offset);
+ const int starOffset = (filter.length() > 1 && filter.startsWith(QLatin1Char('*'))) ? 1 : 0;
+ HStringReference filterRef(reinterpret_cast<const wchar_t *>(filter.utf16() + starOffset),
+ filter.length() - starOffset);
hr = entry->Append(filterRef.Get());
if (FAILED(hr)) {
qWarning("Failed to add named file filter \"%s\": %s",
diff --git a/src/plugins/platforms/winrt/qwinrtfileengine.cpp b/src/plugins/platforms/winrt/qwinrtfileengine.cpp
index 53e7ebd30d..557c13cf63 100644
--- a/src/plugins/platforms/winrt/qwinrtfileengine.cpp
+++ b/src/plugins/platforms/winrt/qwinrtfileengine.cpp
@@ -92,7 +92,7 @@ public:
}
firstDot = fileName.size();
- for (int i = lastSeparator; i > fileName.size(); ++i) {
+ for (int i = lastSeparator; i < fileName.size(); ++i) {
if (fileName.at(i).unicode() == '.') {
firstDot = i;
break;
diff --git a/src/plugins/platforms/winrt/qwinrtintegration.cpp b/src/plugins/platforms/winrt/qwinrtintegration.cpp
index 7a0c95e6c1..ffc3bbf077 100644
--- a/src/plugins/platforms/winrt/qwinrtintegration.cpp
+++ b/src/plugins/platforms/winrt/qwinrtintegration.cpp
@@ -45,7 +45,6 @@
#include "qwinrtinputcontext.h"
#include "qwinrtservices.h"
#include "qwinrteglcontext.h"
-#include "qwinrtfontdatabase.h"
#include "qwinrttheme.h"
#include "qwinrtclipboard.h"
#ifndef QT_NO_DRAGANDDROP
@@ -56,6 +55,7 @@
#include <QtGui/QOpenGLContext>
#include <QtGui/QSurface>
+#include <QtFontDatabaseSupport/private/qwinrtfontdatabase_p.h>
#include <QtEglSupport/private/qeglpbuffer_p.h>
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformwindow.h>
diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp
index e8e869c04f..6d4edcc8dc 100644
--- a/src/plugins/platforms/winrt/qwinrtscreen.cpp
+++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp
@@ -625,7 +625,7 @@ int QWinRTScreen::depth() const
QImage::Format QWinRTScreen::format() const
{
- return QImage::Format_ARGB32_Premultiplied;
+ return QImage::Format_RGB32;
}
QSizeF QWinRTScreen::physicalSize() const
diff --git a/src/plugins/platforms/winrt/winrt.pro b/src/plugins/platforms/winrt/winrt.pro
index 8fd2a83a16..be2f5ca7e2 100644
--- a/src/plugins/platforms/winrt/winrt.pro
+++ b/src/plugins/platforms/winrt/winrt.pro
@@ -8,7 +8,7 @@ QT += \
DEFINES *= QT_NO_CAST_FROM_ASCII __WRL_NO_DEFAULT_LIB__
-LIBS += $$QMAKE_LIBS_CORE -ldwrite -ld3d11
+LIBS += $$QMAKE_LIBS_CORE -ld3d11
SOURCES = \
main.cpp \
@@ -20,7 +20,6 @@ SOURCES = \
qwinrteventdispatcher.cpp \
qwinrtfiledialoghelper.cpp \
qwinrtfileengine.cpp \
- qwinrtfontdatabase.cpp \
qwinrtinputcontext.cpp \
qwinrtintegration.cpp \
qwinrtmessagedialoghelper.cpp \
@@ -39,7 +38,6 @@ HEADERS = \
qwinrteventdispatcher.h \
qwinrtfiledialoghelper.h \
qwinrtfileengine.h \
- qwinrtfontdatabase.h \
qwinrtinputcontext.h \
qwinrtintegration.h \
qwinrtmessagedialoghelper.h \
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
index dc720c090f..1f36a1ad2a 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
@@ -678,8 +678,11 @@ void QGLXContext::queryDummyContext()
}
QOpenGLContext context;
- context.create();
- context.makeCurrent(surface.data());
+ if (!context.create() || !context.makeCurrent(surface.data())) {
+ qWarning("QGLXContext: Failed to create dummy context");
+ m_supportsThreading = false;
+ return;
+ }
m_supportsThreading = true;
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp
index f9c32cd0a4..38e91cc9f6 100644
--- a/src/plugins/platforms/xcb/qxcbclipboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp
@@ -729,8 +729,10 @@ void QXcbClipboard::handleXFixesSelectionRequest(xcb_xfixes_selection_notify_eve
if (mode > QClipboard::Selection)
return;
- // here we care only about the xfixes events that come from non Qt processes
- if (event->owner != XCB_NONE && event->owner != owner()) {
+ // Note1: Here we care only about the xfixes events that come from other processes.
+ // Note2: If the QClipboard::clear() is issued, event->owner is XCB_NONE,
+ // so we check selection_timestamp to not handle our own QClipboard::clear().
+ if (event->owner != owner() && event->selection_timestamp > m_timestamp[mode]) {
if (!m_xClipboard[mode]) {
m_xClipboard[mode].reset(new QXcbClipboardMime(mode, this));
} else {
diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp
index 4de4be43d1..80fe5a2199 100644
--- a/src/plugins/platforms/xcb/qxcbcursor.cpp
+++ b/src/plugins/platforms/xcb/qxcbcursor.cpp
@@ -74,6 +74,8 @@ static PtrXcursorLibraryGetDefaultSize ptrXcursorLibraryGetDefaultSize = 0;
static xcb_font_t cursorFont = 0;
static int cursorCount = 0;
+#ifndef QT_NO_CURSOR
+
static uint8_t cur_blank_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -276,8 +278,6 @@ static const char * const cursorNames[] = {
"link"
};
-#ifndef QT_NO_CURSOR
-
QXcbCursorCacheKey::QXcbCursorCacheKey(const QCursor &c)
: shape(c.shape()), bitmapCacheKey(0), maskCacheKey(0)
{
diff --git a/src/plugins/platforms/xcb/xcb-static/xcb-static.pro b/src/plugins/platforms/xcb/xcb-static/xcb-static.pro
index f3e54813ee..20d8b83e7c 100644
--- a/src/plugins/platforms/xcb/xcb-static/xcb-static.pro
+++ b/src/plugins/platforms/xcb/xcb-static/xcb-static.pro
@@ -6,7 +6,7 @@
#
CONFIG += static
-XCB_DIR = ../../../../3rdparty/xcb
+XCB_DIR = $$QT_SOURCE_TREE/src/3rdparty/xcb
MODULE_INCLUDEPATH += $$XCB_DIR/include $$XCB_DIR/sysinclude
INCLUDEPATH += $$XCB_DIR/include/xcb
diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
index 2030732e4b..ba5089a8bc 100644
--- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
+++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
@@ -38,6 +38,7 @@
****************************************************************************/
#include "qgtk3dialoghelpers.h"
+#include "qgtk3theme.h"
#include <qeventloop.h>
#include <qwindow.h>
@@ -56,6 +57,11 @@
QT_BEGIN_NAMESPACE
+static const char *standardButtonText(int button)
+{
+ return QGtk3Theme::defaultStandardButtonText(button).toUtf8();
+}
+
class QGtk3Dialog : public QWindow
{
Q_OBJECT
@@ -237,8 +243,10 @@ QGtk3FileDialogHelper::QGtk3FileDialogHelper()
{
d.reset(new QGtk3Dialog(gtk_file_chooser_dialog_new("", 0,
GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK, NULL)));
+ standardButtonText(QPlatformDialogHelper::Cancel), GTK_RESPONSE_CANCEL,
+ standardButtonText(QPlatformDialogHelper::Ok), GTK_RESPONSE_OK,
+ NULL)));
+
connect(d.data(), SIGNAL(accept()), this, SLOT(onAccepted()));
connect(d.data(), SIGNAL(reject()), this, SIGNAL(reject()));
@@ -438,9 +446,9 @@ void QGtk3FileDialogHelper::applyOptions()
if (opts->isLabelExplicitlySet(QFileDialogOptions::Accept))
gtk_button_set_label(GTK_BUTTON(acceptButton), opts->labelText(QFileDialogOptions::Accept).toUtf8());
else if (opts->acceptMode() == QFileDialogOptions::AcceptOpen)
- gtk_button_set_label(GTK_BUTTON(acceptButton), GTK_STOCK_OPEN);
+ gtk_button_set_label(GTK_BUTTON(acceptButton), standardButtonText(QPlatformDialogHelper::Open));
else
- gtk_button_set_label(GTK_BUTTON(acceptButton), GTK_STOCK_SAVE);
+ gtk_button_set_label(GTK_BUTTON(acceptButton), standardButtonText(QPlatformDialogHelper::Save));
}
GtkWidget *rejectButton = gtk_dialog_get_widget_for_response(gtkDialog, GTK_RESPONSE_CANCEL);
@@ -448,7 +456,7 @@ void QGtk3FileDialogHelper::applyOptions()
if (opts->isLabelExplicitlySet(QFileDialogOptions::Reject))
gtk_button_set_label(GTK_BUTTON(rejectButton), opts->labelText(QFileDialogOptions::Reject).toUtf8());
else
- gtk_button_set_label(GTK_BUTTON(rejectButton), GTK_STOCK_CANCEL);
+ gtk_button_set_label(GTK_BUTTON(rejectButton), standardButtonText(QPlatformDialogHelper::Cancel));
}
}
diff --git a/src/printsupport/dialogs/qpagesetupdialog_mac.mm b/src/printsupport/dialogs/qpagesetupdialog_mac.mm
index e3e7523a16..c29b911e35 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_mac.mm
+++ b/src/printsupport/dialogs/qpagesetupdialog_mac.mm
@@ -133,6 +133,11 @@ void QMacPageSetupDialogPrivate::openCocoaPageLayout(Qt::WindowModality modality
QT_MANGLE_NAMESPACE(QCocoaPageLayoutDelegate) *delegate = [[QT_MANGLE_NAMESPACE(QCocoaPageLayoutDelegate) alloc] initWithNSPrintInfo:printInfo];
if (modality == Qt::ApplicationModal) {
+
+ // Make sure we don't interrupt the runModalWithPrintInfo call.
+ (void) QMetaObject::invokeMethod(qApp->platformNativeInterface(),
+ "clearCurrentThreadCocoaEventDispatcherInterruptFlag");
+
int rval = [pageLayout runModalWithPrintInfo:printInfo];
[delegate pageLayoutDidEnd:pageLayout returnCode:rval contextInfo:q];
} else {
diff --git a/src/printsupport/dialogs/qprintdialog_mac.mm b/src/printsupport/dialogs/qprintdialog_mac.mm
index c16bb93013..c630ab634a 100644
--- a/src/printsupport/dialogs/qprintdialog_mac.mm
+++ b/src/printsupport/dialogs/qprintdialog_mac.mm
@@ -245,6 +245,11 @@ void QPrintDialogPrivate::openCocoaPrintPanel(Qt::WindowModality modality)
if (modality == Qt::ApplicationModal || !q->parentWidget()) {
if (modality == Qt::NonModal)
qWarning("QPrintDialog is required to be modal on OS X");
+
+ // Make sure we don't interrupt the runModalWithPrintInfo call.
+ (void) QMetaObject::invokeMethod(qApp->platformNativeInterface(),
+ "clearCurrentThreadCocoaEventDispatcherInterruptFlag");
+
int rval = [printPanel runModalWithPrintInfo:printInfo];
[delegate printPanelDidEnd:printPanel returnCode:rval contextInfo:q];
} else {
diff --git a/src/src.pro b/src/src.pro
index 87391eab5b..f19b0bd354 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -174,7 +174,7 @@ qtConfig(gui) {
src_platformsupport.depends += src_3rdparty_freetype
}
SUBDIRS += src_gui src_platformsupport src_platformheaders
- qtConfig(opengl(es2)?): SUBDIRS += src_openglextensions
+ qtConfig(opengl): SUBDIRS += src_openglextensions
src_plugins.depends += src_gui src_platformsupport src_platformheaders
src_testlib.depends += src_gui # if QtGui is enabled, QtTest requires QtGui's headers
qtConfig(widgets) {
@@ -182,7 +182,7 @@ qtConfig(gui) {
TOOLS += src_tools_uic
src_plugins.depends += src_widgets
src_testlib.depends += src_widgets # if QtWidgets is enabled, QtTest requires QtWidgets's headers
- qtConfig(opengl(es2)?) {
+ qtConfig(opengl) {
SUBDIRS += src_opengl
src_plugins.depends += src_opengl
}
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h
index 045431fcaf..c3ccfc3f8c 100644
--- a/src/testlib/qtestcase.h
+++ b/src/testlib/qtestcase.h
@@ -46,7 +46,6 @@
#include <QtCore/qnamespace.h>
#include <QtCore/qmetatype.h>
#include <QtCore/qmetaobject.h>
-#include <QtCore/qtypetraits.h>
#include <QtCore/qsharedpointer.h>
#include <QtCore/qtemporarydir.h>
@@ -312,7 +311,7 @@ namespace QTest
template <typename T>
inline void addColumn(const char *name, T * = 0)
{
- typedef QtPrivate::is_same<T, const char*> QIsSameTConstChar;
+ typedef std::is_same<T, const char*> QIsSameTConstChar;
Q_STATIC_ASSERT_X(!QIsSameTConstChar::value, "const char* is not allowed as a test data format.");
addColumnInternal(qMetaTypeId<T>(), name);
}
diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro
index 0466ca2946..0a61497588 100644
--- a/src/tools/bootstrap/bootstrap.pro
+++ b/src/tools/bootstrap/bootstrap.pro
@@ -137,7 +137,10 @@ macx {
include(../../3rdparty/zlib_dependency.pri)
}
-win32:LIBS += -luser32 -lole32 -ladvapi32 -lshell32
+win32 {
+ LIBS += -luser32 -lole32 -ladvapi32 -lshell32
+ mingw: LIBS += -luuid
+}
load(qt_module)
diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp
index 796d13487b..09eba76fbd 100644
--- a/src/widgets/accessible/itemviews.cpp
+++ b/src/widgets/accessible/itemviews.cpp
@@ -486,10 +486,9 @@ QAccessibleInterface *QAccessibleTable::child(int logicalIndex) const
if (!view()->model())
return 0;
- if (childToId.contains(logicalIndex)) {
- QAccessible::Id id = childToId.value(logicalIndex);
- return QAccessible::accessibleInterface(id);
- }
+ auto id = childToId.constFind(logicalIndex);
+ if (id != childToId.constEnd())
+ return QAccessible::accessibleInterface(id.value());
int vHeader = verticalHeader() ? 1 : 0;
int hHeader = horizontalHeader() ? 1 : 0;
diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp
index 18f8f2df8c..f2db73226b 100644
--- a/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_kernel_qwidget.cpp
@@ -137,11 +137,3 @@ setUpdatesEnabled(false);
bigVisualChanges();
setUpdatesEnabled(true);
//! [13]
-
-
-//! [14]
-...
-extern void qt_x11_set_global_double_buffer(bool);
-qt_x11_set_global_double_buffer(false);
-...
-//! [14]
diff --git a/src/widgets/graphicsview/qgraphicsitem.h b/src/widgets/graphicsview/qgraphicsitem.h
index 59656f5b0b..36f8aac124 100644
--- a/src/widgets/graphicsview/qgraphicsitem.h
+++ b/src/widgets/graphicsview/qgraphicsitem.h
@@ -1024,14 +1024,14 @@ private:
template <class T> inline T qgraphicsitem_cast(QGraphicsItem *item)
{
- typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Item;
+ typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Item;
return int(Item::Type) == int(QGraphicsItem::Type)
|| (item && int(Item::Type) == item->type()) ? static_cast<T>(item) : 0;
}
template <class T> inline T qgraphicsitem_cast(const QGraphicsItem *item)
{
- typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Item;
+ typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Item;
return int(Item::Type) == int(QGraphicsItem::Type)
|| (item && int(Item::Type) == item->type()) ? static_cast<T>(item) : 0;
}
diff --git a/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp b/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp
index b884e93290..203cc8007c 100644
--- a/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp
+++ b/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp
@@ -694,8 +694,7 @@ void QGraphicsSceneBspTreeIndex::itemChange(const QGraphicsItem *item, QGraphics
bool QGraphicsSceneBspTreeIndex::event(QEvent *event)
{
Q_D(QGraphicsSceneBspTreeIndex);
- switch (event->type()) {
- case QEvent::Timer:
+ if (event->type() == QEvent::Timer) {
if (d->indexTimerId && static_cast<QTimerEvent *>(event)->timerId() == d->indexTimerId) {
if (d->restartIndexTimer) {
d->restartIndexTimer = false;
@@ -704,11 +703,8 @@ bool QGraphicsSceneBspTreeIndex::event(QEvent *event)
d->_q_updateIndex();
}
}
- // Fallthrough intended - support timers in subclasses.
- default:
- return QObject::event(event);
}
- return true;
+ return QObject::event(event);
}
QT_END_NAMESPACE
diff --git a/src/widgets/graphicsview/qgraphicstransform_p.h b/src/widgets/graphicsview/qgraphicstransform_p.h
index 39f7ab5487..38dbd51c2e 100644
--- a/src/widgets/graphicsview/qgraphicstransform_p.h
+++ b/src/widgets/graphicsview/qgraphicstransform_p.h
@@ -77,6 +77,6 @@ public:
QT_END_NAMESPACE
-#endif //QT_NO_GRAPHCISVIEW
+#endif //QT_NO_GRAPHICSVIEW
#endif // QGRAPHICSTRANSFORM_P_H
diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp
index d153915ae6..2adc58e4a4 100644
--- a/src/widgets/graphicsview/qgraphicswidget.cpp
+++ b/src/widgets/graphicsview/qgraphicswidget.cpp
@@ -1456,6 +1456,7 @@ bool QGraphicsWidget::event(QEvent *event)
case QEvent::GraphicsSceneMousePress:
if (d->hasDecoration() && windowFrameEvent(event))
return true;
+ break;
case QEvent::GraphicsSceneMouseMove:
case QEvent::GraphicsSceneMouseRelease:
case QEvent::GraphicsSceneMouseDoubleClick:
diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp
index 4beb64a254..46d2a4c1aa 100644
--- a/src/widgets/graphicsview/qgraphicswidget_p.cpp
+++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp
@@ -722,6 +722,9 @@ void QGraphicsWidgetPrivate::windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent
#ifndef QT_NO_CURSOR
if (needsSetCursorCall)
q->setCursor(cursorShape);
+#else
+ Q_UNUSED(needsSetCursorCall);
+ Q_UNUSED(cursorShape);
#endif
// update buttons if we hover over them
windowData->hoveredSubControl = q->style()->hitTestComplexControl(QStyle::CC_TitleBar, &bar, pos.toPoint(), 0);
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 89eff898fe..358838b4e9 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -2790,6 +2790,8 @@ void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget)
// Send enter/leave events followed by a mouse move on the entered widget.
QMouseEvent e(QEvent::MouseMove, pos, windowPos, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier);
sendMouseEvent(widgetUnderCursor, &e, widgetUnderCursor, tlw, &qt_button_down, qt_last_mouse_receiver);
+#else // !QT_NO_CURSOR
+ Q_UNUSED(widget);
#endif // QT_NO_CURSOR
}
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index dc04bfb632..ace50f13ee 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -5535,7 +5535,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
return;
}
}
-#endif //QT_NO_GRAFFICSEFFECT
+#endif //QT_NO_GRAPHICSEFFECT
const bool alsoOnScreen = flags & DrawPaintOnScreen;
const bool recursive = flags & DrawRecursive;
@@ -9625,11 +9625,6 @@ void QWidget::leaveEvent(QEvent *)
Since Qt 4.0, QWidget automatically double-buffers its painting, so there
is no need to write double-buffering code in paintEvent() to avoid flicker.
- \b{Note for the X11 platform}: It is possible to toggle global double
- buffering by calling \c qt_x11_set_global_double_buffer(). For example,
-
- \snippet code/src_gui_kernel_qwidget.cpp 14
-
\note Generally, you should refrain from calling update() or repaint()
\b{inside} a paintEvent(). For example, calling update() or repaint() on
children inside a paintevent() results in undefined behavior; the child may
diff --git a/src/widgets/styles/qpixmapstyle.cpp b/src/widgets/styles/qpixmapstyle.cpp
index b51860045d..e973a96a91 100644
--- a/src/widgets/styles/qpixmapstyle.cpp
+++ b/src/widgets/styles/qpixmapstyle.cpp
@@ -628,10 +628,10 @@ void QPixmapStyle::drawCachedPixmap(QPixmapStyle::ControlDescriptor control, con
QPainter *p) const
{
Q_D(const QPixmapStyle);
- if (!d->descriptors.contains(control))
+ auto descriptor = d->descriptors.constFind(control);
+ if (descriptor == d->descriptors.constEnd())
return;
- const QPixmapStyleDescriptor &desc = d->descriptors.value(control);
- const QPixmap pix = d->getCachedPixmap(control, desc, rect.size());
+ const QPixmap pix = d->getCachedPixmap(control, descriptor.value(), rect.size());
Q_ASSERT(!pix.isNull());
p->drawPixmap(rect, pix);
}
diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp
index 583385ee8a..602421725f 100644
--- a/src/widgets/styles/qstylehelper.cpp
+++ b/src/widgets/styles/qstylehelper.cpp
@@ -49,6 +49,8 @@
#include "qstylehelper_p.h"
#include <qstringbuilder.h>
+#include <qdatastream.h>
+#include <qcryptographichash.h>
QT_BEGIN_NAMESPACE
@@ -62,7 +64,6 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize &
QString tmp = key % HexString<uint>(option->state)
% HexString<uint>(option->direction)
% HexString<uint>(complexOption ? uint(complexOption->activeSubControls) : 0u)
- % HexString<quint64>(option->palette.cacheKey())
% HexString<uint>(size.width())
% HexString<uint>(size.height());
@@ -73,6 +74,25 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize &
% QLatin1Char(spinBox->frame ? '1' : '0'); ;
}
#endif // QT_NO_SPINBOX
+
+ // QTBUG-56743, try to create a palette cache key reflecting the value,
+ // as leaks may occur in conjunction with QStyleSheetStyle/QRenderRule modifying
+ // palettes when using QPalette::cacheKey()
+ if (option->palette != QGuiApplication::palette()) {
+ tmp.append(QLatin1Char('P'));
+#ifndef QT_NO_DATASTREAM
+ QByteArray key;
+ key.reserve(5120); // Observed 5040B for a serialized palette on 64bit
+ {
+ QDataStream str(&key, QIODevice::WriteOnly);
+ str << option->palette;
+ }
+ const QByteArray sha1 = QCryptographicHash::hash(key, QCryptographicHash::Sha1).toHex();
+ tmp.append(QString::fromLatin1(sha1));
+#else // QT_NO_DATASTREAM
+ tmp.append(QString::number(option->palette.cacheKey(), 16));
+#endif // !QT_NO_DATASTREAM
+ }
return tmp;
}
diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h
index 9679411402..0e76d53eea 100644
--- a/src/widgets/styles/qstyleoption.h
+++ b/src/widgets/styles/qstyleoption.h
@@ -665,7 +665,7 @@ protected:
template <typename T>
T qstyleoption_cast(const QStyleOption *opt)
{
- typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Opt;
+ typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
if (opt && opt->version >= Opt::Version && (opt->type == Opt::Type
|| int(Opt::Type) == QStyleOption::SO_Default
|| (int(Opt::Type) == QStyleOption::SO_Complex
@@ -677,7 +677,7 @@ T qstyleoption_cast(const QStyleOption *opt)
template <typename T>
T qstyleoption_cast(QStyleOption *opt)
{
- typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Opt;
+ typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
if (opt && opt->version >= Opt::Version && (opt->type == Opt::Type
|| int(Opt::Type) == QStyleOption::SO_Default
|| (int(Opt::Type) == QStyleOption::SO_Complex
@@ -728,7 +728,7 @@ public:
template <typename T>
T qstyleoption_cast(const QStyleHintReturn *hint)
{
- typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Opt;
+ typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
if (hint && hint->version <= Opt::Version &&
(hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default))
return static_cast<T>(hint);
@@ -738,7 +738,7 @@ T qstyleoption_cast(const QStyleHintReturn *hint)
template <typename T>
T qstyleoption_cast(QStyleHintReturn *hint)
{
- typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type Opt;
+ typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Opt;
if (hint && hint->version <= Opt::Version &&
(hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default))
return static_cast<T>(hint);
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 52e7962109..4358e568bf 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -170,18 +170,18 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt
menuOption.menuRect = option.rect;
menuOption.rect = option.rect;
- // Make sure fonts set on the combo box also overrides the font for the popup menu.
- if (mCombo->testAttribute(Qt::WA_SetFont)
+ // Make sure fonts set on the model or on the combo box, in
+ // that order, also override the font for the popup menu.
+ QVariant fontRoleData = index.data(Qt::FontRole);
+ if (fontRoleData.isValid()) {
+ menuOption.font = fontRoleData.value<QFont>();
+ } else if (mCombo->testAttribute(Qt::WA_SetFont)
|| mCombo->testAttribute(Qt::WA_MacSmallSize)
|| mCombo->testAttribute(Qt::WA_MacMiniSize)
|| mCombo->font() != qt_app_fonts_hash()->value("QComboBox", QFont())) {
menuOption.font = mCombo->font();
} else {
- QVariant fontRoleData = index.data(Qt::FontRole);
- if (fontRoleData.isValid())
- menuOption.font = fontRoleData.value<QFont>();
- else
- menuOption.font = qt_app_fonts_hash()->value("QComboMenuItem", mCombo->font());
+ menuOption.font = qt_app_fonts_hash()->value("QComboMenuItem", mCombo->font());
}
menuOption.fontMetrics = QFontMetrics(menuOption.font);
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index 76713d9880..fa0cff45c9 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -583,6 +583,7 @@ QSize QLabelPrivate::sizeForWidth(int w) const
#ifndef QT_NO_MOVIE
} else if (movie && !movie->currentPixmap().isNull()) {
br = movie->currentPixmap().rect();
+ br.setSize(br.size() / movie->currentPixmap().devicePixelRatio());
#endif
} else if (isTextLabel) {
int align = QStyle::visualAlignment(textDirection(), QFlag(this->align));
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index e32e379198..abfdfbea9b 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -326,7 +326,7 @@ void QMainWindowPrivate::init()
direction.
Two dock widgets may also be stacked on top of each other. A
- QTabBar is then used to select which of the widgets that should be
+ QTabBar is then used to select which of the widgets should be
displayed.
We give an example of how to create and add dock widgets to a
diff --git a/src/widgets/widgets/qmdisubwindow_p.h b/src/widgets/widgets/qmdisubwindow_p.h
index 46a8e99d0a..650d3b0bfb 100644
--- a/src/widgets/widgets/qmdisubwindow_p.h
+++ b/src/widgets/widgets/qmdisubwindow_p.h
@@ -211,7 +211,7 @@ public:
Qt::FocusReason focusInReason;
OperationInfoMap operationMap;
QPointer<QMenu> systemMenu;
-#ifndef QT_NO_ACTIONS
+#ifndef QT_NO_ACTION
QPointer<QAction> actions[NumWindowStateActions];
#endif
QMdiSubWindow::SubWindowOptions options;
diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h
index bcbd0a95c4..5d218ac1ba 100644
--- a/src/widgets/widgets/qmenu.h
+++ b/src/widgets/widgets/qmenu.h
@@ -98,7 +98,7 @@ public:
#else
// addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
template<class Obj, typename Func1>
- inline typename QtPrivate::QEnableIf<!QtPrivate::is_same<const char*, Func1>::value
+ inline typename QtPrivate::QEnableIf<!std::is_same<const char*, Func1>::value
&& QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type
addAction(const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0)
{
@@ -126,7 +126,7 @@ public:
}
// addAction(QIcon, QString): Connect to a QObject slot / functor or function pointer (with context)
template<class Obj, typename Func1>
- inline typename QtPrivate::QEnableIf<!QtPrivate::is_same<const char*, Func1>::value
+ inline typename QtPrivate::QEnableIf<!std::is_same<const char*, Func1>::value
&& QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type
addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0)
{
diff --git a/src/widgets/widgets/qsizegrip.cpp b/src/widgets/widgets/qsizegrip.cpp
index 5150601366..82857c8805 100644
--- a/src/widgets/widgets/qsizegrip.cpp
+++ b/src/widgets/widgets/qsizegrip.cpp
@@ -184,9 +184,12 @@ Qt::Corner QSizeGripPrivate::corner() const
Put this widget anywhere in a widget tree and the user can use it
to resize the top-level window or any widget with the Qt::SubWindow
flag set. Generally, this should be in the lower right-hand corner.
+
Note that QStatusBar already uses this widget, so if you have a
status bar (e.g., you are using QMainWindow), then you don't need
- to use this widget explicitly.
+ to use this widget explicitly. The same goes for QDialog, for which
+ you can just call \l {QDialog::setSizeGripEnabled()}
+ {QDialog::setSizeGripEnabled()}.
On some platforms the size grip automatically hides itself when the
window is shown full screen or maximised.
diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h
index d361513bbf..0ea4d4afeb 100644
--- a/src/widgets/widgets/qtoolbar.h
+++ b/src/widgets/widgets/qtoolbar.h
@@ -116,7 +116,7 @@ public:
#else
// addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
template<class Obj, typename Func1>
- inline typename QtPrivate::QEnableIf<!QtPrivate::is_same<const char*, Func1>::value
+ inline typename QtPrivate::QEnableIf<!std::is_same<const char*, Func1>::value
&& QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type
addAction(const QString &text, const Obj *object, Func1 slot)
{
@@ -134,7 +134,7 @@ public:
}
// addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
template<class Obj, typename Func1>
- inline typename QtPrivate::QEnableIf<!QtPrivate::is_same<const char*, Func1>::value
+ inline typename QtPrivate::QEnableIf<!std::is_same<const char*, Func1>::value
&& QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type
addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot)
{
diff --git a/src/winmain/qtmain_winrt.cpp b/src/winmain/qtmain_winrt.cpp
index e49817ada4..b0e70608f9 100644
--- a/src/winmain/qtmain_winrt.cpp
+++ b/src/winmain/qtmain_winrt.cpp
@@ -110,7 +110,12 @@ static void devMessageHandler(QtMsgType type, const QMessageLogContext &context,
if (!event)
event = CreateEventEx(NULL, L"qdebug-event", 0, EVENT_ALL_ACCESS);
+ Q_ASSERT_X(shmem, Q_FUNC_INFO, "Could not create file mapping");
+ Q_ASSERT_X(event, Q_FUNC_INFO, "Could not create debug event");
+
void *data = MapViewOfFileFromApp(shmem, FILE_MAP_WRITE, 0, 4096);
+ Q_ASSERT_X(data, Q_FUNC_INFO, "Could not map file");
+
memset(data, quint32(type), sizeof(quint32));
memcpy_s(static_cast<quint32 *>(data) + 1, 4096 - sizeof(quint32),
message.data(), (message.length() + 1) * sizeof(wchar_t));
@@ -179,6 +184,7 @@ public:
app->core->Exit();
return res;
}, this, CREATE_SUSPENDED, nullptr);
+ Q_ASSERT_X(mainThread, Q_FUNC_INFO, "Could not create Qt main thread");
HRESULT hr;
ComPtr<Xaml::IApplicationStatics> appStatics;