summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-05-23 21:27:07 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-05-23 21:27:07 +0200
commitd3a8bc803cd7c4ce106038bfc4b37cdd6bb8e177 (patch)
tree3b6db0d4869f334d0eb4559c5ae457995cbe913e /src/corelib
parentd934ddc297f6db94dbc548fe01da64350f13577d (diff)
parent47a7628023610904c6ac52e23fa289f75f349b4e (diff)
Merge remote-tracking branch 'origin/stable' into dev
Conflicts: src/corelib/io/qdatastream.cpp src/corelib/io/qdatastream.h src/corelib/json/qjsonwriter.cpp src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/xcb/qxcbkeyboard.cpp Change-Id: I46fef1455f5a9f2ce1ec394a3c65881093c51b62
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/Qt5Config.cmake.in2
-rw-r--r--src/corelib/Qt5CoreConfigExtras.cmake.in49
-rw-r--r--src/corelib/codecs/qtextcodec.cpp4
-rw-r--r--src/corelib/global/qcompilerdetection.h6
-rw-r--r--src/corelib/global/qflags.h15
-rw-r--r--src/corelib/global/qglobal.cpp44
-rw-r--r--src/corelib/global/qglobal.h4
-rw-r--r--src/corelib/global/qlibraryinfo.cpp1
-rw-r--r--src/corelib/global/qlibraryinfo.h1
-rw-r--r--src/corelib/global/qlogging.h20
-rw-r--r--src/corelib/global/qnamespace.h3
-rw-r--r--src/corelib/global/qnamespace.qdoc6
-rw-r--r--src/corelib/global/qsysinfo.h2
-rw-r--r--src/corelib/global/qsystemdetection.h8
-rw-r--r--src/corelib/io/qdatastream.cpp7
-rw-r--r--src/corelib/io/qdatastream.h2
-rw-r--r--src/corelib/io/qdebug.h2
-rw-r--r--src/corelib/io/qfile.cpp43
-rw-r--r--src/corelib/io/qfilesystemengine.cpp2
-rw-r--r--src/corelib/io/qfilesystemengine_p.h2
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp16
-rw-r--r--src/corelib/io/qfilesystemmetadata_p.h4
-rw-r--r--src/corelib/io/qprocess.cpp38
-rw-r--r--src/corelib/io/qprocess.h2
-rw-r--r--src/corelib/io/qprocess_p.h44
-rw-r--r--src/corelib/io/qprocess_unix.cpp6
-rw-r--r--src/corelib/io/qprocess_win.cpp22
-rw-r--r--src/corelib/io/qprocess_wince.cpp5
-rw-r--r--src/corelib/io/qresource.cpp2
-rw-r--r--src/corelib/io/qurl.cpp2
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.h2
-rw-r--r--src/corelib/json/qjson.cpp11
-rw-r--r--src/corelib/json/qjson_p.h5
-rw-r--r--src/corelib/json/qjsonarray.cpp24
-rw-r--r--src/corelib/json/qjsondocument.h3
-rw-r--r--src/corelib/json/qjsonobject.cpp16
-rw-r--r--src/corelib/json/qjsonparser.cpp21
-rw-r--r--src/corelib/kernel/qcorecmdlineargs_p.h7
-rw-r--r--src/corelib/kernel/qeventdispatcher_blackberry.cpp1
-rw-r--r--src/corelib/kernel/qobject.cpp10
-rw-r--r--src/corelib/thread/qthreadpool.cpp2
-rw-r--r--src/corelib/tools/qdatetime.cpp7
-rw-r--r--src/corelib/tools/qhash.cpp25
-rw-r--r--src/corelib/tools/qhash.h1
-rw-r--r--src/corelib/tools/qlocale.cpp13
-rw-r--r--src/corelib/tools/qlocale_p.h3
-rw-r--r--src/corelib/tools/qsharedpointer.cpp2
-rw-r--r--src/corelib/tools/qstring.h8
48 files changed, 388 insertions, 137 deletions
diff --git a/src/corelib/Qt5Config.cmake.in b/src/corelib/Qt5Config.cmake.in
index a7e9a042e8..a872d0e917 100644
--- a/src/corelib/Qt5Config.cmake.in
+++ b/src/corelib/Qt5Config.cmake.in
@@ -41,3 +41,5 @@ if (_Qt5_NOTFOUND_MESSAGE)
set(Qt5_NOT_FOUND_MESSAGE \"${_Qt5_NOTFOUND_MESSAGE}\")
set(Qt5_FOUND False)
endif()
+
+_qt5_Core_check_file_exists(\"${CMAKE_CURRENT_LIST_DIR}/Qt5ConfigVersion.cmake\")
diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
index 3932c9e2c7..a80427893d 100644
--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
+++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
@@ -2,24 +2,30 @@
if (NOT TARGET Qt5::qmake)
add_executable(Qt5::qmake IMPORTED)
- set_target_properties(Qt5::qmake PROPERTIES
!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
- IMPORTED_LOCATION \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\"
+ set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
!!ELSE
- IMPORTED_LOCATION \"$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\"
+ set(imported_location \"$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\")
!!ENDIF
+ _qt5_Core_check_file_exists(${imported_location})
+
+ set_target_properties(Qt5::qmake PROPERTIES
+ IMPORTED_LOCATION ${imported_location}
)
endif()
if (NOT TARGET Qt5::moc)
add_executable(Qt5::moc IMPORTED)
- set_target_properties(Qt5::moc PROPERTIES
!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
- IMPORTED_LOCATION \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\"
+ set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
!!ELSE
- IMPORTED_LOCATION \"$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\"
+ set(imported_location \"$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\")
!!ENDIF
+ _qt5_Core_check_file_exists(${imported_location})
+
+ set_target_properties(Qt5::moc PROPERTIES
+ IMPORTED_LOCATION ${imported_location}
)
# For CMake automoc feature
get_target_property(QT_MOC_EXECUTABLE Qt5::moc LOCATION)
@@ -28,12 +34,15 @@ endif()
if (NOT TARGET Qt5::rcc)
add_executable(Qt5::rcc IMPORTED)
- set_target_properties(Qt5::rcc PROPERTIES
!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
- IMPORTED_LOCATION \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\"
+ set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
!!ELSE
- IMPORTED_LOCATION \"$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\"
+ set(imported_location \"$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\")
!!ENDIF
+ _qt5_Core_check_file_exists(${imported_location})
+
+ set_target_properties(Qt5::rcc PROPERTIES
+ IMPORTED_LOCATION ${imported_location}
)
endif()
@@ -51,6 +60,9 @@ set(_qt5_corelib_extra_includes \"${_qt5Core_install_prefix}/$${CMAKE_HOST_DATA_
!!ELSE
set(_qt5_corelib_extra_includes \"$${CMAKE_HOST_DATA_DIR}mkspecs/$${CMAKE_MKSPEC}\")
!!ENDIF
+foreach(_dir ${_qt5_corelib_extra_includes})
+ _qt5_Core_check_file_exists(${_dir})
+endforeach()
list(APPEND Qt5Core_INCLUDE_DIRS ${_qt5_corelib_extra_includes})
set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${_qt5_corelib_extra_includes})
@@ -87,23 +99,28 @@ if (NOT TARGET Qt5::WinMain)
!!IF !isEmpty(CMAKE_RELEASE_TYPE)
set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
- set_target_properties(Qt5::WinMain PROPERTIES
!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
- IMPORTED_LOCATION_RELEASE \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\"
+ set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
!!ELSE
- IMPORTED_LOCATION_RELEASE \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\"
+ set(imported_location \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_RELEASE}\")
!!ENDIF
+
+ set_target_properties(Qt5::WinMain PROPERTIES
+ IMPORTED_LOCATION_RELEASE ${imported_location}
)
!!ENDIF
!!IF !isEmpty(CMAKE_DEBUG_TYPE)
set_property(TARGET Qt5::WinMain APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
- set_target_properties(Qt5::WinMain PROPERTIES
+
!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
- IMPORTED_LOCATION_DEBUG \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\"
+ set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
!!ELSE
- IMPORTED_LOCATION_DEBUG \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\"
+ set(imported_location \"$${CMAKE_LIB_DIR}$${CMAKE_WINMAIN_FILE_LOCATION_DEBUG}\")
!!ENDIF
+
+ set_target_properties(Qt5::WinMain PROPERTIES
+ IMPORTED_LOCATION_DEBUG ${imported_location}
)
!!ENDIF
@@ -131,3 +148,5 @@ endif()
get_filename_component(_Qt5CoreConfigDir ${CMAKE_CURRENT_LIST_FILE} PATH)
set(_Qt5CTestMacros \"${_Qt5CoreConfigDir}/Qt5CTestMacros.cmake\")
+
+_qt5_Core_check_file_exists(${_Qt5CTestMacros})
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 1a5c9f6766..1cedd3a28d 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -1065,8 +1065,10 @@ QTextCodec *QTextCodec::codecForHtml(const QByteArray &ba, QTextCodec *defaultCo
}
}
}
+ if (!c)
+ c = defaultCodec;
- return defaultCodec;
+ return c;
}
/*!
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index ada69d081d..fb96ad2732 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -618,7 +618,6 @@
# endif
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404
/* C++11 features supported in GCC 4.4: */
-# define Q_COMPILER_ATOMICS
# define Q_COMPILER_AUTO_FUNCTION
# define Q_COMPILER_AUTO_TYPE
# define Q_COMPILER_CLASS_ENUM
@@ -642,6 +641,11 @@
# define Q_COMPILER_RANGE_FOR
# endif
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407
+ /* GCC 4.4 implemented <atomic> and std::atomic using its old intrinsics.
+ * However, the implementation is incomplete for most platforms until GCC 4.7:
+ * instead, std::atomic would use an external lock. Since we need an std::atomic
+ * that is behavior-compatible with QBasicAtomic, we only enable it here */
+# define Q_COMPILER_ATOMICS
/* GCC 4.6.x has problems dealing with noexcept expressions,
* so turn the feature on for 4.7 and above, only */
# define Q_COMPILER_NOEXCEPT
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h
index 6332e2d761..5b7edbafa6 100644
--- a/src/corelib/global/qflags.h
+++ b/src/corelib/global/qflags.h
@@ -97,31 +97,32 @@ public:
inline QFlags(const QFlags &other);
inline QFlags &operator=(const QFlags &other);
#endif
- Q_DECL_CONSTEXPR inline QFlags(Enum f) : i(f) {}
+ Q_DECL_CONSTEXPR inline QFlags(Enum f) : i(Int(f)) {}
Q_DECL_CONSTEXPR inline QFlags(Zero = 0) : i(0) {}
Q_DECL_CONSTEXPR inline QFlags(QFlag f) : i(f) {}
inline QFlags &operator&=(int mask) { i &= mask; return *this; }
inline QFlags &operator&=(uint mask) { i &= mask; return *this; }
+ inline QFlags &operator&=(Enum mask) { i &= Int(mask); return *this; }
inline QFlags &operator|=(QFlags f) { i |= f.i; return *this; }
- inline QFlags &operator|=(Enum f) { i |= f; return *this; }
+ inline QFlags &operator|=(Enum f) { i |= Int(f); return *this; }
inline QFlags &operator^=(QFlags f) { i ^= f.i; return *this; }
- inline QFlags &operator^=(Enum f) { i ^= f; return *this; }
+ inline QFlags &operator^=(Enum f) { i ^= Int(f); return *this; }
Q_DECL_CONSTEXPR inline operator Int() const { return i; }
Q_DECL_CONSTEXPR inline QFlags operator|(QFlags f) const { return QFlags(Enum(i | f.i)); }
- Q_DECL_CONSTEXPR inline QFlags operator|(Enum f) const { return QFlags(Enum(i | f)); }
+ Q_DECL_CONSTEXPR inline QFlags operator|(Enum f) const { return QFlags(Enum(i | Int(f))); }
Q_DECL_CONSTEXPR inline QFlags operator^(QFlags f) const { return QFlags(Enum(i ^ f.i)); }
- Q_DECL_CONSTEXPR inline QFlags operator^(Enum f) const { return QFlags(Enum(i ^ f)); }
+ Q_DECL_CONSTEXPR inline QFlags operator^(Enum f) const { return QFlags(Enum(i ^ Int(f))); }
Q_DECL_CONSTEXPR inline QFlags operator&(int mask) const { return QFlags(Enum(i & mask)); }
Q_DECL_CONSTEXPR inline QFlags operator&(uint mask) const { return QFlags(Enum(i & mask)); }
- Q_DECL_CONSTEXPR inline QFlags operator&(Enum f) const { return QFlags(Enum(i & f)); }
+ Q_DECL_CONSTEXPR inline QFlags operator&(Enum f) const { return QFlags(Enum(i & Int(f))); }
Q_DECL_CONSTEXPR inline QFlags operator~() const { return QFlags(Enum(~i)); }
Q_DECL_CONSTEXPR inline bool operator!() const { return !i; }
- Q_DECL_CONSTEXPR inline bool testFlag(Enum f) const { return (i & f) == f && (f != 0 || i == Int(f) ); }
+ Q_DECL_CONSTEXPR inline bool testFlag(Enum f) const { return (i & Int(f)) == Int(f) && (Int(f) != 0 || i == Int(f) ); }
private:
Int i;
};
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 9995daf1e9..4598f60d5e 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -72,7 +72,7 @@
# include <envLib.h>
#endif
-#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
+#if defined(Q_OS_MACX)
#include <CoreServices/CoreServices.h>
#endif
@@ -240,6 +240,12 @@ Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);
*/
/*!
+ \fn QFlags &QFlags::operator&=(Enum mask)
+
+ \overload
+*/
+
+/*!
\fn QFlags &QFlags::operator|=(QFlags other)
Performs a bitwise OR operation with \a other and stores the
@@ -928,8 +934,8 @@ bool qSharedBuild() Q_DECL_NOTHROW
\endlist
Some constants are defined only on certain platforms. You can use
- the preprocessor symbols Q_OS_WIN and Q_OS_MAC to test that
- the application is compiled under Windows or Mac.
+ the preprocessor symbols Q_OS_WIN and Q_OS_MACX to test that
+ the application is compiled under Windows or OS X.
\sa QLibraryInfo
*/
@@ -1073,6 +1079,27 @@ bool qSharedBuild() Q_DECL_NOTHROW
*/
/*!
+ \macro Q_OS_MAC
+ \relates <QtGlobal>
+
+ Defined on OS X and iOS (synonym for Q_OS_DARWIN).
+ */
+
+/*!
+ \macro Q_OS_MACX
+ \relates <QtGlobal>
+
+ Defined on OS X.
+ */
+
+/*!
+ \macro Q_OS_IOS
+ \relates <QtGlobal>
+
+ Defined on iOS.
+ */
+
+/*!
\macro Q_OS_WIN
\relates <QtGlobal>
@@ -1395,13 +1422,6 @@ bool qSharedBuild() Q_DECL_NOTHROW
*/
/*!
- \macro Q_OS_MAC
- \relates <QtGlobal>
-
- Defined on MAC OS (synonym for Darwin).
- */
-
-/*!
\macro Q_PROCESSOR_ALPHA
\relates <QtGlobal>
@@ -1646,7 +1666,7 @@ static const unsigned int qt_one = 1;
const int QSysInfo::ByteOrder = ((*((unsigned char *) &qt_one) == 0) ? BigEndian : LittleEndian);
#endif
-#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
+#if defined(Q_OS_MACX)
QT_BEGIN_INCLUDE_NAMESPACE
#include "private/qcore_mac_p.h"
@@ -1668,7 +1688,7 @@ Q_CORE_EXPORT void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding e
Q_CORE_EXPORT QString qt_mac_from_pascal_string(const Str255 pstr) {
return QCFString(CFStringCreateWithPascalString(0, pstr, CFStringGetSystemEncoding()));
}
-#endif // defined(Q_OS_MAC) && !defined(Q_OS_IOS)
+#endif // defined(Q_OS_MACX)
#if defined(Q_OS_MAC)
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 0d8a5b1428..2132e555cd 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -203,7 +203,11 @@ typedef quint64 qulonglong;
QT_BEGIN_INCLUDE_NAMESPACE
typedef unsigned char uchar;
typedef unsigned short ushort;
+#if defined(Q_QDOC) || !defined(Q_OS_ANDROID)
typedef unsigned int uint;
+#else
+# include <sys/types.h>
+#endif
typedef unsigned long ulong;
QT_END_INCLUDE_NAMESPACE
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 5fb9640b19..1eaebe5f90 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -291,6 +291,7 @@ static const struct {
{ "Sysroot", "" },
{ "HostPrefix", "" },
{ "HostBinaries", "bin" },
+ { "HostLibraries", "lib" },
{ "HostData", "." },
{ "TargetSpec", "" },
{ "HostSpec", "" },
diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h
index 1a00a14caf..b275e018a0 100644
--- a/src/corelib/global/qlibraryinfo.h
+++ b/src/corelib/global/qlibraryinfo.h
@@ -82,6 +82,7 @@ public:
SysrootPath,
HostPrefixPath,
HostBinariesPath,
+ HostLibrariesPath,
HostDataPath,
TargetSpecPath,
HostSpecPath,
diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h
index a6f244698d..2b798f9ea0 100644
--- a/src/corelib/global/qlogging.h
+++ b/src/corelib/global/qlogging.h
@@ -94,22 +94,38 @@ public:
void debug(const char *msg, ...) const
#if defined(Q_CC_GNU) && !defined(__INSURE__)
+# if defined(Q_CC_MINGW) && !defined(Q_CC_CLANG)
+ __attribute__ ((format (gnu_printf, 2, 3)))
+# else
__attribute__ ((format (printf, 2, 3)))
+# endif
#endif
;
void noDebug(const char *, ...) const
#if defined(Q_CC_GNU) && !defined(__INSURE__)
+# if defined(Q_CC_MINGW) && !defined(Q_CC_CLANG)
+ __attribute__ ((format (gnu_printf, 2, 3)))
+# else
__attribute__ ((format (printf, 2, 3)))
+# endif
#endif
{}
void warning(const char *msg, ...) const
#if defined(Q_CC_GNU) && !defined(__INSURE__)
+# if defined(Q_CC_MINGW) && !defined(Q_CC_CLANG)
+ __attribute__ ((format (gnu_printf, 2, 3)))
+# else
__attribute__ ((format (printf, 2, 3)))
+# endif
#endif
;
void critical(const char *msg, ...) const
#if defined(Q_CC_GNU) && !defined(__INSURE__)
+# if defined(Q_CC_MINGW) && !defined(Q_CC_CLANG)
+ __attribute__ ((format (gnu_printf, 2, 3)))
+# else
__attribute__ ((format (printf, 2, 3)))
+# endif
#endif
;
@@ -118,7 +134,11 @@ public:
#endif
void fatal(const char *msg, ...) const Q_DECL_NOTHROW
#if defined(Q_CC_GNU) && !defined(__INSURE__)
+# if defined(Q_CC_MINGW) && !defined(Q_CC_CLANG)
+ __attribute__ ((format (gnu_printf, 2, 3)))
+# else
__attribute__ ((format (printf, 2, 3)))
+# endif
#endif
;
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 95d9baafd5..74949b86f0 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -293,7 +293,8 @@ public:
WindowType_Mask = 0x000000ff,
MSWindowsFixedSizeDialogHint = 0x00000100,
MSWindowsOwnDC = 0x00000200,
- X11BypassWindowManagerHint = 0x00000400,
+ BypassWindowManagerHint = 0x00000400,
+ X11BypassWindowManagerHint = BypassWindowManagerHint,
FramelessWindowHint = 0x00000800,
WindowTitleHint = 0x00001000,
WindowSystemMenuHint = 0x00002000,
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index b6ce9e03fd..9eb0c6b8f2 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -1999,6 +1999,12 @@
\value MSWindowsOwnDC Gives the window its own display
context on Windows.
+ \value BypassWindowManagerHint This flag can be used to indicate to the platform plugin
+ that "all" window manager protocols should be disabled. This flag will behave
+ different depending on what operating system the application is running on and
+ what window manager is running. The flag can be used to get a native window
+ with no configuration set.
+
\value X11BypassWindowManagerHint Bypass the window
manager completely. This results in a borderless window
that is not managed at all (i.e., no keyboard input unless
diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h
index edeef3c461..58939cc013 100644
--- a/src/corelib/global/qsysinfo.h
+++ b/src/corelib/global/qsysinfo.h
@@ -3,7 +3,7 @@
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
-** This file is part of the FOO module of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h
index 0caac3d797..690442d066 100644
--- a/src/corelib/global/qsystemdetection.h
+++ b/src/corelib/global/qsystemdetection.h
@@ -50,8 +50,9 @@
The operating system, must be one of: (Q_OS_x)
DARWIN - Darwin OS (synonym for Q_OS_MAC)
- MAC - Mac OS X or iOS (iPhoneOS)
- IOS - iOS (treated as a variant of Mac OS)
+ MAC - OS X or iOS (synonym for Q_OS_DARWIN)
+ MACX - OS X
+ IOS - iOS
MSDOS - MS-DOS and Windows
OS2 - OS/2
OS2EMX - XFree86 on OS/2 (not PM)
@@ -166,7 +167,6 @@
#if defined(Q_OS_DARWIN)
# define Q_OS_MAC
-# define Q_OS_MACX /* Q_OS_MACX is only for compatibility.*/
# if defined(Q_OS_DARWIN64)
# define Q_OS_MAC64
# elif defined(Q_OS_DARWIN32)
@@ -175,6 +175,8 @@
# include <TargetConditionals.h>
# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
# define Q_OS_IOS
+# else
+# define Q_OS_MACX
# endif
#endif
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index da38f8ae21..52b80badb8 100644
--- a/src/corelib/io/qdatastream.cpp
+++ b/src/corelib/io/qdatastream.cpp
@@ -538,9 +538,9 @@ void QDataStream::setByteOrder(ByteOrder bo)
\value Qt_4_7 Same as Qt_4_6.
\value Qt_4_8 Same as Qt_4_6.
\value Qt_4_9 Same as Qt_4_6.
- \value Qt_5_0 Version 13 (Qt 5.0, Qt 5.1, Qt 5.2)
- \value Qt_5_1 Same as Qt_5_0.
- \value Qt_5_2 Same as Qt_5_0.
+ \value Qt_5_0 Version 13 (Qt 5.0)
+ \value Qt_5_1 Version 14 (Qt 5.1, Qt 5.2)
+ \value Qt_5_2 Same as Qt_5_1.
\sa setVersion(), version()
*/
@@ -572,6 +572,7 @@ void QDataStream::setByteOrder(ByteOrder bo)
\table
\header \li Qt Version \li QDataStream Version
+ \row \li Qt 5.1 \li 14
\row \li Qt 5.0 \li 13
\row \li Qt 4.6 \li 12
\row \li Qt 4.5 \li 11
diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h
index f893e6a503..eb064b3fe2 100644
--- a/src/corelib/io/qdatastream.h
+++ b/src/corelib/io/qdatastream.h
@@ -86,7 +86,7 @@ public:
Qt_4_8 = Qt_4_7,
Qt_4_9 = Qt_4_8,
Qt_5_0 = 13,
- Qt_5_1 = Qt_5_0,
+ Qt_5_1 = 14,
Qt_5_2 = Qt_5_1
#if QT_VERSION >= 0x050300
#error Add the datastream version for this Qt version
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h
index ce72fcd26d..9ed5f6e951 100644
--- a/src/corelib/io/qdebug.h
+++ b/src/corelib/io/qdebug.h
@@ -280,7 +280,7 @@ inline QDebug operator<<(QDebug debug, const QFlags<T> &flags)
debug.nospace() << '|';
else
needSeparator = true;
- debug.nospace() << "0x" << QByteArray::number(T(1 << i), 16).constData();
+ debug.nospace() << "0x" << QByteArray::number(typename QFlags<T>::Int(1) << i, 16).constData();
}
}
debug << ')';
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index afa62a075f..e46ba28f47 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -559,14 +559,43 @@ QFile::rename(const QString &newName)
}
// If the file exists and it is a case-changing rename ("foo" -> "Foo"),
// compare Ids to make sure it really is a different file.
- if (QFile::exists(newName)
- && (d->fileName.compare(newName, Qt::CaseInsensitive)
- || QFileSystemEngine::id(QFileSystemEntry(d->fileName)) != QFileSystemEngine::id(QFileSystemEntry(newName)))) {
- // ### Race condition. If a file is moved in after this, it /will/ be
- // overwritten. On Unix, the proper solution is to use hardlinks:
- // return ::link(old, new) && ::remove(old);
- d->setError(QFile::RenameError, tr("Destination file exists"));
+ if (QFile::exists(newName)) {
+ if (d->fileName.compare(newName, Qt::CaseInsensitive)
+ || QFileSystemEngine::id(QFileSystemEntry(d->fileName)) != QFileSystemEngine::id(QFileSystemEntry(newName))) {
+ // ### Race condition. If a file is moved in after this, it /will/ be
+ // overwritten. On Unix, the proper solution is to use hardlinks:
+ // return ::link(old, new) && ::remove(old);
+ d->setError(QFile::RenameError, tr("Destination file exists"));
+ return false;
+ }
+#ifdef Q_OS_LINUX
+ // rename() on Linux simply does nothing when renaming "foo" to "Foo" on a case-insensitive
+ // FS, such as FAT32. Move the file away and rename in 2 steps to work around.
+ QTemporaryFile tempFile(d->fileName + QStringLiteral(".XXXXXX"));
+ tempFile.setAutoRemove(false);
+ if (!tempFile.open(QIODevice::ReadWrite)) {
+ d->setError(QFile::RenameError, tempFile.errorString());
+ return false;
+ }
+ tempFile.close();
+ if (!d->engine()->rename(tempFile.fileName())) {
+ d->setError(QFile::RenameError, tr("Error while renaming."));
+ return false;
+ }
+ if (tempFile.rename(newName)) {
+ d->fileEngine->setFileName(newName);
+ d->fileName = newName;
+ return true;
+ }
+ d->setError(QFile::RenameError, tempFile.errorString());
+ // We need to restore the original file.
+ if (!tempFile.rename(d->fileName)) {
+ d->setError(QFile::RenameError, errorString() + QLatin1Char('\n')
+ + tr("Unable to restore from %1: %2").
+ arg(QDir::toNativeSeparators(tempFile.fileName()), tempFile.errorString()));
+ }
return false;
+#endif
}
unsetError();
close();
diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp
index 71ecc4a0a0..53cf6158ad 100644
--- a/src/corelib/io/qfilesystemengine.cpp
+++ b/src/corelib/io/qfilesystemengine.cpp
@@ -272,7 +272,7 @@ void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer)
// Attributes
entryFlags |= QFileSystemMetaData::ExistsAttribute;
size_ = statBuffer.st_size;
-#if defined (Q_OS_MAC) && !defined(Q_OS_IOS)
+#if defined(Q_OS_MACX)
if (statBuffer.st_flags & UF_HIDDEN) {
entryFlags |= QFileSystemMetaData::HiddenAttribute;
knownFlagsMask |= QFileSystemMetaData::HiddenAttribute;
diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h
index f3d3018da6..5719629958 100644
--- a/src/corelib/io/qfilesystemengine_p.h
+++ b/src/corelib/io/qfilesystemengine_p.h
@@ -84,7 +84,7 @@ public:
static QString resolveGroupName(uint groupId);
#endif
-#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
+#if defined(Q_OS_MACX)
static QString bundleName(const QFileSystemEntry &entry);
#else
static QString bundleName(const QFileSystemEntry &entry) { Q_UNUSED(entry) return QString(); }
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 4bfb03a41e..b18e32b29a 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -59,7 +59,7 @@
QT_BEGIN_NAMESPACE
-#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
+#if defined(Q_OS_MACX)
static inline bool _q_isMacHidden(const char *nativePath)
{
OSErr err;
@@ -143,7 +143,7 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link,
ret.chop(1);
return QFileSystemEntry(ret);
}
-#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
+#if defined(Q_OS_MACX)
{
FSRef fref;
if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(link.filePath())).data(), &fref, 0) == noErr) {
@@ -175,7 +175,7 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry,
return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath()));
#else
char *ret = 0;
-# if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
+# if defined(Q_OS_MACX)
// When using -mmacosx-version-min=10.4, we get the legacy realpath implementation,
// which does not work properly with the realpath(X,0) form. See QTBUG-28282.
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) {
@@ -335,7 +335,7 @@ QString QFileSystemEngine::resolveGroupName(uint groupId)
return QString();
}
-#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
+#if defined(Q_OS_MACX)
//static
QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry)
{
@@ -355,7 +355,7 @@ QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry)
bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data,
QFileSystemMetaData::MetaDataFlags what)
{
-#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
+#if defined(Q_OS_MACX)
if (what & QFileSystemMetaData::BundleType) {
if (!data.hasFlags(QFileSystemMetaData::DirectoryType))
what |= QFileSystemMetaData::DirectoryType;
@@ -364,7 +364,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
// Mac OS >= 10.5: st_flags & UF_HIDDEN
what |= QFileSystemMetaData::PosixStatFlags;
}
-#endif // defined(Q_OS_MAC) && !defined(Q_OS_IOS)
+#endif // defined(Q_OS_MACX)
if (what & QFileSystemMetaData::PosixStatFlags)
what |= QFileSystemMetaData::PosixStatFlags;
@@ -425,7 +425,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
| QFileSystemMetaData::ExistsAttribute;
}
-#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
+#if defined(Q_OS_MACX)
if (what & QFileSystemMetaData::AliasType)
{
if (entryExists) {
@@ -471,7 +471,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
data.knownFlagsMask |= QFileSystemMetaData::HiddenAttribute;
}
-#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
+#if defined(Q_OS_MACX)
if (what & QFileSystemMetaData::BundleType) {
if (entryExists && data.isDirectory()) {
QCFType<CFStringRef> path = CFStringCreateWithBytes(0,
diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h
index 2444a5fd63..1abc9b7ec4 100644
--- a/src/corelib/io/qfilesystemmetadata_p.h
+++ b/src/corelib/io/qfilesystemmetadata_p.h
@@ -100,7 +100,7 @@ public:
LinkType = 0x00010000,
FileType = 0x00020000,
DirectoryType = 0x00040000,
-#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
+#if defined(Q_OS_MACX)
BundleType = 0x00080000,
AliasType = 0x08000000,
#else
@@ -248,7 +248,7 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QFileSystemMetaData::MetaDataFlags)
-#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
+#if defined(Q_OS_MACX)
inline bool QFileSystemMetaData::isBundle() const { return (entryFlags & BundleType); }
inline bool QFileSystemMetaData::isAlias() const { return (entryFlags & AliasType); }
#else
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 59b6db7c79..b1861d8038 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -265,7 +265,13 @@ QProcessEnvironment &QProcessEnvironment::operator=(const QProcessEnvironment &o
*/
bool QProcessEnvironment::operator==(const QProcessEnvironment &other) const
{
- return d == other.d || (d && other.d && d->hash == other.d->hash);
+ if (d == other.d)
+ return true;
+ if (d && other.d) {
+ QProcessEnvironmentPrivate::OrderedMutexLocker locker(d, other.d);
+ return d->hash == other.d->hash;
+ }
+ return false;
}
/*!
@@ -276,6 +282,7 @@ bool QProcessEnvironment::operator==(const QProcessEnvironment &other) const
*/
bool QProcessEnvironment::isEmpty() const
{
+ // Needs no locking, as no hash nodes are accessed
return d ? d->hash.isEmpty() : true;
}
@@ -302,7 +309,10 @@ void QProcessEnvironment::clear()
*/
bool QProcessEnvironment::contains(const QString &name) const
{
- return d ? d->hash.contains(d->prepareName(name)) : false;
+ if (!d)
+ return false;
+ QProcessEnvironmentPrivate::MutexLocker locker(d);
+ return d->hash.contains(d->prepareName(name));
}
/*!
@@ -319,7 +329,8 @@ bool QProcessEnvironment::contains(const QString &name) const
*/
void QProcessEnvironment::insert(const QString &name, const QString &value)
{
- // d detaches from null
+ // our re-impl of detach() detaches from null
+ d.detach(); // detach before prepareName()
d->hash.insert(d->prepareName(name), d->prepareValue(value));
}
@@ -333,8 +344,10 @@ void QProcessEnvironment::insert(const QString &name, const QString &value)
*/
void QProcessEnvironment::remove(const QString &name)
{
- if (d)
+ if (d) {
+ d.detach(); // detach before prepareName()
d->hash.remove(d->prepareName(name));
+ }
}
/*!
@@ -349,6 +362,7 @@ QString QProcessEnvironment::value(const QString &name, const QString &defaultVa
if (!d)
return defaultValue;
+ QProcessEnvironmentPrivate::MutexLocker locker(d);
QProcessEnvironmentPrivate::Hash::ConstIterator it = d->hash.constFind(d->prepareName(name));
if (it == d->hash.constEnd())
return defaultValue;
@@ -371,7 +385,10 @@ QString QProcessEnvironment::value(const QString &name, const QString &defaultVa
*/
QStringList QProcessEnvironment::toStringList() const
{
- return d ? d->toList() : QStringList();
+ if (!d)
+ return QStringList();
+ QProcessEnvironmentPrivate::MutexLocker locker(d);
+ return d->toList();
}
/*!
@@ -382,7 +399,10 @@ QStringList QProcessEnvironment::toStringList() const
*/
QStringList QProcessEnvironment::keys() const
{
- return d ? d->keys() : QStringList();
+ if (!d)
+ return QStringList();
+ QProcessEnvironmentPrivate::MutexLocker locker(d);
+ return d->keys();
}
/*!
@@ -397,7 +417,8 @@ void QProcessEnvironment::insert(const QProcessEnvironment &e)
if (!e.d)
return;
- // d detaches from null
+ // our re-impl of detach() detaches from null
+ QProcessEnvironmentPrivate::MutexLocker locker(e.d);
d->insert(*e.d);
}
@@ -1006,6 +1027,7 @@ bool QProcessPrivate::_q_processDied()
return false;
#endif
#ifdef Q_OS_WIN
+ drainOutputPipes();
if (processFinishedNotifier)
processFinishedNotifier->setEnabled(false);
#endif
@@ -2339,7 +2361,7 @@ bool QProcess::startDetached(const QString &program)
}
QT_BEGIN_INCLUDE_NAMESPACE
-#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
+#if defined(Q_OS_MACX)
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
#elif defined(Q_OS_WINCE) || defined(Q_OS_IOS)
diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h
index 29adf37f74..9da3e63f38 100644
--- a/src/corelib/io/qprocess.h
+++ b/src/corelib/io/qprocess.h
@@ -219,7 +219,7 @@ Q_SIGNALS:
QPrivateSignal
#endif
);
- void finished(int exitCode);
+ void finished(int exitCode); // ### Qt 6: merge the two signals with a default value
void finished(int exitCode, QProcess::ExitStatus exitStatus);
void error(QProcess::ProcessError error);
void stateChanged(QProcess::ProcessState state
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h
index f658e54d4b..2a2cc9fb84 100644
--- a/src/corelib/io/qprocess_p.h
+++ b/src/corelib/io/qprocess_p.h
@@ -59,6 +59,9 @@
#include "QtCore/qshareddata.h"
#include "private/qringbuffer_p.h"
#include "private/qiodevice_p.h"
+#ifdef Q_OS_UNIX
+#include <QtCore/private/qorderedmutexlocker_p.h>
+#endif
#ifdef Q_OS_WIN
#include "QtCore/qt_windows.h"
@@ -148,6 +151,13 @@ public:
inline QString nameToString(const Key &name) const { return name; }
inline Value prepareValue(const QString &value) const { return value; }
inline QString valueToString(const Value &value) const { return value; }
+ struct MutexLocker {
+ MutexLocker(const QProcessEnvironmentPrivate *) {}
+ };
+ struct OrderedMutexLocker {
+ OrderedMutexLocker(const QProcessEnvironmentPrivate *,
+ const QProcessEnvironmentPrivate *) {}
+ };
#else
inline Key prepareName(const QString &name) const
{
@@ -164,6 +174,37 @@ public:
}
inline Value prepareValue(const QString &value) const { return Value(value); }
inline QString valueToString(const Value &value) const { return value.string(); }
+
+ struct MutexLocker : public QMutexLocker
+ {
+ MutexLocker(const QProcessEnvironmentPrivate *d) : QMutexLocker(&d->mutex) {}
+ };
+ struct OrderedMutexLocker : public QOrderedMutexLocker
+ {
+ OrderedMutexLocker(const QProcessEnvironmentPrivate *d1,
+ const QProcessEnvironmentPrivate *d2) :
+ QOrderedMutexLocker(&d1->mutex, &d2->mutex)
+ {}
+ };
+
+ QProcessEnvironmentPrivate() : QSharedData() {}
+ QProcessEnvironmentPrivate(const QProcessEnvironmentPrivate &other) :
+ QSharedData()
+ {
+ // This being locked ensures that the functions that only assign
+ // d pointers don't need explicit locking.
+ // We don't need to lock our own mutex, as this object is new and
+ // consequently not shared. For the same reason, non-const methods
+ // do not need a lock, as they detach objects (however, we need to
+ // ensure that they really detach before using prepareName()).
+ MutexLocker locker(&other);
+ hash = other.hash;
+ nameMap = other.nameMap;
+ // We need to detach our members, so that our mutex can protect them.
+ // As we are being detached, they likely would be detached a moment later anyway.
+ hash.detach();
+ nameMap.detach();
+ }
#endif
typedef QHash<Key, Value> Hash;
@@ -172,6 +213,8 @@ public:
#ifdef Q_OS_UNIX
typedef QHash<QString, Key> NameHash;
mutable NameHash nameMap;
+
+ mutable QMutex mutex;
#endif
static QProcessEnvironment fromList(const QStringList &list);
@@ -317,6 +360,7 @@ public:
bool waitForDeadChild();
#endif
#ifdef Q_OS_WIN
+ bool drainOutputPipes();
void flushPipeWriter();
qint64 pipeWriterBytesToWrite() const;
#endif
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 7f7066271b..e9957d2384 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -472,7 +472,7 @@ bool QProcessPrivate::createChannel(Channel &channel)
}
QT_BEGIN_INCLUDE_NAMESPACE
-#if defined(Q_OS_MAC) && !defined(Q_OS_IOS)
+#if defined(Q_OS_MACX)
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
#else
@@ -617,8 +617,10 @@ void QProcessPrivate::startProcess()
// Duplicate the environment.
int envc = 0;
char **envp = 0;
- if (environment.d.constData())
+ if (environment.d.constData()) {
+ QProcessEnvironmentPrivate::MutexLocker locker(environment.d);
envp = _q_dupEnvironment(environment.d.constData()->hash, &envc);
+ }
// Encode the working directory if it's non-empty, otherwise just pass 0.
const char *workingDirPtr = 0;
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 0f36c3adbf..7776852277 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -625,21 +625,21 @@ bool QProcessPrivate::waitForStarted(int)
return false;
}
-static bool drainOutputPipes(QProcessPrivate *d)
+bool QProcessPrivate::drainOutputPipes()
{
- if (!d->stdoutReader && !d->stderrReader)
+ if (!stdoutReader && !stderrReader)
return false;
bool readyReadEmitted = false;
forever {
bool readOperationActive = false;
- if (d->stdoutReader) {
- readyReadEmitted |= d->stdoutReader->waitForReadyRead(0);
- readOperationActive = d->stdoutReader->isReadOperationActive();
+ if (stdoutReader) {
+ readyReadEmitted |= stdoutReader->waitForReadyRead(0);
+ readOperationActive = stdoutReader->isReadOperationActive();
}
- if (d->stderrReader) {
- readyReadEmitted |= d->stderrReader->waitForReadyRead(0);
- readOperationActive |= d->stderrReader->isReadOperationActive();
+ if (stderrReader) {
+ readyReadEmitted |= stderrReader->waitForReadyRead(0);
+ readOperationActive |= stderrReader->isReadOperationActive();
}
if (!readOperationActive)
break;
@@ -669,7 +669,7 @@ bool QProcessPrivate::waitForReadyRead(int msecs)
if (!pid)
return false;
if (WaitForSingleObject(pid->hProcess, 0) == WAIT_OBJECT_0) {
- bool readyReadEmitted = drainOutputPipes(this);
+ bool readyReadEmitted = drainOutputPipes();
_q_processDied();
return readyReadEmitted;
}
@@ -772,12 +772,12 @@ bool QProcessPrivate::waitForFinished(int msecs)
timer.resetIncrements();
if (!pid) {
- drainOutputPipes(this);
+ drainOutputPipes();
return true;
}
if (WaitForSingleObject(pid->hProcess, timer.nextSleepTime()) == WAIT_OBJECT_0) {
- drainOutputPipes(this);
+ drainOutputPipes();
_q_processDied();
return true;
}
diff --git a/src/corelib/io/qprocess_wince.cpp b/src/corelib/io/qprocess_wince.cpp
index 712748aa59..ad9a328133 100644
--- a/src/corelib/io/qprocess_wince.cpp
+++ b/src/corelib/io/qprocess_wince.cpp
@@ -233,6 +233,11 @@ bool QProcessPrivate::waitForStarted(int)
return false;
}
+bool QProcessPrivate::drainOutputPipes()
+{
+ return true;
+}
+
bool QProcessPrivate::waitForReadyRead(int msecs)
{
return false;
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index 7dfc9b977c..04ec81e159 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -665,7 +665,7 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
qDebug() << " " << child+j << " :: " << name(child+j);
}
#endif
- const uint h = qt_hash(segment.toString());
+ const uint h = qt_hash(segment);
//do the binary search for the hash
int l = 0, r = child_count-1;
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index c71bb3afac..02e7b967ea 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -3731,7 +3731,7 @@ QString QUrl::errorString() const
return QString();
QString errorSource;
- int errorPosition;
+ int errorPosition = 0;
QUrlPrivate::ErrorCode errorCode = d->validityError(&errorSource, &errorPosition);
if (errorCode == QUrlPrivate::NoError)
return QString();
diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h
index 16f30fffd6..0284ab4830 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.h
+++ b/src/corelib/itemmodels/qabstractitemmodel.h
@@ -159,7 +159,7 @@ template <class Key, class T> class QMap;
class Q_CORE_EXPORT QAbstractItemModel : public QObject
{
Q_OBJECT
- Q_ENUMS(LayoutChangeHints)
+ Q_ENUMS(LayoutChangeHint)
friend class QPersistentModelIndexData;
friend class QAbstractItemViewPrivate;
diff --git a/src/corelib/json/qjson.cpp b/src/corelib/json/qjson.cpp
index ed6ef74e3c..8215aeefc0 100644
--- a/src/corelib/json/qjson.cpp
+++ b/src/corelib/json/qjson.cpp
@@ -149,6 +149,10 @@ bool Data::valid() const
int Base::reserveSpace(uint dataSize, int posInTable, uint numItems, bool replace)
{
Q_ASSERT(posInTable >= 0 && posInTable <= (int)length);
+ if (size + dataSize >= Value::MaxSize) {
+ qWarning("QJson: Document too large to store in data structure %d %d %d", (uint)size, dataSize, Value::MaxSize);
+ return 0;
+ }
offset off = tableOffset;
// move table to new position
@@ -334,7 +338,7 @@ bool Value::isValid(const Base *b) const
/*!
\internal
*/
-int Value::requiredStorage(const QJsonValue &v, bool *compressed)
+int Value::requiredStorage(QJsonValue &v, bool *compressed)
{
*compressed = false;
switch (v.t) {
@@ -351,6 +355,11 @@ int Value::requiredStorage(const QJsonValue &v, bool *compressed)
}
case QJsonValue::Array:
case QJsonValue::Object:
+ if (v.d && v.d->compactionCounter) {
+ v.detach();
+ v.d->compact();
+ v.base = static_cast<QJsonPrivate::Base *>(v.d->header->root());
+ }
return v.base ? v.base->size : sizeof(QJsonPrivate::Base);
case QJsonValue::Undefined:
case QJsonValue::Null:
diff --git a/src/corelib/json/qjson_p.h b/src/corelib/json/qjson_p.h
index 96a11cd40e..7d0162938d 100644
--- a/src/corelib/json/qjson_p.h
+++ b/src/corelib/json/qjson_p.h
@@ -545,6 +545,9 @@ public:
class Value
{
public:
+ enum {
+ MaxSize = (1<<27) - 1
+ };
union {
uint _dummy;
qle_bitfield<0, 3> type;
@@ -566,7 +569,7 @@ public:
bool isValid(const Base *b) const;
- static int requiredStorage(const QJsonValue &v, bool *compressed);
+ static int requiredStorage(QJsonValue &v, bool *compressed);
static uint valueToStore(const QJsonValue &v, uint offset);
static void copyData(const QJsonValue &v, char *dest, bool compressed);
};
diff --git a/src/corelib/json/qjsonarray.cpp b/src/corelib/json/qjsonarray.cpp
index 5f1c38a752..fb8d2e83ff 100644
--- a/src/corelib/json/qjsonarray.cpp
+++ b/src/corelib/json/qjsonarray.cpp
@@ -391,9 +391,10 @@ QJsonValue QJsonArray::takeAt(int i)
void QJsonArray::insert(int i, const QJsonValue &value)
{
Q_ASSERT (i >= 0 && i <= (a ? (int)a->length : 0));
+ QJsonValue val = value;
bool compressed;
- int valueSize = QJsonPrivate::Value::requiredStorage(value, &compressed);
+ int valueSize = QJsonPrivate::Value::requiredStorage(val, &compressed);
detach(valueSize + sizeof(QJsonPrivate::Value));
@@ -401,13 +402,16 @@ void QJsonArray::insert(int i, const QJsonValue &value)
a->tableOffset = sizeof(QJsonPrivate::Array);
int valueOffset = a->reserveSpace(valueSize, i, 1, false);
+ if (!valueOffset)
+ return;
+
QJsonPrivate::Value &v = (*a)[i];
- v.type = (value.t == QJsonValue::Undefined ? QJsonValue::Null : value.t);
+ v.type = (val.t == QJsonValue::Undefined ? QJsonValue::Null : val.t);
v.latinOrIntValue = compressed;
v.latinKey = false;
- v.value = QJsonPrivate::Value::valueToStore(value, valueOffset);
+ v.value = QJsonPrivate::Value::valueToStore(val, valueOffset);
if (valueSize)
- QJsonPrivate::Value::copyData(value, (char *)a + valueOffset, compressed);
+ QJsonPrivate::Value::copyData(val, (char *)a + valueOffset, compressed);
}
/*!
@@ -437,9 +441,10 @@ void QJsonArray::insert(int i, const QJsonValue &value)
void QJsonArray::replace(int i, const QJsonValue &value)
{
Q_ASSERT (a && i >= 0 && i < (int)(a->length));
+ QJsonValue val = value;
bool compressed;
- int valueSize = QJsonPrivate::Value::requiredStorage(value, &compressed);
+ int valueSize = QJsonPrivate::Value::requiredStorage(val, &compressed);
detach(valueSize);
@@ -447,13 +452,16 @@ void QJsonArray::replace(int i, const QJsonValue &value)
a->tableOffset = sizeof(QJsonPrivate::Array);
int valueOffset = a->reserveSpace(valueSize, i, 1, true);
+ if (!valueOffset)
+ return;
+
QJsonPrivate::Value &v = (*a)[i];
- v.type = (value.t == QJsonValue::Undefined ? QJsonValue::Null : value.t);
+ v.type = (val.t == QJsonValue::Undefined ? QJsonValue::Null : val.t);
v.latinOrIntValue = compressed;
v.latinKey = false;
- v.value = QJsonPrivate::Value::valueToStore(value, valueOffset);
+ v.value = QJsonPrivate::Value::valueToStore(val, valueOffset);
if (valueSize)
- QJsonPrivate::Value::copyData(value, (char *)a + valueOffset, compressed);
+ QJsonPrivate::Value::copyData(val, (char *)a + valueOffset, compressed);
++d->compactionCounter;
if (d->compactionCounter > 32u && d->compactionCounter >= unsigned(a->length) / 2u)
diff --git a/src/corelib/json/qjsondocument.h b/src/corelib/json/qjsondocument.h
index 4d4f3885dc..0354262e2c 100644
--- a/src/corelib/json/qjsondocument.h
+++ b/src/corelib/json/qjsondocument.h
@@ -67,7 +67,8 @@ struct Q_CORE_EXPORT QJsonParseError
IllegalUTF8String,
UnterminatedString,
MissingObject,
- DeepNesting
+ DeepNesting,
+ DocumentTooLarge
};
QString errorString() const;
diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp
index 55c736afce..2be9d8891d 100644
--- a/src/corelib/json/qjsonobject.cpp
+++ b/src/corelib/json/qjsonobject.cpp
@@ -317,9 +317,10 @@ QJsonObject::iterator QJsonObject::insert(const QString &key, const QJsonValue &
remove(key);
return end();
}
+ QJsonValue val = value;
bool latinOrIntValue;
- int valueSize = QJsonPrivate::Value::requiredStorage(value, &latinOrIntValue);
+ int valueSize = QJsonPrivate::Value::requiredStorage(val, &latinOrIntValue);
bool latinKey = QJsonPrivate::useCompressed(key);
int valueOffset = sizeof(QJsonPrivate::Entry) + QJsonPrivate::qStringSize(key, latinKey);
@@ -335,16 +336,21 @@ QJsonObject::iterator QJsonObject::insert(const QString &key, const QJsonValue &
if (keyExists)
++d->compactionCounter;
- o->reserveSpace(requiredSize, pos, 1, keyExists);
+ uint off = o->reserveSpace(requiredSize, pos, 1, keyExists);
+ if (!off)
+ return end();
QJsonPrivate::Entry *e = o->entryAt(pos);
- e->value.type = value.t;
+ e->value.type = val.t;
e->value.latinKey = latinKey;
e->value.latinOrIntValue = latinOrIntValue;
- e->value.value = QJsonPrivate::Value::valueToStore(value, (char *)e - (char *)o + valueOffset);
+ e->value.value = QJsonPrivate::Value::valueToStore(val, (char *)e - (char *)o + valueOffset);
QJsonPrivate::copyString((char *)(e + 1), key, latinKey);
if (valueSize)
- QJsonPrivate::Value::copyData(value, (char *)e + valueOffset, latinOrIntValue);
+ QJsonPrivate::Value::copyData(val, (char *)e + valueOffset, latinOrIntValue);
+
+ if (d->compactionCounter > 32u && d->compactionCounter >= unsigned(o->length) / 2u)
+ compact();
return iterator(this, pos);
}
diff --git a/src/corelib/json/qjsonparser.cpp b/src/corelib/json/qjsonparser.cpp
index e569cbf435..7989d18901 100644
--- a/src/corelib/json/qjsonparser.cpp
+++ b/src/corelib/json/qjsonparser.cpp
@@ -76,6 +76,7 @@ QT_BEGIN_NAMESPACE
#define JSONERR_UTERM_STR QT_TRANSLATE_NOOP("QJsonParseError", "unterminated string")
#define JSONERR_MISS_OBJ QT_TRANSLATE_NOOP("QJsonParseError", "object is missing after a comma")
#define JSONERR_DEEP_NEST QT_TRANSLATE_NOOP("QJsonParseError", "too deeply nested document")
+#define JSONERR_DOC_LARGE QT_TRANSLATE_NOOP("QJsonParseError", "too large document")
/*!
\class QJsonParseError
@@ -105,6 +106,7 @@ QT_BEGIN_NAMESPACE
\value UnterminatedString A string wasn't terminated with a quote
\value MissingObject An object was expected but couldn't be found
\value DeepNesting The JSON document is too deeply nested for the parser to parse it
+ \value DocumentTooLarge The JSON document is too large for the parser to parse it
*/
/*!
@@ -173,6 +175,9 @@ QString QJsonParseError::errorString() const
case DeepNesting:
sz = JSONERR_DEEP_NEST;
break;
+ case DocumentTooLarge:
+ sz = JSONERR_DOC_LARGE;
+ break;
}
#ifndef QT_BOOTSTRAPPED
return QCoreApplication::translate("QJsonParseError", sz);
@@ -579,6 +584,10 @@ bool Parser::parseValue(QJsonPrivate::Value *val, int baseOffset)
return false;
case Quote: {
val->type = QJsonValue::String;
+ if (current - baseOffset >= Value::MaxSize) {
+ lastError = QJsonParseError::DocumentTooLarge;
+ return false;
+ }
val->value = current - baseOffset;
bool latin1;
if (!parseString(&latin1))
@@ -590,6 +599,10 @@ bool Parser::parseValue(QJsonPrivate::Value *val, int baseOffset)
}
case BeginArray:
val->type = QJsonValue::Array;
+ if (current - baseOffset >= Value::MaxSize) {
+ lastError = QJsonParseError::DocumentTooLarge;
+ return false;
+ }
val->value = current - baseOffset;
if (!parseArray())
return false;
@@ -598,6 +611,10 @@ bool Parser::parseValue(QJsonPrivate::Value *val, int baseOffset)
return true;
case BeginObject:
val->type = QJsonValue::Object;
+ if (current - baseOffset >= Value::MaxSize) {
+ lastError = QJsonParseError::DocumentTooLarge;
+ return false;
+ }
val->value = current - baseOffset;
if (!parseObject())
return false;
@@ -707,6 +724,10 @@ bool Parser::parseNumber(QJsonPrivate::Value *val, int baseOffset)
int pos = reserveSpace(sizeof(double));
*(quint64 *)(data + pos) = qToLittleEndian(ui);
+ if (current - baseOffset >= Value::MaxSize) {
+ lastError = QJsonParseError::DocumentTooLarge;
+ return false;
+ }
val->value = pos - baseOffset;
val->latinOrIntValue = false;
diff --git a/src/corelib/kernel/qcorecmdlineargs_p.h b/src/corelib/kernel/qcorecmdlineargs_p.h
index 8292b21822..17a03a5b2d 100644
--- a/src/corelib/kernel/qcorecmdlineargs_p.h
+++ b/src/corelib/kernel/qcorecmdlineargs_p.h
@@ -101,11 +101,8 @@ static QVector<Char*> qWinCmdLine(Char *cmdParam, int length, int &argc)
}
}
if (*p == '\\') { // escape char?
- p++;
- if (*p == Char('\"') || *p == Char('\''))
- ; // yes
- else
- p--; // treat \ literally
+ if (*(p+1) == quote)
+ p++;
} else {
if (!quote && (*p == Char('\"') || *p == Char('\''))) { // " or ' quote
quote = *p++;
diff --git a/src/corelib/kernel/qeventdispatcher_blackberry.cpp b/src/corelib/kernel/qeventdispatcher_blackberry.cpp
index 5807683cc8..4cf1db18b4 100644
--- a/src/corelib/kernel/qeventdispatcher_blackberry.cpp
+++ b/src/corelib/kernel/qeventdispatcher_blackberry.cpp
@@ -50,6 +50,7 @@
//#define QEVENTDISPATCHERBLACKBERRY_DEBUG
#ifdef QEVENTDISPATCHERBLACKBERRY_DEBUG
+#include <QThread>
#define qEventDispatcherDebug qDebug() << QThread::currentThread()
#else
#define qEventDispatcherDebug QT_NO_QDEBUG_MACRO()
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 527a842d17..d4d2d527d4 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -4288,9 +4288,13 @@ QMetaObject::Connection QObject::connectImpl(const QObject *sender, void **signa
}
int signal_index = -1;
void *args[] = { &signal_index, signal };
- senderMetaObject->static_metacall(QMetaObject::IndexOfMethod, 0, args);
- if (signal_index < 0 || signal_index >= QMetaObjectPrivate::get(senderMetaObject)->signalCount) {
- qWarning("QObject::connect: signal not found in %s", senderMetaObject->className());
+ for (; senderMetaObject && signal_index < 0; senderMetaObject = senderMetaObject->superClass()) {
+ senderMetaObject->static_metacall(QMetaObject::IndexOfMethod, 0, args);
+ if (signal_index >= 0 && signal_index < QMetaObjectPrivate::get(senderMetaObject)->signalCount)
+ break;
+ }
+ if (!senderMetaObject) {
+ qWarning("QObject::connect: signal not found in %s", sender->metaObject()->className());
slotObj->destroyIfLastRef();
return QMetaObject::Connection(0);
}
diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp
index 1616fb9fab..a7d52f9652 100644
--- a/src/corelib/thread/qthreadpool.cpp
+++ b/src/corelib/thread/qthreadpool.cpp
@@ -215,7 +215,7 @@ void QThreadPoolPrivate::enqueueTask(QRunnable *runnable, int priority)
// put it on the queue
QList<QPair<QRunnable *, int> >::const_iterator begin = queue.constBegin();
QList<QPair<QRunnable *, int> >::const_iterator it = queue.constEnd();
- if (it != begin && priority < (*(it - 1)).second)
+ if (it != begin && priority > (*(it - 1)).second)
it = std::upper_bound(begin, --it, priority);
queue.insert(it - begin, qMakePair(runnable, priority));
runnableReady.wakeOne();
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 07b617ee2e..d8e3a78cdf 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -3691,8 +3691,11 @@ QDataStream &operator>>(QDataStream &in, QTime &time)
*/
QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime)
{
- if (out.version() >= 13) {
+ if (out.version() == 13) {
if (dateTime.isValid()) {
+ // This approach is wrong and should not be used again; it breaks
+ // the guarantee that a deserialised local datetime is the same time
+ // of day, regardless of which timezone it was serialised in.
QDateTime asUTC = dateTime.toUTC();
out << asUTC.d->date << asUTC.d->time;
} else {
@@ -3721,7 +3724,7 @@ QDataStream &operator>>(QDataStream &in, QDateTime &dateTime)
in >> dateTime.d->date >> dateTime.d->time;
- if (in.version() >= 13) {
+ if (in.version() == 13) {
qint8 ts = 0;
in >> ts;
if (dateTime.isValid()) {
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index ed756cbeb6..59e7a979dc 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -235,17 +235,16 @@ static void qt_initialize_qhash_seed()
\internal
Private copy of the implementation of the Qt 4 qHash algorithm for strings,
+ (that is, QChar-based arrays, so all QString-like classes),
to be used wherever the result is somehow stored or reused across multiple
Qt versions. The public qHash implementation can change at any time,
therefore one must not rely on the fact that it will always give the same
results.
- This function must *never* change its results.
+ The qt_hash functions must *never* change their results.
*/
-uint qt_hash(const QString &key) Q_DECL_NOTHROW
+static uint qt_hash(const QChar *p, int n) Q_DECL_NOTHROW
{
- const QChar *p = key.unicode();
- int n = key.size();
uint h = 0;
while (n--) {
@@ -256,6 +255,24 @@ uint qt_hash(const QString &key) Q_DECL_NOTHROW
return h;
}
+/*!
+ \internal
+ \overload
+*/
+uint qt_hash(const QString &key) Q_DECL_NOTHROW
+{
+ return qt_hash(key.unicode(), key.size());
+}
+
+/*!
+ \internal
+ \overload
+*/
+uint qt_hash(const QStringRef &key) Q_DECL_NOTHROW
+{
+ return qt_hash(key.unicode(), key.size());
+}
+
/*
The prime_deltas array is a table of selected prime values, even
though it doesn't look like one. The primes we are using are 1,
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 5d9238f453..e99a67d1e3 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -92,6 +92,7 @@ Q_CORE_EXPORT uint qHash(const QStringRef &key, uint seed = 0) Q_DECL_NOTHROW;
Q_CORE_EXPORT uint qHash(const QBitArray &key, uint seed = 0) Q_DECL_NOTHROW;
Q_CORE_EXPORT uint qHash(QLatin1String key, uint seed = 0) Q_DECL_NOTHROW;
Q_CORE_EXPORT uint qt_hash(const QString &key) Q_DECL_NOTHROW;
+Q_CORE_EXPORT uint qt_hash(const QStringRef &key) Q_DECL_NOTHROW;
#if defined(Q_CC_MSVC)
#pragma warning( push )
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 991cc9e170..ede783bf9e 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -695,19 +695,6 @@ QDataStream &operator>>(QDataStream &ds, QLocale &l)
static const int locale_data_size = sizeof(locale_data)/sizeof(QLocaleData) - 1;
-const QLocaleData *QLocalePrivate::dataPointerForIndex(quint16 index)
-{
-#ifndef QT_NO_SYSTEMLOCALE
- Q_ASSERT(index <= locale_data_size);
- if (index == locale_data_size)
- return system_data;
-#else
- Q_ASSERT(index < locale_data_size);
-#endif
-
- return &locale_data[index];
-}
-
Q_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer<QLocalePrivate>, defaultLocalePrivate,
(QLocalePrivate::create(defaultData(), default_number_options)))
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h
index a62ee9304b..56ed6c7534 100644
--- a/src/corelib/tools/qlocale_p.h
+++ b/src/corelib/tools/qlocale_p.h
@@ -215,7 +215,7 @@ public:
{
QLocalePrivate *retval = new QLocalePrivate;
retval->m_data = data;
- retval->ref.store(1);
+ retval->ref.store(0);
retval->m_numberOptions = numberOptions;
return retval;
}
@@ -247,7 +247,6 @@ public:
static QLocale::Country codeToCountry(const QString &code);
static void getLangAndCountry(const QString &name, QLocale::Language &lang,
QLocale::Script &script, QLocale::Country &cntry);
- static const QLocaleData *dataPointerForIndex(quint16 index);
QLocale::MeasurementSystem measurementSystem() const;
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index bced1f4ece..ef62621386 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -1279,7 +1279,7 @@ QT_END_NAMESPACE
# ifdef QT_SHARED_POINTER_BACKTRACE_SUPPORT
# if defined(__GLIBC__) && (__GLIBC__ >= 2) && !defined(__UCLIBC__) && !defined(QT_LINUXBASE)
# define BACKTRACE_SUPPORTED
-# elif defined(Q_OS_MACX)
+# elif defined(Q_OS_MAC)
# define BACKTRACE_SUPPORTED
# endif
# endif
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index ac49bdcdf6..d8aaa929dc 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -298,12 +298,20 @@ public:
QString &vsprintf(const char *format, va_list ap)
#if defined(Q_CC_GNU) && !defined(__INSURE__)
+# if defined(Q_CC_MINGW) && !defined(Q_CC_CLANG)
+ __attribute__ ((format (gnu_printf, 2, 0)))
+# else
__attribute__ ((format (printf, 2, 0)))
+# endif
#endif
;
QString &sprintf(const char *format, ...)
#if defined(Q_CC_GNU) && !defined(__INSURE__)
+# if defined(Q_CC_MINGW) && !defined(Q_CC_CLANG)
+ __attribute__ ((format (gnu_printf, 2, 3)))
+# else
__attribute__ ((format (printf, 2, 3)))
+# endif
#endif
;