diff options
Diffstat (limited to 'src')
118 files changed, 951 insertions, 638 deletions
diff --git a/src/angle/README.qt b/src/angle/README.qt index ce5b6332bc..2d484a0280 100644 --- a/src/angle/README.qt +++ b/src/angle/README.qt @@ -1,6 +1,6 @@ This is the ANGLE project from: -http://code.google.com/p/angleproject/ +https://chromium.googlesource.com/angle/angle/+/master/README.md The upstream version used here can be found in: diff --git a/src/angle/src/common/common.pri b/src/angle/src/common/common.pri index 83cd1e8687..9eae06d410 100644 --- a/src/angle/src/common/common.pri +++ b/src/angle/src/common/common.pri @@ -21,7 +21,7 @@ lib_replace.CONFIG = path QMAKE_PRL_INSTALL_REPLACE += lib_replace # DirectX is included in the Windows 8 Kit, but everything else requires the DX SDK. -winrt|if(msvc:!win32-msvc2005:!win32-msvc2008:!win32-msvc2010) { +winrt|msvc { FXC = fxc.exe } else { DX_DIR = $$(DXSDK_DIR) diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in index f492148a50..a5ed8b2ea3 100644 --- a/src/corelib/Qt5CoreConfigExtras.cmake.in +++ b/src/corelib/Qt5CoreConfigExtras.cmake.in @@ -46,21 +46,6 @@ if (NOT TARGET Qt5::rcc) ) endif() -if (NOT TARGET Qt5::qdoc) - add_executable(Qt5::qdoc IMPORTED) - -!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE) - set(imported_location \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}qdoc$$CMAKE_BIN_SUFFIX\") -!!ELSE - set(imported_location \"$${CMAKE_BIN_DIR}qdoc$$CMAKE_BIN_SUFFIX\") -!!ENDIF - _qt5_Core_check_file_exists(${imported_location}) - - set_target_properties(Qt5::qdoc PROPERTIES - IMPORTED_LOCATION ${imported_location} - ) -endif() - set(Qt5Core_QMAKE_EXECUTABLE Qt5::qmake) set(Qt5Core_MOC_EXECUTABLE Qt5::moc) set(Qt5Core_RCC_EXECUTABLE Qt5::rcc) diff --git a/src/corelib/arch/qatomic_cxx11.h b/src/corelib/arch/qatomic_cxx11.h index bb49aae4fb..9658aca37c 100644 --- a/src/corelib/arch/qatomic_cxx11.h +++ b/src/corelib/arch/qatomic_cxx11.h @@ -53,44 +53,168 @@ QT_END_NAMESPACE #pragma qt_sync_stop_processing #endif -#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE -#define Q_ATOMIC_INT_TEST_AND_SET_IS_SOMETIMES_NATIVE -#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_SOMETIMES_NATIVE -#define Q_ATOMIC_INT_FETCH_AND_ADD_IS_SOMETIMES_NATIVE +/* Attempt to detect whether the atomic operations exist in hardware + * or whether they are emulated by way of a lock. + * + * C++11 29.4 [atomics.lockfree] p1 says + * + * The ATOMIC_..._LOCK_FREE macros indicate the lock-free property of the + * corresponding atomic types, with the signed and unsigned variants grouped + * together. The properties also apply to the corresponding (partial) + * specializations of the atomic template. A value of 0 indicates that the + * types are never lock-free. A value of 1 indicates that the types are + * sometimes lock-free. A value of 2 indicates that the types are always + * lock-free. + * + * We have a problem when the value is 1: we'd need to check at runtime, but + * QAtomicInteger requires a constexpr answer (defect introduced in Qt 5.0). So + * we'll err in the side of caution and say it isn't. + */ + +// ### Qt 6: make non-constexpr (see above) +template <int N> struct QAtomicTraits +{ static Q_DECL_CONSTEXPR inline bool isLockFree() Q_DECL_NOTHROW; }; #define Q_ATOMIC_INT32_IS_SUPPORTED -#define Q_ATOMIC_INT32_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE -#define Q_ATOMIC_INT32_TEST_AND_SET_IS_SOMETIMES_NATIVE -#define Q_ATOMIC_INT32_FETCH_AND_STORE_IS_SOMETIMES_NATIVE -#define Q_ATOMIC_INT32_FETCH_AND_ADD_IS_SOMETIMES_NATIVE +#if ATOMIC_INT_LOCK_FREE == 2 +# define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT_TEST_AND_SET_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT_FETCH_AND_ADD_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT32_REFERENCE_COUNTING_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT32_TEST_AND_SET_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT32_FETCH_AND_STORE_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT32_FETCH_AND_ADD_IS_ALWAYS_NATIVE + +template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<4>::isLockFree() Q_DECL_NOTHROW +{ return true; } +#elif ATOMIC_INT_LOCK_FREE == 1 +# define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE +# define Q_ATOMIC_INT_TEST_AND_SET_IS_SOMETIMES_NATIVE +# define Q_ATOMIC_INT_FETCH_AND_STORE_IS_SOMETIMES_NATIVE +# define Q_ATOMIC_INT_FETCH_AND_ADD_IS_SOMETIMES_NATIVE +# define Q_ATOMIC_INT32_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE +# define Q_ATOMIC_INT32_TEST_AND_SET_IS_SOMETIMES_NATIVE +# define Q_ATOMIC_INT32_FETCH_AND_STORE_IS_SOMETIMES_NATIVE +# define Q_ATOMIC_INT32_FETCH_AND_ADD_IS_SOMETIMES_NATIVE + +template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<4>::isLockFree() Q_DECL_NOTHROW +{ return false; } +#else +# define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_NEVER_NATIVE +# define Q_ATOMIC_INT_TEST_AND_SET_IS_NEVER_NATIVE +# define Q_ATOMIC_INT_FETCH_AND_STORE_IS_NEVER_NATIVE +# define Q_ATOMIC_INT_FETCH_AND_ADD_IS_NEVER_NATIVE +# define Q_ATOMIC_INT32_REFERENCE_COUNTING_IS_NEVER_NATIVE +# define Q_ATOMIC_INT32_TEST_AND_SET_IS_NEVER_NATIVE +# define Q_ATOMIC_INT32_FETCH_AND_STORE_IS_NEVER_NATIVE +# define Q_ATOMIC_INT32_FETCH_AND_ADD_IS_NEVER_NATIVE + +template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<4>::isLockFree() Q_DECL_NOTHROW +{ return false; } +#endif -#define Q_ATOMIC_POINTER_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE -#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_SOMETIMES_NATIVE -#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_SOMETIMES_NATIVE -#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_SOMETIMES_NATIVE +#if ATOMIC_POINTER_LOCK_FREE == 2 +# define Q_ATOMIC_POINTER_REFERENCE_COUNTING_IS_ALWAYS_NATIVE +# define Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE +# define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE +# define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_ALWAYS_NATIVE +#elif ATOMIC_POINTER_LOCK_FREE == 1 +# define Q_ATOMIC_POINTER_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE +# define Q_ATOMIC_POINTER_TEST_AND_SET_IS_SOMETIMES_NATIVE +# define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_SOMETIMES_NATIVE +# define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_SOMETIMES_NATIVE +#else +# define Q_ATOMIC_POINTER_REFERENCE_COUNTING_IS_NEVER_NATIVE +# define Q_ATOMIC_POINTER_TEST_AND_SET_IS_NEVER_NATIVE +# define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_NEVER_NATIVE +# define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_NEVER_NATIVE +#endif template<> struct QAtomicOpsSupport<1> { enum { IsSupported = 1 }; }; -template<> struct QAtomicOpsSupport<2> { enum { IsSupported = 1 }; }; -template<> struct QAtomicOpsSupport<8> { enum { IsSupported = 1 }; }; - #define Q_ATOMIC_INT8_IS_SUPPORTED -#define Q_ATOMIC_INT8_REFERENCE_COUNTING_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT8_TEST_AND_SET_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT8_FETCH_AND_STORE_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT8_FETCH_AND_ADD_IS_ALWAYS_NATIVE +#if ATOMIC_CHAR_LOCK_FREE == 2 +# define Q_ATOMIC_INT8_REFERENCE_COUNTING_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT8_TEST_AND_SET_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT8_FETCH_AND_STORE_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT8_FETCH_AND_ADD_IS_ALWAYS_NATIVE + +template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<1>::isLockFree() Q_DECL_NOTHROW +{ return true; } +#elif ATOMIC_CHAR_LOCK_FREE == 1 +# define Q_ATOMIC_INT8_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE +# define Q_ATOMIC_INT8_TEST_AND_SET_IS_SOMETIMES_NATIVE +# define Q_ATOMIC_INT8_FETCH_AND_STORE_IS_SOMETIMES_NATIVE +# define Q_ATOMIC_INT8_FETCH_AND_ADD_IS_SOMETIMES_NATIVE + +template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<1>::isLockFree() Q_DECL_NOTHROW +{ return false; } +#else +# define Q_ATOMIC_INT8_REFERENCE_COUNTING_IS_NEVER_NATIVE +# define Q_ATOMIC_INT8_TEST_AND_SET_IS_NEVER_NATIVE +# define Q_ATOMIC_INT8_FETCH_AND_STORE_IS_NEVER_NATIVE +# define Q_ATOMIC_INT8_FETCH_AND_ADD_IS_NEVER_NATIVE +template <> Q_DECL_CONSTEXPR bool QAtomicTraits<1>::isLockFree() Q_DECL_NOTHROW +{ return false; } +#endif + +template<> struct QAtomicOpsSupport<2> { enum { IsSupported = 1 }; }; #define Q_ATOMIC_INT16_IS_SUPPORTED -#define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT16_TEST_AND_SET_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_ALWAYS_NATIVE +#if ATOMIC_SHORT_LOCK_FREE == 2 +# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT16_TEST_AND_SET_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_ALWAYS_NATIVE + +template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<2>::isLockFree() Q_DECL_NOTHROW +{ return false; } +#elif ATOMIC_SHORT_LOCK_FREE == 1 +# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE +# define Q_ATOMIC_INT16_TEST_AND_SET_IS_SOMETIMES_NATIVE +# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_SOMETIMES_NATIVE +# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_SOMETIMES_NATIVE + +template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<2>::isLockFree() Q_DECL_NOTHROW +{ return false; } +#else +# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_NEVER_NATIVE +# define Q_ATOMIC_INT16_TEST_AND_SET_IS_NEVER_NATIVE +# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_NEVER_NATIVE +# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_NEVER_NATIVE + +template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<2>::isLockFree() Q_DECL_NOTHROW +{ return false; } +#endif #ifndef QT_NO_STD_ATOMIC64 +template<> struct QAtomicOpsSupport<8> { enum { IsSupported = 1 }; }; # define Q_ATOMIC_INT64_IS_SUPPORTED -# define Q_ATOMIC_INT64_REFERENCE_COUNTING_IS_ALWAYS_NATIVE -# define Q_ATOMIC_INT64_TEST_AND_SET_IS_ALWAYS_NATIVE -# define Q_ATOMIC_INT64_FETCH_AND_STORE_IS_ALWAYS_NATIVE -# define Q_ATOMIC_INT64_FETCH_AND_ADD_IS_ALWAYS_NATIVE +# if ATOMIC_LLONG_LOCK_FREE == 2 +# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT16_TEST_AND_SET_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_ALWAYS_NATIVE + +template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<8>::isLockFree() Q_DECL_NOTHROW +{ return true; } +# elif ATOMIC_LLONG_LOCK_FREE == 1 +# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE +# define Q_ATOMIC_INT16_TEST_AND_SET_IS_SOMETIMES_NATIVE +# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_SOMETIMES_NATIVE +# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_SOMETIMES_NATIVE + +template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<8>::isLockFree() Q_DECL_NOTHROW +{ return false; } +# else +# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_NEVER_NATIVE +# define Q_ATOMIC_INT16_TEST_AND_SET_IS_NEVER_NATIVE +# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_NEVER_NATIVE +# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_NEVER_NATIVE + +template <> Q_DECL_CONSTEXPR inline bool QAtomicTraits<8>::isLockFree() Q_DECL_NOTHROW +{ return false; } +# endif #endif template <typename X> struct QAtomicOps @@ -133,7 +257,7 @@ template <typename X> struct QAtomicOps _q_value.store(newValue, std::memory_order_release); } - static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; } + static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return isTestAndSetNative(); } static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return false; } template <typename T> static inline bool ref(std::atomic<T> &_q_value) @@ -147,7 +271,8 @@ template <typename X> struct QAtomicOps return --_q_value != 0; } - static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return false; } + static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW + { return QAtomicTraits<sizeof(X)>::isLockFree(); } static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; } template <typename T> @@ -186,7 +311,7 @@ template <typename X> struct QAtomicOps return tmp; } - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return false; } + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return isTestAndSetNative(); } static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return false; } template <typename T> @@ -213,7 +338,7 @@ template <typename X> struct QAtomicOps return _q_value.exchange(newValue, std::memory_order_acq_rel); } - static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return false; } + static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return isTestAndSetNative(); } static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return false; } template <typename T> static inline diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp index ae969ca269..1169ad5536 100644 --- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp @@ -603,13 +603,13 @@ template<> class QTypeInfo<A> : public QTypeInfoMerger<A, B, C, D> {}; void overloadedFunction(); void overloadedFunction(int, QString); }; - ... qOverload<>(&Foo:overloadedFunction) - ... qOverload<int, QString>(&Foo:overloadedFunction) + ... qOverload<>(&Foo::overloadedFunction) + ... qOverload<int, QString>(&Foo::overloadedFunction) //! [52] //! [53] - ... QOverload<>::of(&Foo:overloadedFunction) - ... QOverload<int, QString>::of(&Foo:overloadedFunction) + ... QOverload<>::of(&Foo::overloadedFunction) + ... QOverload<int, QString>::of(&Foo::overloadedFunction) //! [53] //! [54] @@ -617,8 +617,8 @@ template<> class QTypeInfo<A> : public QTypeInfoMerger<A, B, C, D> {}; void overloadedFunction(int, QString); void overloadedFunction(int, QString) const; }; - ... qConstOverload<>(&Foo:overloadedFunction) - ... qNonConstOverload<int, QString>(&Foo:overloadedFunction) + ... qConstOverload<>(&Foo::overloadedFunction) + ... qNonConstOverload<int, QString>(&Foo::overloadedFunction) //! [54] //! [qlikely] diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp index 576aea1cf5..ca1ea21b02 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qvariant.cpp @@ -147,10 +147,7 @@ QVariant data = QVariant::fromValue(object); //! [9] -QList<int> intList; -intList.push_back(7); -intList.push_back(11); -intList.push_back(42); +QList<int> intList = {7, 11, 42}; QVariant variant = QVariant::fromValue(intList); if (variant.canConvert<QVariantList>()) { diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 0fe095b8d3..3aee15051f 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1123,7 +1123,7 @@ void QMessagePattern::setPattern(const QString &pattern) if (m.hasMatch()) { int depth = m.capturedRef(1).toInt(); if (depth <= 0) - error += QStringLiteral("QT_MESSAGE_PATTERN: %{backtrace} depth must be a number greater than 0\n"); + error += QLatin1String("QT_MESSAGE_PATTERN: %{backtrace} depth must be a number greater than 0\n"); else backtraceDepth = depth; } @@ -1135,7 +1135,7 @@ void QMessagePattern::setPattern(const QString &pattern) backtraceParams.backtraceSeparator = backtraceSeparator; backtraceArgs.append(backtraceParams); #else - error += QStringLiteral("QT_MESSAGE_PATTERN: %{backtrace} is not supported by this Qt build\n"); + error += QLatin1String("QT_MESSAGE_PATTERN: %{backtrace} is not supported by this Qt build\n"); #endif } @@ -1156,7 +1156,7 @@ void QMessagePattern::setPattern(const QString &pattern) else if (lexeme == QLatin1String(endifTokenC)) { tokens[i] = endifTokenC; if (!inIf && !nestedIfError) - error += QStringLiteral("QT_MESSAGE_PATTERN: %{endif} without an %{if-*}\n"); + error += QLatin1String("QT_MESSAGE_PATTERN: %{endif} without an %{if-*}\n"); inIf = false; } else { tokens[i] = emptyTokenC; @@ -1172,9 +1172,9 @@ void QMessagePattern::setPattern(const QString &pattern) } } if (nestedIfError) - error += QStringLiteral("QT_MESSAGE_PATTERN: %{if-*} cannot be nested\n"); + error += QLatin1String("QT_MESSAGE_PATTERN: %{if-*} cannot be nested\n"); else if (inIf) - error += QStringLiteral("QT_MESSAGE_PATTERN: missing %{endif}\n"); + error += QLatin1String("QT_MESSAGE_PATTERN: missing %{endif}\n"); if (!error.isEmpty()) { #if defined(Q_OS_WINRT) OutputDebugString(reinterpret_cast<const wchar_t*>(error.utf16())); diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h index c7f8840a82..5956f9ac40 100644 --- a/src/corelib/io/qdatastream.h +++ b/src/corelib/io/qdatastream.h @@ -195,6 +195,29 @@ private: int readBlock(char *data, int len); }; +namespace QtPrivate { + +class StreamStateSaver +{ +public: + inline StreamStateSaver(QDataStream *s) : stream(s), oldStatus(s->status()) + { + stream->resetStatus(); + } + inline ~StreamStateSaver() + { + if (oldStatus != QDataStream::Ok) { + stream->resetStatus(); + stream->setStatus(oldStatus); + } + } + +private: + QDataStream *stream; + QDataStream::Status oldStatus; +}; + +} // QtPrivate namespace /***************************************************************************** QDataStream inline functions @@ -239,6 +262,8 @@ inline QDataStream &QDataStream::operator<<(quint64 i) template <typename T> QDataStream& operator>>(QDataStream& s, QList<T>& l) { + QtPrivate::StreamStateSaver stateSaver(&s); + l.clear(); quint32 c; s >> c; @@ -247,10 +272,13 @@ QDataStream& operator>>(QDataStream& s, QList<T>& l) { T t; s >> t; - l.append(t); - if (s.atEnd()) + if (s.status() != QDataStream::Ok) { + l.clear(); break; + } + l.append(t); } + return s; } @@ -266,6 +294,8 @@ QDataStream& operator<<(QDataStream& s, const QList<T>& l) template <typename T> QDataStream& operator>>(QDataStream& s, QLinkedList<T>& l) { + QtPrivate::StreamStateSaver stateSaver(&s); + l.clear(); quint32 c; s >> c; @@ -273,10 +303,13 @@ QDataStream& operator>>(QDataStream& s, QLinkedList<T>& l) { T t; s >> t; - l.append(t); - if (s.atEnd()) + if (s.status() != QDataStream::Ok) { + l.clear(); break; + } + l.append(t); } + return s; } @@ -293,6 +326,8 @@ QDataStream& operator<<(QDataStream& s, const QLinkedList<T>& l) template<typename T> QDataStream& operator>>(QDataStream& s, QVector<T>& v) { + QtPrivate::StreamStateSaver stateSaver(&s); + v.clear(); quint32 c; s >> c; @@ -300,8 +335,13 @@ QDataStream& operator>>(QDataStream& s, QVector<T>& v) for(quint32 i = 0; i < c; ++i) { T t; s >> t; + if (s.status() != QDataStream::Ok) { + v.clear(); + break; + } v[i] = t; } + return s; } @@ -317,16 +357,21 @@ QDataStream& operator<<(QDataStream& s, const QVector<T>& v) template <typename T> QDataStream &operator>>(QDataStream &in, QSet<T> &set) { + QtPrivate::StreamStateSaver stateSaver(&in); + set.clear(); quint32 c; in >> c; for (quint32 i = 0; i < c; ++i) { T t; in >> t; - set << t; - if (in.atEnd()) + if (in.status() != QDataStream::Ok) { + set.clear(); break; + } + set << t; } + return in; } @@ -345,10 +390,9 @@ QDataStream& operator<<(QDataStream &out, const QSet<T> &set) template <class Key, class T> Q_OUTOFLINE_TEMPLATE QDataStream &operator>>(QDataStream &in, QHash<Key, T> &hash) { - QDataStream::Status oldStatus = in.status(); - in.resetStatus(); - hash.clear(); + QtPrivate::StreamStateSaver stateSaver(&in); + hash.clear(); quint32 n; in >> n; @@ -364,10 +408,6 @@ Q_OUTOFLINE_TEMPLATE QDataStream &operator>>(QDataStream &in, QHash<Key, T> &has if (in.status() != QDataStream::Ok) hash.clear(); - if (oldStatus != QDataStream::Ok) { - in.resetStatus(); - in.setStatus(oldStatus); - } return in; } @@ -391,10 +431,9 @@ template <class aKey, class aT> Q_OUTOFLINE_TEMPLATE QDataStream &operator>>(QDataStream &in, QMap<aKey, aT> &map) #endif { - QDataStream::Status oldStatus = in.status(); - in.resetStatus(); - map.clear(); + QtPrivate::StreamStateSaver stateSaver(&in); + map.clear(); quint32 n; in >> n; @@ -410,10 +449,6 @@ Q_OUTOFLINE_TEMPLATE QDataStream &operator>>(QDataStream &in, QMap<aKey, aT> &ma } if (in.status() != QDataStream::Ok) map.clear(); - if (oldStatus != QDataStream::Ok) { - in.resetStatus(); - in.setStatus(oldStatus); - } return in; } diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 8197ea63e7..91953ebf26 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -694,7 +694,7 @@ QString QDir::filePath(const QString &fileName) const { const QDirPrivate* d = d_ptr.constData(); if (isAbsolutePath(fileName)) - return QString(fileName); + return fileName; QString ret = d->dirEntry.filePath(); if (!fileName.isEmpty()) { diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp index 63a15c9fac..920281cef7 100644 --- a/src/corelib/io/qfileselector.cpp +++ b/src/corelib/io/qfileselector.cpp @@ -388,7 +388,7 @@ QStringList QFileSelectorPrivate::platformSelectors() # endif QString productName = QSysInfo::productType(); # ifdef Q_OS_MACOS - if (productName != QStringLiteral("osx")) + if (productName != QLatin1String("osx")) ret << QStringLiteral("osx"); // compatibility # endif if (productName != QLatin1String("unknown")) diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp index 79141d1e8f..924d2e7214 100644 --- a/src/corelib/io/qlockfile_unix.cpp +++ b/src/corelib/io/qlockfile_unix.cpp @@ -71,12 +71,12 @@ #elif defined(Q_OS_HAIKU) # include <kernel/OS.h> #elif defined(Q_OS_BSD4) && !defined(QT_PLATFORM_UIKIT) -# if !defined(Q_OS_NETBSD) -# include <sys/user.h> -# endif # include <sys/cdefs.h> # include <sys/param.h> # include <sys/sysctl.h> +# if !defined(Q_OS_NETBSD) +# include <sys/user.h> +# endif #endif QT_BEGIN_NAMESPACE diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index ed3273eb2e..856108e417 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -248,8 +248,7 @@ QString QSettingsPrivate::actualKey(const QString &key) const { QString n = normalizedKey(key); Q_ASSERT_X(!n.isEmpty(), "QSettings", "empty key"); - n.prepend(groupPrefix); - return n; + return groupPrefix + n; } /* @@ -324,10 +323,9 @@ void QSettingsPrivate::processChild(QStringRef key, ChildSpec spec, QStringList void QSettingsPrivate::beginGroupOrArray(const QSettingsGroup &group) { groupStack.push(group); - if (!group.name().isEmpty()) { - groupPrefix += group.name(); - groupPrefix += QLatin1Char('/'); - } + const QString name = group.name(); + if (!name.isEmpty()) + groupPrefix += name + QLatin1Char('/'); } /* @@ -403,9 +401,9 @@ QString QSettingsPrivate::variantToString(const QVariant &v) case QVariant::ByteArray: { QByteArray a = v.toByteArray(); - result = QLatin1String("@ByteArray("); - result += QString::fromLatin1(a.constData(), a.size()); - result += QLatin1Char(')'); + result = QLatin1String("@ByteArray(") + + QLatin1String(a.constData(), a.size()) + + QLatin1Char(')'); break; } @@ -425,33 +423,17 @@ QString QSettingsPrivate::variantToString(const QVariant &v) #ifndef QT_NO_GEOM_VARIANT case QVariant::Rect: { QRect r = qvariant_cast<QRect>(v); - result += QLatin1String("@Rect("); - result += QString::number(r.x()); - result += QLatin1Char(' '); - result += QString::number(r.y()); - result += QLatin1Char(' '); - result += QString::number(r.width()); - result += QLatin1Char(' '); - result += QString::number(r.height()); - result += QLatin1Char(')'); + result = QString::asprintf("@Rect(%d %d %d %d)", r.x(), r.y(), r.width(), r.height()); break; } case QVariant::Size: { QSize s = qvariant_cast<QSize>(v); - result += QLatin1String("@Size("); - result += QString::number(s.width()); - result += QLatin1Char(' '); - result += QString::number(s.height()); - result += QLatin1Char(')'); + result = QString::asprintf("@Size(%d %d)", s.width(), s.height()); break; } case QVariant::Point: { QPoint p = qvariant_cast<QPoint>(v); - result += QLatin1String("@Point("); - result += QString::number(p.x()); - result += QLatin1Char(' '); - result += QString::number(p.y()); - result += QLatin1Char(')'); + result = QString::asprintf("@Point(%d %d)", p.x(), p.y()); break; } #endif // !QT_NO_GEOM_VARIANT @@ -474,9 +456,9 @@ QString QSettingsPrivate::variantToString(const QVariant &v) s << v; } - result = QLatin1String(typeSpec); - result += QString::fromLatin1(a.constData(), a.size()); - result += QLatin1Char(')'); + result = QLatin1String(typeSpec) + + QLatin1String(a.constData(), a.size()) + + QLatin1Char(')'); #else Q_ASSERT(!"QSettings: Cannot save custom types without QDataStream support"); #endif @@ -647,8 +629,7 @@ void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result, && ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F'))) { - result += "\\x"; - result += QByteArray::number(ch, 16); + result += "\\x" + QByteArray::number(ch, 16); continue; } @@ -687,8 +668,7 @@ void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result, break; default: if (ch <= 0x1F || (ch >= 0x7F && !useCodec)) { - result += "\\x"; - result += QByteArray::number(ch, 16); + result += "\\x" + QByteArray::number(ch, 16); escapeNextIfDigit = true; #ifndef QT_NO_TEXTCODEC } else if (useCodec) { @@ -1038,10 +1018,33 @@ static inline int pathHashKey(QSettings::Format format, QSettings::Scope scope) return int((uint(format) << 1) | uint(scope == QSettings::SystemScope)); } +#ifndef Q_OS_WIN +static QString make_user_path() +{ + static Q_CONSTEXPR QChar sep = QLatin1Char('/'); +#ifndef QSETTINGS_USE_QSTANDARDPATHS + // Non XDG platforms (OS X, iOS, Android...) have used this code path erroneously + // for some time now. Moving away from that would require migrating existing settings. + QByteArray env = qgetenv("XDG_CONFIG_HOME"); + if (env.isEmpty()) { + return QDir::homePath() + QLatin1String("/.config/"); + } else if (env.startsWith('/')) { + return QFile::decodeName(env) + sep; + } else { + return QDir::homePath() + sep + QFile::decodeName(env) + sep; + } +#else + // When using a proper XDG platform, use QStandardPaths rather than the above hand-written code; + // it makes the use of test mode from unit tests possible. + // Ideally all platforms should use this, but see above for the migration issue. + return QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + sep; +#endif +} +#endif // !Q_OS_WIN + static void initDefaultPaths(QMutexLocker *locker) { PathHash *pathHash = pathHashFunc(); - QString systemPath; locker->unlock(); @@ -1050,8 +1053,7 @@ static void initDefaultPaths(QMutexLocker *locker) avoid a dead-lock, we can't hold the global mutex while calling it. */ - systemPath = QLibraryInfo::location(QLibraryInfo::SettingsPath); - systemPath += QLatin1Char('/'); + QString systemPath = QLibraryInfo::location(QLibraryInfo::SettingsPath) + QLatin1Char('/'); locker->relock(); if (pathHash->isEmpty()) { @@ -1067,38 +1069,14 @@ static void initDefaultPaths(QMutexLocker *locker) pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::SystemScope), windowsConfigPath(CSIDL_COMMON_APPDATA) + QDir::separator()); #else - -#ifndef QSETTINGS_USE_QSTANDARDPATHS - // Non XDG platforms (OS X, iOS, Android...) have used this code path erroneously - // for some time now. Moving away from that would require migrating existing settings. - QString userPath; - QByteArray env = qgetenv("XDG_CONFIG_HOME"); - if (env.isEmpty()) { - userPath = QDir::homePath(); - userPath += QLatin1Char('/'); - userPath += QLatin1String(".config"); - } else if (env.startsWith('/')) { - userPath = QFile::decodeName(env); - } else { - userPath = QDir::homePath(); - userPath += QLatin1Char('/'); - userPath += QFile::decodeName(env); - } -#else - // When using a proper XDG platform, use QStandardPaths rather than the above hand-written code; - // it makes the use of test mode from unit tests possible. - // Ideally all platforms should use this, but see above for the migration issue. - QString userPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation); -#endif - userPath += QLatin1Char('/'); - + const QString userPath = make_user_path(); pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::UserScope), userPath); pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::SystemScope), systemPath); #ifndef Q_OS_MAC pathHash->insert(pathHashKey(QSettings::NativeFormat, QSettings::UserScope), userPath); pathHash->insert(pathHashKey(QSettings::NativeFormat, QSettings::SystemScope), systemPath); #endif -#endif +#endif // Q_OS_WIN } } @@ -3486,8 +3464,7 @@ QSettings::Format QSettings::registerFormat(const QString &extension, ReadFunc r return QSettings::InvalidFormat; QConfFileCustomFormat info; - info.extension = QLatin1Char('.'); - info.extension += extension; + info.extension = QLatin1Char('.') + extension; info.readFunc = readFunc; info.writeFunc = writeFunc; info.caseSensitivity = caseSensitivity; diff --git a/src/corelib/io/qsettings_winrt.cpp b/src/corelib/io/qsettings_winrt.cpp index 0a87e7ce66..708287ce5e 100644 --- a/src/corelib/io/qsettings_winrt.cpp +++ b/src/corelib/io/qsettings_winrt.cpp @@ -92,7 +92,7 @@ static IApplicationDataContainer *subContainer(IApplicationDataContainer *parent if (FAILED(hr)) return 0; - while (SUCCEEDED(S_OK) && current) { + while (SUCCEEDED(hr) && current) { ComPtr<ContainerItem> item; hr = iterator->get_Current(&item); if (FAILED(hr)) diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index 0daf041954..ae5c42ffd1 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2014 Ivan Komissarov <ABBAPOH@gmail.com> +** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -153,29 +154,41 @@ static bool isParentOf(const String &parent, const QString &dirName) parent.size() == 1); } -static bool isPseudoFs(const QStorageIterator &it) -{ +static bool shouldIncludeFs(const QStorageIterator &it) +{ + /* + * This function implements a heuristic algorithm to determine whether a + * given mount should be reported to the user. Our objective is to list + * only entries that the end-user would find useful. + * + * We therefore ignore: + * - mounted in /dev, /proc, /sys: special mounts + * (this will catch /sys/fs/cgroup, /proc/sys/fs/binfmt_misc, /dev/pts, + * some of which are tmpfs on Linux) + * - mounted in /var/run or /var/lock: most likely pseudofs + * (on earlier systemd versions, /var/run was a bind-mount of /run, so + * everything would be unnecessarily duplicated) + * - filesystem type is "rootfs": artifact of the root-pivot on some Linux + * initrd + * - if the filesystem total size is zero, it's a pseudo-fs (not checked here). + */ + QString mountDir = it.rootPath(); if (isParentOf(QLatin1String("/dev"), mountDir) || isParentOf(QLatin1String("/proc"), mountDir) || isParentOf(QLatin1String("/sys"), mountDir) || isParentOf(QLatin1String("/var/run"), mountDir) || isParentOf(QLatin1String("/var/lock"), mountDir)) { - return true; + return false; } - QByteArray type = it.fileSystemType(); - if (type == "tmpfs") +#ifdef Q_OS_LINUX + if (it.fileSystemType() == "rootfs") return false; -#if defined(Q_OS_LINUX) - if (type == "rootfs" || type == "rpc_pipefs") - return true; #endif - if (!it.device().startsWith('/')) - return true; - - return false; + // size checking in mountedVolumes() + return true; } #if defined(Q_OS_BSD4) @@ -557,11 +570,14 @@ QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes() QList<QStorageInfo> volumes; while (it.next()) { - if (isPseudoFs(it)) + if (!shouldIncludeFs(it)) continue; const QString mountDir = it.rootPath(); - volumes.append(QStorageInfo(mountDir)); + QStorageInfo info(mountDir); + if (info.bytesTotal() == 0) + continue; + volumes.append(info); } return volumes; diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index e20a98fbf1..71a0228eeb 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -816,7 +816,7 @@ static const ushort * const fragmentInUrl = userNameInUrl + 6; static inline void parseDecodedComponent(QString &data) { - data.replace(QLatin1Char('%'), QStringLiteral("%25")); + data.replace(QLatin1Char('%'), QLatin1String("%25")); } static inline QString @@ -981,10 +981,12 @@ inline bool QUrlPrivate::setScheme(const QString &value, int len, bool doSetErro needsLowercasing = i; continue; } - if (p[i] >= '0' && p[i] <= '9' && i > 0) - continue; - if (p[i] == '+' || p[i] == '-' || p[i] == '.') - continue; + if (i) { + if (p[i] >= '0' && p[i] <= '9') + continue; + if (p[i] == '+' || p[i] == '-' || p[i] == '.') + continue; + } // found something else // don't call setError needlessly: @@ -1472,7 +1474,7 @@ QString QUrlPrivate::toLocalFile(QUrl::FormattingOptions options) const // magic for shared drive on windows if (!host.isEmpty()) { - tmp = QStringLiteral("//") + host; + tmp = QLatin1String("//") + host; #ifdef Q_OS_WIN // QTBUG-42346, WebDAV is visible as local file on Windows only. if (scheme == webDavScheme()) tmp += webDavSslTag(); diff --git a/src/corelib/io/qurlidna.cpp b/src/corelib/io/qurlidna.cpp index 11b2280cd1..16bb924b17 100644 --- a/src/corelib/io/qurlidna.cpp +++ b/src/corelib/io/qurlidna.cpp @@ -2269,7 +2269,7 @@ Q_AUTOTEST_EXPORT void qt_punycodeEncoder(const QChar *s, int ucLength, QString } // prepend ACE prefix - output->insert(outLen, QStringLiteral("xn--")); + output->insert(outLen, QLatin1String("xn--")); return; } diff --git a/src/corelib/json/qjsondocument.cpp b/src/corelib/json/qjsondocument.cpp index ee9aa49016..86fd63ead4 100644 --- a/src/corelib/json/qjsondocument.cpp +++ b/src/corelib/json/qjsondocument.cpp @@ -359,16 +359,14 @@ QByteArray QJsonDocument::toJson(JsonFormat format) const #endif /*! - Parses a UTF-8 encoded JSON document and creates a QJsonDocument + Parses \a json as a UTF-8 encoded JSON document, and creates a QJsonDocument from it. - \a json contains the json document to be parsed. + Returns a valid (non-null) QJsonDocument if the parsing succeeds. If it fails, + the returned document will be null, and the optional \a error variable will contain + further details about the error. - The optional \a error variable can be used to pass in a QJsonParseError data - structure that will contain information about possible errors encountered during - parsing. - - \sa toJson(), QJsonParseError + \sa toJson(), QJsonParseError, isNull() */ QJsonDocument QJsonDocument::fromJson(const QByteArray &json, QJsonParseError *error) { diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h index 7ea7e90d94..c393609188 100644 --- a/src/corelib/kernel/qcore_unix_p.h +++ b/src/corelib/kernel/qcore_unix_p.h @@ -80,6 +80,10 @@ #include <errno.h> #include <fcntl.h> +#if !defined(QT_POSIX_IPC) && !defined(QT_NO_SHAREDMEMORY) && !defined(Q_OS_ANDROID) +# include <sys/ipc.h> +#endif + #if defined(Q_OS_VXWORKS) # include <ioLib.h> #endif diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp index e960d355e1..e4b819d9d2 100644 --- a/src/corelib/kernel/qeventloop.cpp +++ b/src/corelib/kernel/qeventloop.cpp @@ -188,8 +188,10 @@ int QEventLoop::exec(ProcessEventsFlags flags) { if (exceptionCaught) { qWarning("Qt has caught an exception thrown from an event handler. Throwing\n" - "exceptions from an event handler is not supported in Qt. You must\n" - "reimplement QApplication::notify() and catch all exceptions there.\n"); + "exceptions from an event handler is not supported in Qt.\n" + "You must not let any exception whatsoever propagate through Qt code.\n" + "If that is not possible, in Qt 5 you must at least reimplement\n" + "QCoreApplication::notify() and catch all exceptions there.\n"); } locker.relock(); QEventLoop *eventLoop = d->threadData->eventLoops.pop(); diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index f5b879aea8..633fcfda91 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -1353,7 +1353,7 @@ static inline QByteArray findMethodCandidates(const QMetaObject *metaObject, con for (int i = 0; i < metaObject->methodCount(); ++i) { const QMetaMethod method = metaObject->method(i); if (method.name() == memberByteArray) - candidateMessage.append(" " + method.methodSignature() + '\n'); + candidateMessage += " " + method.methodSignature() + '\n'; } if (!candidateMessage.isEmpty()) { candidateMessage.prepend("\nCandidates are:\n"); diff --git a/src/corelib/thread/qreadwritelock.cpp b/src/corelib/thread/qreadwritelock.cpp index 5665bf74f6..6302a3a515 100644 --- a/src/corelib/thread/qreadwritelock.cpp +++ b/src/corelib/thread/qreadwritelock.cpp @@ -244,6 +244,9 @@ bool QReadWriteLock::tryLockForRead(int timeout) } if (d == dummyLockedForWrite) { + if (!timeout) + return false; + // locked for write, assign a d_ptr and wait. auto val = QReadWriteLockPrivate::allocate(); val->writerCount = 1; @@ -345,6 +348,9 @@ bool QReadWriteLock::tryLockForWrite(int timeout) } if (isUncontendedLocked(d)) { + if (!timeout) + return false; + // locked for either read or write, assign a d_ptr and wait. auto val = QReadWriteLockPrivate::allocate(); if (d == dummyLockedForWrite) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index d6b90efb33..ee5ee5c362 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -3513,7 +3513,7 @@ qint64 QDateTime::toMSecsSinceEpoch() const case Qt::TimeZone: #ifdef QT_BOOTSTRAPPED - break; + return 0; #else return QDateTimePrivate::zoneMSecsToEpochMSecs(d->m_msecs, d->m_timeZone); #endif @@ -3771,7 +3771,7 @@ QString QDateTime::toString(Qt::DateFormat format) const .arg(tm.toString(Qt::TextDate)) .arg(dt.year()); if (timeSpec() != Qt::LocalTime) { - buf += QStringLiteral(" GMT"); + buf += QLatin1String(" GMT"); if (getSpec(d) == Qt::OffsetFromUTC) buf += toOffsetString(Qt::TextDate, offsetFromUtc()); } @@ -5019,7 +5019,12 @@ QDataStream &operator>>(QDataStream &in, QDate &date) QDataStream &operator<<(QDataStream &out, const QTime &time) { - return out << quint32(time.mds); + if (out.version() >= QDataStream::Qt_4_0) { + return out << quint32(time.mds); + } else { + // Qt3 had no support for reading -1, QTime() was valid and serialized as 0 + return out << quint32(time.isNull() ? 0 : time.mds); + } } /*! @@ -5034,7 +5039,12 @@ QDataStream &operator>>(QDataStream &in, QTime &time) { quint32 ds; in >> ds; - time.mds = int(ds); + if (in.version() >= QDataStream::Qt_4_0) { + time.mds = int(ds); + } else { + // Qt3 would write 0 for a null time + time.mds = (ds == 0) ? QTime::NullTime : int(ds); + } return in; } diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 32f12bd092..a8e924b62d 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -1786,17 +1786,12 @@ void QString::reallocData(uint alloc, bool grow) } } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) void QString::expand(int i) { - int sz = d->size; - resize(qMax(i + 1, sz)); - if (d->size - 1 > sz) { - ushort *n = d->data() + d->size - 1; - ushort *e = d->data() + sz; - while (n != e) - * --n = ' '; - } + resize(qMax(i + 1, d->size), QLatin1Char(' ')); } +#endif /*! \fn void QString::clear() @@ -1982,7 +1977,10 @@ QString &QString::insert(int i, QLatin1String str) return *this; int len = str.size(); - expand(qMax(d->size, i) + len - 1); + if (Q_UNLIKELY(i > d->size)) + resize(i + len, QLatin1Char(' ')); + else + resize(d->size + len); ::memmove(d->data() + i + len, d->data() + i, (d->size - i - len) * sizeof(QChar)); qt_from_latin1(d->data() + i, s, uint(len)); @@ -2012,7 +2010,10 @@ QString& QString::insert(int i, const QChar *unicode, int size) return *this; } - expand(qMax(d->size, i) + size - 1); + if (Q_UNLIKELY(i > d->size)) + resize(i + size, QLatin1Char(' ')); + else + resize(d->size + size); ::memmove(d->data() + i + size, d->data() + i, (d->size - i - size) * sizeof(QChar)); memcpy(d->data() + i, s, size * sizeof(QChar)); @@ -2032,7 +2033,10 @@ QString& QString::insert(int i, QChar ch) i += d->size; if (i < 0) return *this; - expand(qMax(i, d->size)); + if (Q_UNLIKELY(i > d->size)) + resize(i + 1, QLatin1Char(' ')); + else + resize(d->size + 1); ::memmove(d->data() + i + 1, d->data() + i, (d->size - i - 1) * sizeof(QChar)); d->data()[i] = ch.unicode(); return *this; @@ -2404,26 +2408,40 @@ QString &QString::replace(const QString &before, const QString &after, Qt::CaseS return replace(before.constData(), before.size(), after.constData(), after.size(), cs); } +namespace { // helpers for replace and its helper: +QChar *textCopy(const QChar *start, int len) +{ + const size_t size = len * sizeof(QChar); + QChar *const copy = static_cast<QChar *>(::malloc(size)); + Q_CHECK_PTR(copy); + ::memcpy(copy, start, size); + return copy; +} + +bool pointsIntoRange(const QChar *ptr, const ushort *base, int len) +{ + const QChar *const start = reinterpret_cast<const QChar *>(base); + return start <= ptr && ptr < start + len; +} +} // end namespace + /*! \internal */ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar *after, int alen) { - // copy *after in case it lies inside our own d->data() area - // (which we could possibly invalidate via a realloc or corrupt via memcpy operations.) - QChar *afterBuffer = const_cast<QChar *>(after); - if (after >= reinterpret_cast<QChar *>(d->data()) && after < reinterpret_cast<QChar *>(d->data()) + d->size) { - afterBuffer = static_cast<QChar *>(::malloc(alen*sizeof(QChar))); - Q_CHECK_PTR(afterBuffer); - ::memcpy(afterBuffer, after, alen*sizeof(QChar)); - } + // Copy after if it lies inside our own d->data() area (which we could + // possibly invalidate via a realloc or modify by replacement). + QChar *afterBuffer = 0; + if (pointsIntoRange(after, d->data(), d->size)) // Use copy in place of vulnerable original: + after = afterBuffer = textCopy(after, alen); QT_TRY { if (blen == alen) { // replace in place detach(); for (int i = 0; i < nIndices; ++i) - memcpy(d->data() + indices[i], afterBuffer, alen * sizeof(QChar)); + memcpy(d->data() + indices[i], after, alen * sizeof(QChar)); } else if (alen < blen) { // replace from front detach(); @@ -2439,7 +2457,7 @@ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar to += msize; } if (alen) { - memcpy(d->data() + to, afterBuffer, alen*sizeof(QChar)); + memcpy(d->data() + to, after, alen * sizeof(QChar)); to += alen; } movestart = indices[i] + blen; @@ -2462,17 +2480,15 @@ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar int moveto = insertstart + alen; memmove(d->data() + moveto, d->data() + movestart, (moveend - movestart)*sizeof(QChar)); - memcpy(d->data() + insertstart, afterBuffer, alen*sizeof(QChar)); + memcpy(d->data() + insertstart, after, alen * sizeof(QChar)); moveend = movestart-blen; } } } QT_CATCH(const std::bad_alloc &) { - if (afterBuffer != after) - ::free(afterBuffer); + ::free(afterBuffer); QT_RETHROW; } - if (afterBuffer != after) - ::free(afterBuffer); + ::free(afterBuffer); } /*! @@ -2501,31 +2517,48 @@ QString &QString::replace(const QChar *before, int blen, return *this; QStringMatcher matcher(before, blen, cs); + QChar *beforeBuffer = 0, *afterBuffer = 0; int index = 0; while (1) { uint indices[1024]; uint pos = 0; - while (pos < 1023) { + while (pos < 1024) { index = matcher.indexIn(*this, index); if (index == -1) break; indices[pos++] = index; - index += blen; - // avoid infinite loop - if (!blen) + if (blen) // Step over before: + index += blen; + else // Only count one instance of empty between any two characters: index++; } - if (!pos) + if (!pos) // Nothing to replace break; + if (Q_UNLIKELY(index != -1)) { + /* + We're about to change data, that before and after might point + into, and we'll need that data for our next batch of indices. + */ + if (!afterBuffer && pointsIntoRange(after, d->data(), d->size)) + after = afterBuffer = textCopy(after, alen); + + if (!beforeBuffer && pointsIntoRange(before, d->data(), d->size)) { + beforeBuffer = textCopy(before, blen); + matcher = QStringMatcher(beforeBuffer, blen, cs); + } + } + replace_helper(indices, pos, blen, after, alen); - if (index == -1) + if (Q_LIKELY(index == -1)) // Nothing left to replace break; - // index has to be adjusted in case we get back into the loop above. + // The call to replace_helper just moved what index points at: index += pos*(alen-blen); } + ::free(afterBuffer); + ::free(beforeBuffer); return *this; } @@ -2556,26 +2589,26 @@ QString& QString::replace(QChar ch, const QString &after, Qt::CaseSensitivity cs uint indices[1024]; uint pos = 0; if (cs == Qt::CaseSensitive) { - while (pos < 1023 && index < d->size) { + while (pos < 1024 && index < d->size) { if (d->data()[index] == cc) indices[pos++] = index; index++; } } else { - while (pos < 1023 && index < d->size) { + while (pos < 1024 && index < d->size) { if (QChar::toCaseFolded(d->data()[index]) == cc) indices[pos++] = index; index++; } } - if (!pos) + if (!pos) // Nothing to replace break; replace_helper(indices, pos, 1, after.constData(), after.d->size); - if (index == -1) + if (Q_LIKELY(index == -1)) // Nothing left to replace break; - // index has to be adjusted in case we get back into the loop above. + // The call to replace_helper just moved what index points at: index += pos*(after.d->size - 1); } return *this; @@ -5001,7 +5034,7 @@ void QString::truncate(int pos) Removes \a n characters from the end of the string. If \a n is greater than or equal to size(), the result is an - empty string. + empty string; if \a n is negative, it is equivalent to passing zero. Example: \snippet qstring/main.cpp 15 diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index ec959b50a0..a110c129de 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -821,7 +821,9 @@ private: friend inline bool operator> (QChar, QLatin1String) Q_DECL_NOTHROW; void reallocData(uint alloc, bool grow = false); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) void expand(int i); +#endif QString multiArg(int numArgs, const QString **args) const; static int compare_helper(const QChar *data1, int length1, const QChar *data2, int length2, @@ -1008,7 +1010,7 @@ public: inline operator QChar() const { return i < s.d->size ? s.d->data()[i] : 0; } inline QCharRef &operator=(QChar c) - { if (i >= s.d->size) s.expand(i); else s.detach(); + { if (i >= s.d->size) s.resize(i + 1, QLatin1Char(' ')); else s.detach(); s.d->data()[i] = c.unicode(); return *this; } // An operator= for each QChar cast constructors diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index 8ce98cbd71..b2832b5fbe 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -82,7 +82,7 @@ struct QStringBuilderCommon T toLower() const { return resolved().toLower(); } protected: - const T resolved() const { return *static_cast<const Builder*>(this); } + T resolved() const { return *static_cast<const Builder*>(this); } }; template<typename Builder, typename T> diff --git a/src/corelib/tools/qtimezoneprivate_icu.cpp b/src/corelib/tools/qtimezoneprivate_icu.cpp index a7036808db..c088fe7694 100644 --- a/src/corelib/tools/qtimezoneprivate_icu.cpp +++ b/src/corelib/tools/qtimezoneprivate_icu.cpp @@ -332,7 +332,7 @@ QString QIcuTimeZonePrivate::displayName(QTimeZone::TimeType timeType, { // Return standard offset format name as ICU C api doesn't support it yet if (nameType == QTimeZone::OffsetName) { - const Data nowData = data(QDateTime::currentDateTimeUtc().toMSecsSinceEpoch()); + const Data nowData = data(QDateTime::currentMSecsSinceEpoch()); // We can't use transitions reliably to find out right dst offset // Instead use dst offset api to try get it if needed if (timeType == QTimeZone::DaylightTime) diff --git a/src/corelib/tools/qtimezoneprivate_mac.mm b/src/corelib/tools/qtimezoneprivate_mac.mm index 3a665c2b00..77c04ac20c 100644 --- a/src/corelib/tools/qtimezoneprivate_mac.mm +++ b/src/corelib/tools/qtimezoneprivate_mac.mm @@ -59,6 +59,7 @@ QT_BEGIN_NAMESPACE // Create the system default time zone QMacTimeZonePrivate::QMacTimeZonePrivate() + : m_nstz(0) { init(systemTimeZoneId()); } @@ -106,7 +107,7 @@ QString QMacTimeZonePrivate::displayName(QTimeZone::TimeType timeType, { // TODO Mac doesn't support OffsetName yet so use standard offset name if (nameType == QTimeZone::OffsetName) { - const Data nowData = data(QDateTime::currentDateTimeUtc().toMSecsSinceEpoch()); + const Data nowData = data(QDateTime::currentMSecsSinceEpoch()); // TODO Cheat for now, assume if has dst the offset if 1 hour if (timeType == QTimeZone::DaylightTime && hasDaylightTime()) return isoOffsetFormat(nowData.standardTimeOffset + 3600); diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 757543281c..e95315aea8 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -758,7 +758,7 @@ void QAccessible::deleteAccessibleInterface(Id id) */ QAccessible::Id QAccessible::uniqueId(QAccessibleInterface *iface) { - Id id = QAccessibleCache::instance()->idToInterface.key(iface); + Id id = QAccessibleCache::instance()->idForInterface(iface); if (!id) id = registerAccessibleInterface(iface); return id; @@ -771,7 +771,7 @@ QAccessible::Id QAccessible::uniqueId(QAccessibleInterface *iface) */ QAccessibleInterface *QAccessible::accessibleInterface(Id id) { - return QAccessibleCache::instance()->idToInterface.value(id); + return QAccessibleCache::instance()->interfaceForId(id); } diff --git a/src/gui/accessible/qaccessiblecache.cpp b/src/gui/accessible/qaccessiblecache.cpp index 6fbe9b5582..43c4b15cb0 100644 --- a/src/gui/accessible/qaccessiblecache.cpp +++ b/src/gui/accessible/qaccessiblecache.cpp @@ -83,6 +83,11 @@ QAccessibleInterface *QAccessibleCache::interfaceForId(QAccessible::Id id) const return idToInterface.value(id); } +QAccessible::Id QAccessibleCache::idForInterface(QAccessibleInterface *iface) const +{ + return interfaceToId.value(iface); +} + QAccessible::Id QAccessibleCache::insert(QObject *object, QAccessibleInterface *iface) const { Q_ASSERT(iface); @@ -90,7 +95,7 @@ QAccessible::Id QAccessibleCache::insert(QObject *object, QAccessibleInterface * // object might be 0 Q_ASSERT(!objectToId.contains(object)); - Q_ASSERT_X(!idToInterface.values().contains(iface), "", "Accessible interface inserted into cache twice!"); + Q_ASSERT_X(!interfaceToId.contains(iface), "", "Accessible interface inserted into cache twice!"); QAccessible::Id id = acquireId(); QObject *obj = iface->object(); @@ -100,6 +105,7 @@ QAccessible::Id QAccessibleCache::insert(QObject *object, QAccessibleInterface * connect(obj, &QObject::destroyed, this, &QAccessibleCache::objectDestroyed); } idToInterface.insert(id, iface); + interfaceToId.insert(iface, id); return id; } @@ -115,6 +121,7 @@ void QAccessibleCache::objectDestroyed(QObject* obj) void QAccessibleCache::deleteInterface(QAccessible::Id id, QObject *obj) { QAccessibleInterface *iface = idToInterface.take(id); + interfaceToId.take(iface); if (!obj) obj = iface->object(); if (obj) diff --git a/src/gui/accessible/qaccessiblecache_p.h b/src/gui/accessible/qaccessiblecache_p.h index 5f62f43b6a..f054ee9678 100644 --- a/src/gui/accessible/qaccessiblecache_p.h +++ b/src/gui/accessible/qaccessiblecache_p.h @@ -70,6 +70,7 @@ class Q_GUI_EXPORT QAccessibleCache :public QObject public: static QAccessibleCache *instance(); QAccessibleInterface *interfaceForId(QAccessible::Id id) const; + QAccessible::Id idForInterface(QAccessibleInterface *iface) const; QAccessible::Id insert(QObject *object, QAccessibleInterface *iface) const; void deleteInterface(QAccessible::Id id, QObject *obj = 0); @@ -85,6 +86,7 @@ private: QAccessible::Id acquireId() const; mutable QHash<QAccessible::Id, QAccessibleInterface *> idToInterface; + mutable QHash<QAccessibleInterface *, QAccessible::Id> interfaceToId; mutable QHash<QObject *, QAccessible::Id> objectToId; #ifdef Q_OS_MAC diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 0dec4b512d..c65ac7f92d 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -1227,8 +1227,8 @@ bool QIcon::hasThemeIcon(const QString &name) /*! \since 5.6 - Indicate that this icon is a mask image, and hence can potentially - be modified based on where it's displayed. + Indicate that this icon is a mask image(boolean \a isMask), and hence can + potentially be modified based on where it's displayed. \sa isMask() */ void QIcon::setIsMask(bool isMask) diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index 3279880601..e965045524 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -1796,11 +1796,12 @@ QStandardItem *QStandardItem::takeChild(int row, int column) QList<QStandardItem*> QStandardItem::takeRow(int row) { Q_D(QStandardItem); + QList<QStandardItem*> items; if ((row < 0) || (row >= rowCount())) - return QList<QStandardItem*>(); + return items; if (d->model) d->model->d_func()->rowsAboutToBeRemoved(this, row, row); - QList<QStandardItem*> items; + int index = d->childIndex(row, 0); // Will return -1 if there are no columns if (index != -1) { int col_count = d->columnCount(); @@ -1829,13 +1830,15 @@ QList<QStandardItem*> QStandardItem::takeRow(int row) QList<QStandardItem*> QStandardItem::takeColumn(int column) { Q_D(QStandardItem); + QList<QStandardItem*> items; if ((column < 0) || (column >= columnCount())) - return QList<QStandardItem*>(); + return items; if (d->model) d->model->d_func()->columnsAboutToBeRemoved(this, column, column); - QList<QStandardItem*> items; - for (int row = d->rowCount() - 1; row >= 0; --row) { + const int rowCount = d->rowCount(); + items.reserve(rowCount); + for (int row = rowCount - 1; row >= 0; --row) { int index = d->childIndex(row, column); QStandardItem *ch = d->children.at(index); if (ch) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 7afeadcced..416c899270 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -3355,28 +3355,6 @@ bool QGuiApplication::isSavingSession() const return d->is_saving_session; } -/*! - \since 5.2 - - Function that can be used to sync Qt state with the Window Systems state. - - This function will first empty Qts events by calling QCoreApplication::processEvents(), - then the platform plugin will sync up with the windowsystem, and finally Qts events - will be delived by another call to QCoreApplication::processEvents(); - - This function is timeconsuming and its use is discouraged. -*/ -void QGuiApplication::sync() -{ - QCoreApplication::processEvents(); - if (QGuiApplicationPrivate::platform_integration - && QGuiApplicationPrivate::platform_integration->hasCapability(QPlatformIntegration::SyncState)) { - QGuiApplicationPrivate::platform_integration->sync(); - QCoreApplication::processEvents(); - QWindowSystemInterface::flushWindowSystemEvents(); - } -} - void QGuiApplicationPrivate::commitData() { Q_Q(QGuiApplication); @@ -3402,6 +3380,28 @@ void QGuiApplicationPrivate::saveState() #endif //QT_NO_SESSIONMANAGER /*! + \since 5.2 + + Function that can be used to sync Qt state with the Window Systems state. + + This function will first empty Qts events by calling QCoreApplication::processEvents(), + then the platform plugin will sync up with the windowsystem, and finally Qts events + will be delived by another call to QCoreApplication::processEvents(); + + This function is timeconsuming and its use is discouraged. +*/ +void QGuiApplication::sync() +{ + QCoreApplication::processEvents(); + if (QGuiApplicationPrivate::platform_integration + && QGuiApplicationPrivate::platform_integration->hasCapability(QPlatformIntegration::SyncState)) { + QGuiApplicationPrivate::platform_integration->sync(); + QCoreApplication::processEvents(); + QWindowSystemInterface::flushWindowSystemEvents(); + } +} + +/*! \property QGuiApplication::layoutDirection \brief the default layout direction for this application @@ -3647,7 +3647,8 @@ QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape) void QGuiApplicationPrivate::notifyThemeChanged() { - if (!(applicationResourceFlags & ApplicationPaletteExplicitlySet)) { + if (!(applicationResourceFlags & ApplicationPaletteExplicitlySet) && + !QCoreApplication::testAttribute(Qt::AA_SetPalette)) { clearPalette(); initPalette(); } diff --git a/src/gui/kernel/qplatformintegrationfactory.cpp b/src/gui/kernel/qplatformintegrationfactory.cpp index 566d025b28..1e04a673eb 100644 --- a/src/gui/kernel/qplatformintegrationfactory.cpp +++ b/src/gui/kernel/qplatformintegrationfactory.cpp @@ -86,7 +86,7 @@ QStringList QPlatformIntegrationFactory::keys(const QString &platformPluginPath) QCoreApplication::addLibraryPath(platformPluginPath); list = directLoader()->keyMap().values(); if (!list.isEmpty()) { - const QString postFix = QStringLiteral(" (from ") + const QString postFix = QLatin1String(" (from ") + QDir::toNativeSeparators(platformPluginPath) + QLatin1Char(')'); const QStringList::iterator end = list.end(); diff --git a/src/gui/kernel/qplatformthemefactory.cpp b/src/gui/kernel/qplatformthemefactory.cpp index 40ba844e57..223d7344e3 100644 --- a/src/gui/kernel/qplatformthemefactory.cpp +++ b/src/gui/kernel/qplatformthemefactory.cpp @@ -88,7 +88,7 @@ QStringList QPlatformThemeFactory::keys(const QString &platformPluginPath) QCoreApplication::addLibraryPath(platformPluginPath); list += directLoader()->keyMap().values(); if (!list.isEmpty()) { - const QString postFix = QStringLiteral(" (from ") + const QString postFix = QLatin1String(" (from ") + QDir::toNativeSeparators(platformPluginPath) + QLatin1Char(')'); const QStringList::iterator end = list.end(); diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index bcc17457d3..3e82d5a649 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -1284,6 +1284,7 @@ static inline QImage qt_gl_read_framebuffer_rgba8(const QSize &size, bool includ const char *ver = reinterpret_cast<const char *>(funcs->glGetString(GL_VERSION)); // Blacklist GPU chipsets that have problems with their BGRA support. +#ifndef Q_OS_IOS const bool blackListed = (qstrcmp(renderer, "PowerVR Rogue G6200") == 0 && ::strstr(ver, "1.3") != 0) || (qstrcmp(renderer, "Mali-T760") == 0 @@ -1291,7 +1292,9 @@ static inline QImage qt_gl_read_framebuffer_rgba8(const QSize &size, bool includ (qstrcmp(renderer, "Mali-T720") == 0 && ::strstr(ver, "3.1") != 0) || qstrcmp(renderer, "PowerVR SGX 554") == 0; - +#else + const bool blackListed = true; +#endif const bool supports_bgra = has_bgra_ext && !blackListed; if (supports_bgra) { diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index e89522f5af..26ed81a091 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -259,7 +259,6 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id, newFreetype->ref.store(1); newFreetype->xsize = 0; newFreetype->ysize = 0; - newFreetype->scalableBitmapScaleFactor = 1; newFreetype->matrix.xx = 0x10000; newFreetype->matrix.yy = 0x10000; newFreetype->matrix.xy = 0; @@ -335,10 +334,11 @@ void QFreetypeFace::release(const QFontEngine::FaceId &face_id) } -void QFreetypeFace::computeSize(const QFontDef &fontDef, int *xsize, int *ysize, bool *outline_drawing) +void QFreetypeFace::computeSize(const QFontDef &fontDef, int *xsize, int *ysize, bool *outline_drawing, QFixed *scalableBitmapScaleFactor) { *ysize = qRound(fontDef.pixelSize * 64); *xsize = *ysize * fontDef.stretch / 100; + *scalableBitmapScaleFactor = 1; *outline_drawing = false; if (!(face->face_flags & FT_FACE_FLAG_SCALABLE)) { @@ -376,7 +376,7 @@ void QFreetypeFace::computeSize(const QFontDef &fontDef, int *xsize, int *ysize, // to make sure we can select the desired bitmap strike index if (FT_Select_Size(face, best) == 0) { if (isScalableBitmap()) - scalableBitmapScaleFactor = QFixed::fromReal((qreal)fontDef.pixelSize / face->available_sizes[best].height); + *scalableBitmapScaleFactor = QFixed::fromReal((qreal)fontDef.pixelSize / face->available_sizes[best].height); *xsize = face->available_sizes[best].x_ppem; *ysize = face->available_sizes[best].y_ppem; } else { @@ -729,7 +729,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format, symbol = bool(fontDef.family.contains(QLatin1String("symbol"), Qt::CaseInsensitive)); } - freetype->computeSize(fontDef, &xsize, &ysize, &defaultGlyphSet.outline_drawing); + freetype->computeSize(fontDef, &xsize, &ysize, &defaultGlyphSet.outline_drawing, &scalableBitmapScaleFactor); FT_Face face = lockFace(); @@ -1294,24 +1294,24 @@ int QFontEngineFT::synthesized() const QFixed QFontEngineFT::ascent() const { QFixed v = QFixed::fromFixed(metrics.ascender); - if (freetype->scalableBitmapScaleFactor != 1) - v *= freetype->scalableBitmapScaleFactor; + if (scalableBitmapScaleFactor != 1) + v *= scalableBitmapScaleFactor; return v; } QFixed QFontEngineFT::descent() const { QFixed v = QFixed::fromFixed(-metrics.descender); - if (freetype->scalableBitmapScaleFactor != 1) - v *= freetype->scalableBitmapScaleFactor; + if (scalableBitmapScaleFactor != 1) + v *= scalableBitmapScaleFactor; return v; } QFixed QFontEngineFT::leading() const { QFixed v = QFixed::fromFixed(metrics.height - metrics.ascender + metrics.descender); - if (freetype->scalableBitmapScaleFactor != 1) - v *= freetype->scalableBitmapScaleFactor; + if (scalableBitmapScaleFactor != 1) + v *= scalableBitmapScaleFactor; return v; } @@ -1326,7 +1326,7 @@ QFixed QFontEngineFT::xHeight() const return answer; } } else { - return QFixed(freetype->face->size->metrics.y_ppem) * freetype->scalableBitmapScaleFactor; + return QFixed(freetype->face->size->metrics.y_ppem) * scalableBitmapScaleFactor; } return QFontEngine::xHeight(); } @@ -1352,8 +1352,8 @@ QFixed QFontEngineFT::averageCharWidth() const qreal QFontEngineFT::maxCharWidth() const { QFixed max_advance = QFixed::fromFixed(metrics.max_advance); - if (freetype->scalableBitmapScaleFactor != 1) - max_advance *= freetype->scalableBitmapScaleFactor; + if (scalableBitmapScaleFactor != 1) + max_advance *= scalableBitmapScaleFactor; return max_advance.toReal(); } @@ -1639,7 +1639,7 @@ bool QFontEngineFT::shouldUseDesignMetrics(QFontEngine::ShaperFlags flags) const QFixed QFontEngineFT::scaledBitmapMetrics(QFixed m) const { - return m * freetype->scalableBitmapScaleFactor; + return m * scalableBitmapScaleFactor; } glyph_metrics_t QFontEngineFT::scaledBitmapMetrics(const glyph_metrics_t &m) const @@ -1677,8 +1677,8 @@ void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlag delete g; } - if (freetype->scalableBitmapScaleFactor != 1) - glyphs->advances[i] *= freetype->scalableBitmapScaleFactor; + if (scalableBitmapScaleFactor != 1) + glyphs->advances[i] *= scalableBitmapScaleFactor; } if (face) unlockFace(); @@ -1981,9 +1981,9 @@ QImage QFontEngineFT::bitmapForGlyph(glyph_t g, QFixed subPixelPosition, const Q else if (defaultFormat == GlyphFormat::Format_Mono) img = QImage(glyph->data, glyph->width, glyph->height, QImage::Format_Mono).copy(); - if (!img.isNull() && (!t.isIdentity() || freetype->scalableBitmapScaleFactor != 1)) { + if (!img.isNull() && (!t.isIdentity() || scalableBitmapScaleFactor != 1)) { QTransform trans(t); - const qreal scaleFactor = freetype->scalableBitmapScaleFactor.toReal(); + const qreal scaleFactor = scalableBitmapScaleFactor.toReal(); trans.scale(scaleFactor, scaleFactor); img = img.transformed(trans, Qt::SmoothTransformation); } diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h index 3f4bf84753..3cdf0cda47 100644 --- a/src/gui/text/qfontengine_ft_p.h +++ b/src/gui/text/qfontengine_ft_p.h @@ -75,7 +75,7 @@ class QFontconfigDatabase; class QFreetypeFace { public: - void computeSize(const QFontDef &fontDef, int *xsize, int *ysize, bool *outline_drawing); + void computeSize(const QFontDef &fontDef, int *xsize, int *ysize, bool *outline_drawing, QFixed *scalableBitmapScaleFactor); QFontEngine::Properties properties() const; bool getSfntTable(uint tag, uchar *buffer, uint *length) const; @@ -96,7 +96,6 @@ public: FT_Face face; int xsize; // 26.6 int ysize; // 26.6 - QFixed scalableBitmapScaleFactor; FT_Matrix matrix; FT_CharMap unicode_map; FT_CharMap symbol_map; @@ -340,6 +339,7 @@ private: FT_Size_Metrics metrics; mutable bool kerning_pairs_loaded; + QFixed scalableBitmapScaleFactor; }; inline uint qHash(const QFontEngineFT::GlyphAndSubPixelPosition &g) diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp index a1a562c839..5727b34e86 100644 --- a/src/gui/text/qtextdocumentfragment.cpp +++ b/src/gui/text/qtextdocumentfragment.cpp @@ -428,7 +428,7 @@ QTextHtmlImporter::QTextHtmlImporter(QTextDocument *_doc, const QString &_html, QString html = _html; const int startFragmentPos = html.indexOf(QLatin1String("<!--StartFragment-->")); if (startFragmentPos != -1) { - QString qt3RichTextHeader(QLatin1String("<meta name=\"qrichtext\" content=\"1\" />")); + const QLatin1String qt3RichTextHeader("<meta name=\"qrichtext\" content=\"1\" />"); // Hack for Qt3 const bool hasQtRichtextMetaTag = html.contains(qt3RichTextHeader); diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index 103a208c26..7bca50325c 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -1418,16 +1418,16 @@ static bool setFloatAttribute(qreal *destination, const QString &value) return ok; } -static void setWidthAttribute(QTextLength *width, QString value) +static void setWidthAttribute(QTextLength *width, const QString &valueStr) { bool ok = false; - qreal realVal = value.toDouble(&ok); + qreal realVal = valueStr.toDouble(&ok); if (ok) { *width = QTextLength(QTextLength::FixedLength, realVal); } else { - value = value.trimmed(); + QStringRef value = QStringRef(&valueStr).trimmed(); if (!value.isEmpty() && value.endsWith(QLatin1Char('%'))) { - value.chop(1); + value.truncate(value.size() - 1); realVal = value.toDouble(&ok); if (ok) *width = QTextLength(QTextLength::PercentageLength, realVal); @@ -1438,9 +1438,7 @@ static void setWidthAttribute(QTextLength *width, QString value) #ifndef QT_NO_CSSPARSER void QTextHtmlParserNode::parseStyleAttribute(const QString &value, const QTextDocument *resourceProvider) { - QString css = value; - css.prepend(QLatin1String("* {")); - css.append(QLatin1Char('}')); + const QString css = QLatin1String("* {") + value + QLatin1Char('}'); QCss::Parser parser(css); QCss::StyleSheet sheet; parser.parse(&sheet, Qt::CaseInsensitive); diff --git a/src/gui/text/qtextimagehandler.cpp b/src/gui/text/qtextimagehandler.cpp index acd18994ad..18311ed161 100644 --- a/src/gui/text/qtextimagehandler.cpp +++ b/src/gui/text/qtextimagehandler.cpp @@ -111,7 +111,7 @@ static QPixmap getPixmap(QTextDocument *doc, const QTextImageFormat &format, con doc->addResource(QTextDocument::ImageResource, url, pm); } - if (name.contains(QStringLiteral("@2x"))) + if (name.contains(QLatin1String("@2x"))) pm.setDevicePixelRatio(sourcePixelRatio); return pm; diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index 19b519243c..7b6f830333 100644 --- a/src/network/access/qftp.cpp +++ b/src/network/access/qftp.cpp @@ -2034,7 +2034,7 @@ int QFtp::rename(const QString &oldname, const QString &newname) */ int QFtp::rawCommand(const QString &command) { - QString cmd = command.trimmed() + QLatin1String("\r\n"); + const QString cmd = QStringRef(&command).trimmed() + QLatin1String("\r\n"); return d_func()->addCommand(new QFtpCommand(RawCommand, QStringList(cmd))); } @@ -2253,8 +2253,8 @@ void QFtpPrivate::_q_startNextCommand() // Proxy support, replace the Login argument in place, then fall // through. if (c->command == QFtp::Login && !proxyHost.isEmpty()) { - QString loginString = c->rawCmds.constFirst().trimmed(); - loginString += QLatin1Char('@') + host; + QString loginString; + loginString += QStringRef(&c->rawCmds.constFirst()).trimmed() + QLatin1Char('@') + host; if (port && port != 21) loginString += QLatin1Char(':') + QString::number(port); loginString += QLatin1String("\r\n"); diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp index 153a33f782..d242bdba82 100644 --- a/src/network/access/qnetworkaccessftpbackend.cpp +++ b/src/network/access/qnetworkaccessftpbackend.cpp @@ -306,8 +306,6 @@ void QNetworkAccessFtpBackend::ftpDone() state = CheckingFeatures; if (operation() == QNetworkAccessManager::GetOperation) { // send help command to find out if server supports "SIZE" and "MDTM" - QString command = url().path(); - command.prepend(QLatin1String("%1 ")); helpId = ftp->rawCommand(QLatin1String("HELP")); // get supported commands } else { ftpDone(); @@ -316,14 +314,13 @@ void QNetworkAccessFtpBackend::ftpDone() state = Statting; if (operation() == QNetworkAccessManager::GetOperation) { // logged in successfully, send the stat requests (if supported) - QString command = url().path(); - command.prepend(QLatin1String("%1 ")); + const QString path = url().path(); if (supportsSize) { ftp->rawCommand(QLatin1String("TYPE I")); - sizeId = ftp->rawCommand(command.arg(QLatin1String("SIZE"))); // get size + sizeId = ftp->rawCommand(QLatin1String("SIZE ") + path); // get size } if (supportsMdtm) - mdtmId = ftp->rawCommand(command.arg(QLatin1String("MDTM"))); // get modified time + mdtmId = ftp->rawCommand(QLatin1String("MDTM ") + path); // get modified time if (!supportsSize && !supportsMdtm) ftpDone(); // no commands sent, move to the next state } else { diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 469879c78b..107addae58 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -1277,7 +1277,7 @@ static QByteArray qEncodeNtlmv2Response(const QAuthenticatorPrivate *ctx, time = QDateTime::currentSecsSinceEpoch() + 11644473600; // represented as 100 nano seconds - time = Q_UINT64_C(time * 10000000); + time = time * Q_UINT64_C(10000000); ds << time; } diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index 7ef9d7f26b..fcb8a60c8f 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -902,10 +902,7 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxS if (cmsgptr->cmsg_level == IPPROTO_IP && cmsgptr->cmsg_type == IP_RECVIF && cmsgptr->cmsg_len >= CMSG_LEN(sizeof(sockaddr_dl))) { sockaddr_dl *sdl = reinterpret_cast<sockaddr_dl *>(CMSG_DATA(cmsgptr)); -# if defined(Q_OS_OPENBSD) -# define LLINDEX(s) ((s)->sdl_index) -# endif - header->ifindex = LLINDEX(sdl); + header->ifindex = sdl->sdl_index; } # endif #endif diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 580b0fbdde..2371dd7212 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -55,7 +55,8 @@ QSslSocket establishes a secure, encrypted TCP connection you can use for transmitting encrypted data. It can operate in both client and server mode, and it supports modern SSL protocols, including - SSLv3 and TLSv1_0. By default, QSslSocket uses TLSv1_0, but you can + SSL 3 and TLS 1.2. By default, QSslSocket uses only SSL protocols + which are considered to be secure (QSsl::SecureProtocols), but you can change the SSL protocol by calling setProtocol() as long as you do it before the handshake has started. @@ -2394,6 +2395,13 @@ void QSslSocketPrivate::_q_disconnectedSlot() #endif disconnected(); emit q->disconnected(); + + q->setLocalPort(0); + q->setLocalAddress(QHostAddress()); + q->setPeerPort(0); + q->setPeerAddress(QHostAddress()); + q->setPeerName(QString()); + cachedSocketDescriptor = -1; } /*! diff --git a/src/network/ssl/qsslsocket_mac.cpp b/src/network/ssl/qsslsocket_mac.cpp index 194acbeacc..438ea9a38e 100644 --- a/src/network/ssl/qsslsocket_mac.cpp +++ b/src/network/ssl/qsslsocket_mac.cpp @@ -321,7 +321,7 @@ long QSslSocketPrivate::sslLibraryVersionNumber() QString QSslSocketPrivate::sslLibraryVersionString() { - return QStringLiteral("Secure Transport, ") + QSysInfo::prettyProductName(); + return QLatin1String("Secure Transport, ") + QSysInfo::prettyProductName(); } long QSslSocketPrivate::sslLibraryBuildVersionNumber() @@ -436,7 +436,7 @@ void QSslSocketBackendPrivate::startClientEncryption() // Error description/code were set, 'error' emitted // by initSslContext, but OpenSSL socket also sets error // emits a signal twice, so ... - setErrorAndEmit(QAbstractSocket::SslInternalError, "Unable to init SSL Context"); + setErrorAndEmit(QAbstractSocket::SslInternalError, QStringLiteral("Unable to init SSL Context")); return; } @@ -449,7 +449,7 @@ void QSslSocketBackendPrivate::startServerEncryption() // Error description/code were set, 'error' emitted // by initSslContext, but OpenSSL socket also sets error // emits a signal twice, so ... - setErrorAndEmit(QAbstractSocket::SslInternalError, "Unable to init SSL Context"); + setErrorAndEmit(QAbstractSocket::SslInternalError, QStringLiteral("Unable to init SSL Context")); return; } @@ -470,7 +470,7 @@ void QSslSocketBackendPrivate::transmit() if (connectionEncrypted && !writeBuffer.isEmpty()) { qint64 totalBytesWritten = 0; - while (writeBuffer.nextDataBlockSize() > 0) { + while (writeBuffer.nextDataBlockSize() > 0 && context) { const size_t nextDataBlockSize = writeBuffer.nextDataBlockSize(); size_t writtenBytes = 0; const OSStatus err = SSLWrite(context, writeBuffer.readPointer(), nextDataBlockSize, &writtenBytes); @@ -505,7 +505,7 @@ void QSslSocketBackendPrivate::transmit() if (connectionEncrypted) { QVarLengthArray<char, 4096> data; - while (true) { + while (context) { size_t readBytes = 0; data.resize(4096); const OSStatus err = SSLRead(context, data.data(), data.size(), &readBytes); @@ -780,7 +780,7 @@ bool QSslSocketBackendPrivate::initSslContext() context.reset(qt_createSecureTransportContext(mode)); if (!context) { - setErrorAndEmit(QAbstractSocket::SslInternalError, "SSLCreateContext failed"); + setErrorAndEmit(QAbstractSocket::SslInternalError, QStringLiteral("SSLCreateContext failed")); return false; } @@ -808,7 +808,7 @@ bool QSslSocketBackendPrivate::initSslContext() if (!setSessionProtocol()) { destroySslContext(); - setErrorAndEmit(QAbstractSocket::SslInternalError, "Failed to set protocol version"); + setErrorAndEmit(QAbstractSocket::SslInternalError, QStringLiteral("Failed to set protocol version")); return false; } @@ -1121,7 +1121,10 @@ bool QSslSocketBackendPrivate::verifyPeerTrust() // report errors if (!errors.isEmpty() && !canIgnoreVerify) { sslErrors = errors; - if (!checkSslErrors()) + // checkSslErrors unconditionally emits sslErrors: + // a user's slot can abort/close/disconnect on this + // signal, so we also test the socket's state: + if (!checkSslErrors() || q->state() != QAbstractSocket::ConnectedState) return false; } else { sslErrors.clear(); @@ -1219,8 +1222,7 @@ bool QSslSocketBackendPrivate::startHandshake() // check protocol version ourselves, as Secure Transport does not enforce // the requested min / max versions. if (!verifySessionProtocol()) { - setErrorAndEmit(QAbstractSocket::SslHandshakeFailedError, - "Protocol version mismatch"); + setErrorAndEmit(QAbstractSocket::SslHandshakeFailedError, QStringLiteral("Protocol version mismatch")); plainSocket->disconnectFromHost(); return false; } diff --git a/src/platformsupport/clipboard/qmacmime.mm b/src/platformsupport/clipboard/qmacmime.mm index 02d1295b0f..d48da8da15 100644 --- a/src/platformsupport/clipboard/qmacmime.mm +++ b/src/platformsupport/clipboard/qmacmime.mm @@ -412,9 +412,7 @@ QVariant QMacPasteboardMimeUnicodeText::convertToMime(const QString &mimetype, Q // I can only handle two types (system and unicode) so deal with them that way QVariant ret; if (flavor == QLatin1String("public.utf8-plain-text")) { - ret = QString(QCFString(CFStringCreateWithBytes(kCFAllocatorDefault, - reinterpret_cast<const UInt8 *>(firstData.constData()), - firstData.size(), CFStringGetSystemEncoding(), false))); + ret = QString::fromUtf8(firstData); } else if (flavor == QLatin1String("public.utf16-plain-text")) { ret = QString(reinterpret_cast<const QChar *>(firstData.constData()), firstData.size() / sizeof(QChar)); diff --git a/src/platformsupport/dbustray/qdbustrayicon.cpp b/src/platformsupport/dbustray/qdbustrayicon.cpp index 724992f348..da368bf9b7 100644 --- a/src/platformsupport/dbustray/qdbustrayicon.cpp +++ b/src/platformsupport/dbustray/qdbustrayicon.cpp @@ -66,7 +66,7 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray") static const QString KDEItemFormat = QStringLiteral("org.kde.StatusNotifierItem-%1-%2"); static const QString KDEWatcherService = QStringLiteral("org.kde.StatusNotifierWatcher"); -static const QString TempFileTemplate = QDir::tempPath() + QStringLiteral("/qt-trayicon-XXXXXX.png"); +static const QString TempFileTemplate = QDir::tempPath() + QLatin1String("/qt-trayicon-XXXXXX.png"); static const QString XdgNotificationService = QStringLiteral("org.freedesktop.Notifications"); static const QString XdgNotificationPath = QStringLiteral("/org/freedesktop/Notifications"); static const QString DefaultAction = QStringLiteral("default"); @@ -156,7 +156,7 @@ QTemporaryFile *QDBusTrayIcon::tempIcon(const QIcon &icon) QDBusConnection session = QDBusConnection::sessionBus(); uint pid = session.interface()->servicePid(KDEWatcherService).value(); QString processName = QLockFilePrivate::processNameByPid(pid); - necessary = processName.endsWith(QStringLiteral("indicator-application-service")); + necessary = processName.endsWith(QLatin1String("indicator-application-service")); necessity_checked = true; } if (!necessary) diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 1a17f75488..5fec53d1ed 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -585,8 +585,7 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo fallbackList.append(familyNameFromPostScriptName(item)); } - if (QCoreTextFontEngine::supportsColorGlyphs()) - fallbackList.append(QLatin1String("Apple Color Emoji")); + fallbackList.append(QLatin1String("Apple Color Emoji")); // Since we are only returning a list of default fonts for the current language, we do not // cover all unicode completely. This was especially an issue for some of the common script diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index 251ba2b9ac..a0047c0b7d 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -224,11 +224,9 @@ void QCoreTextFontEngine::init() synthesisFlags = 0; CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(ctfont); -#if defined(QT_PLATFORM_UIKIT) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 - if (supportsColorGlyphs() && (traits & kCTFontColorGlyphsTrait)) + if (traits & kCTFontColorGlyphsTrait) glyphFormat = QFontEngine::Format_ARGB; else -#endif glyphFormat = defaultGlyphFormat; if (traits & kCTFontItalicTrait) @@ -659,9 +657,7 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition CGContextSetTextPosition(ctx, pos_x + 0.5 * lineThickness().toReal(), pos_y); CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &CGSizeZero, 1); } - } -#if defined(QT_PLATFORM_UIKIT) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 - else if (supportsColorGlyphs()) { + } else { // CGContextSetTextMatrix does not work with color glyphs, so we use // the CTM instead. This means we must translate the CTM as well, to // set the glyph position, instead of using CGContextSetTextPosition. @@ -672,7 +668,6 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition // glyphs in the Apple Color Emoji font, so we use CTFontDrawGlyphs instead. CTFontDrawGlyphs(ctfont, &cgGlyph, &CGPointZero, 1, ctx); } -#endif CGContextRelease(ctx); CGColorSpaceRelease(colorspace); diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h index 27289239c6..b7c9edc528 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h @@ -116,21 +116,6 @@ public: QFontEngine::Properties properties() const Q_DECL_OVERRIDE; - static bool supportsColorGlyphs() - { -#if defined(QT_PLATFORM_UIKIT) - return true; -#elif MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 - #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 - return &CTFontDrawGlyphs; - #else - return true; - #endif -#else - return false; -#endif - } - static bool ct_getSfntTable(void *user_data, uint tag, uchar *buffer, uint *length); static QFont::Weight qtWeightFromCFWeight(float value); diff --git a/src/platformsupport/input/tslib/qtslib.cpp b/src/platformsupport/input/tslib/qtslib.cpp index ed21cc1cef..75ac3c50e0 100644 --- a/src/platformsupport/input/tslib/qtslib.cpp +++ b/src/platformsupport/input/tslib/qtslib.cpp @@ -64,7 +64,7 @@ QTsLibMouseHandler::QTsLibMouseHandler(const QString &key, QByteArray device = qgetenv("TSLIB_TSDEVICE"); - if (specification.startsWith(QStringLiteral("/dev/"))) + if (specification.startsWith(QLatin1String("/dev/"))) device = specification.toLocal8Bit(); if (device.isEmpty()) diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp index 727da3132a..5242f00193 100644 --- a/src/platformsupport/services/genericunix/qgenericunixservices.cpp +++ b/src/platformsupport/services/genericunix/qgenericunixservices.cpp @@ -101,7 +101,7 @@ static inline bool detectWebBrowser(const QByteArray &desktop, if (desktop == QByteArray("KDE")) { // Konqueror launcher if (checkExecutable(QStringLiteral("kfmclient"), browser)) { - browser->append(QStringLiteral(" exec")); + browser->append(QLatin1String(" exec")); return true; } } else if (desktop == QByteArray("GNOME")) { @@ -121,7 +121,7 @@ static inline bool launch(const QString &launcher, const QUrl &url) if (debug) qDebug("Launching %s", qPrintable(command)); #if defined(QT_NO_PROCESS) - const bool ok = ::system(qPrintable(command + QStringLiteral(" &"))); + const bool ok = ::system(qPrintable(command + QLatin1String(" &"))); #else const bool ok = QProcess::startDetached(command); #endif diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index 5e5c931c2c..9abcd04063 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -170,7 +170,7 @@ QStringList QGenericUnixTheme::xdgIconThemePaths() { QStringList paths; // Add home directory first in search path - const QFileInfo homeIconDir(QDir::homePath() + QStringLiteral("/.icons")); + const QFileInfo homeIconDir(QDir::homePath() + QLatin1String("/.icons")); if (homeIconDir.isDir()) paths.prepend(homeIconDir.absoluteFilePath()); @@ -247,8 +247,8 @@ public: static QString kdeGlobals(const QString &kdeDir, int kdeVersion) { if (kdeVersion > 4) - return kdeDir + QStringLiteral("/kdeglobals"); - return kdeDir + QStringLiteral("/share/config/kdeglobals"); + return kdeDir + QLatin1String("/kdeglobals"); + return kdeDir + QLatin1String("/share/config/kdeglobals"); } void refresh(); @@ -559,22 +559,22 @@ QPlatformTheme *QKdeTheme::createKdeTheme() if (!kdeDirsVar.isEmpty()) kdeDirs += kdeDirsVar.split(QLatin1Char(':'), QString::SkipEmptyParts); - const QString kdeVersionHomePath = QDir::homePath() + QStringLiteral("/.kde") + QLatin1String(kdeVersionBA); + const QString kdeVersionHomePath = QDir::homePath() + QLatin1String("/.kde") + QLatin1String(kdeVersionBA); if (QFileInfo(kdeVersionHomePath).isDir()) kdeDirs += kdeVersionHomePath; - const QString kdeHomePath = QDir::homePath() + QStringLiteral("/.kde"); + const QString kdeHomePath = QDir::homePath() + QLatin1String("/.kde"); if (QFileInfo(kdeHomePath).isDir()) kdeDirs += kdeHomePath; - const QString kdeRcPath = QStringLiteral("/etc/kde") + QLatin1String(kdeVersionBA) + QStringLiteral("rc"); + const QString kdeRcPath = QLatin1String("/etc/kde") + QLatin1String(kdeVersionBA) + QLatin1String("rc"); if (QFileInfo(kdeRcPath).isReadable()) { QSettings kdeSettings(kdeRcPath, QSettings::IniFormat); kdeSettings.beginGroup(QStringLiteral("Directories-default")); kdeDirs += kdeSettings.value(QStringLiteral("prefixes")).toStringList(); } - const QString kdeVersionPrefix = QStringLiteral("/etc/kde") + QLatin1String(kdeVersionBA); + const QString kdeVersionPrefix = QLatin1String("/etc/kde") + QLatin1String(kdeVersionBA); if (QFileInfo(kdeVersionPrefix).isDir()) kdeDirs += kdeVersionPrefix; diff --git a/src/plugins/bearer/connman/qconnmanservice_linux_p.h b/src/plugins/bearer/connman/qconnmanservice_linux_p.h index e773db9b20..0e774d50c3 100644 --- a/src/plugins/bearer/connman/qconnmanservice_linux_p.h +++ b/src/plugins/bearer/connman/qconnmanservice_linux_p.h @@ -218,6 +218,7 @@ protected: private: QVariantMap properties(); QVariantMap propertiesMap; +private Q_SLOTS: void scanReply(QDBusPendingCallWatcher *call); }; diff --git a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp index 52d14e5324..d507751d5e 100644 --- a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp +++ b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp @@ -278,7 +278,7 @@ QString TableGenerator::findComposeFile() // check if user’s home directory has a file named .XCompose if (cleanState()) { - QString path = qgetenv("HOME") + QStringLiteral("/.XCompose"); + QString path = qgetenv("HOME") + QLatin1String("/.XCompose"); if (QFile::exists(path)) return path; } diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index f6a3b3943f..f02dad675e 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -457,6 +457,10 @@ QCocoaScreen *QCocoaIntegration::screenAtIndex(int index) if (index >= mScreens.count()) updateScreens(); + // It is possible that the screen got removed while updateScreens was called + // so we do a sanity check to be certain + if (index >= mScreens.count()) + return 0; return mScreens.at(index); } diff --git a/src/plugins/platforms/cocoa/qcocoamenu.h b/src/plugins/platforms/cocoa/qcocoamenu.h index 7951a2ff70..6b80162e4d 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.h +++ b/src/plugins/platforms/cocoa/qcocoamenu.h @@ -93,6 +93,9 @@ public: void setAttachedItem(NSMenuItem *item); NSMenuItem *attachedItem() const; + bool isOpen() const; + void setIsOpen(bool isOpen); + private: QCocoaMenuItem *itemOrNull(int index) const; void insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem); @@ -100,9 +103,10 @@ private: QList<QCocoaMenuItem *> m_menuItems; NSMenu *m_nativeMenu; NSMenuItem *m_attachedItem; + quintptr m_tag; bool m_enabled; bool m_visible; - quintptr m_tag; + bool m_isOpen; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index a388155c03..06ec2aa479 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -137,12 +137,14 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaMenuDelegate); - (void) menuWillOpen:(NSMenu*)m { Q_UNUSED(m); + m_menu->setIsOpen(true); emit m_menu->aboutToShow(); } - (void) menuDidClose:(NSMenu*)m { Q_UNUSED(m); + m_menu->setIsOpen(false); // wrong, but it's the best we can do emit m_menu->aboutToHide(); } @@ -257,9 +259,10 @@ QT_BEGIN_NAMESPACE QCocoaMenu::QCocoaMenu() : m_attachedItem(0), + m_tag(0), m_enabled(true), m_visible(true), - m_tag(0) + m_isOpen(false) { QMacAutoReleasePool pool; @@ -330,6 +333,8 @@ 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->menu()->setAttachedItem(item->nsItem()); if (item->isMerged()) return; @@ -353,6 +358,16 @@ void QCocoaMenu::insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem) item->setMenuParent(this); } +bool QCocoaMenu::isOpen() const +{ + return m_isOpen; +} + +void QCocoaMenu::setIsOpen(bool isOpen) +{ + m_isOpen = isOpen; +} + void QCocoaMenu::removeMenuItem(QPlatformMenuItem *menuItem) { QMacAutoReleasePool pool; diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index 86f6dda2e9..96b40259b4 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -179,9 +179,11 @@ void QCocoaMenuBar::syncMenu(QPlatformMenu *menu) } } - NSMenuItem *nativeMenuItem = nativeItemForMenu(cocoaMenu); - nativeMenuItem.title = cocoaMenu->nsMenu().title; - nativeMenuItem.hidden = shouldHide; + if (NSMenuItem *attachedItem = cocoaMenu->attachedItem()) { + // Non-nil attached item means the item's submenu is set + attachedItem.title = cocoaMenu->nsMenu().title; + attachedItem.hidden = shouldHide; + } } NSMenuItem *QCocoaMenuBar::nativeItemForMenu(QCocoaMenu *menu) const diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 9e2fca23a1..831f1cfcf4 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -260,34 +260,14 @@ QPixmap QCocoaTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const } if (iconType != 0) { QPixmap pixmap; - IconRef icon; - IconRef overlayIcon = 0; - if (iconType != kGenericApplicationIcon) { - GetIconRef(kOnSystemDisk, kSystemIconsCreator, iconType, &icon); - } else { - FSRef fsRef; - ProcessSerialNumber psn = { 0, kCurrentProcess }; - GetProcessBundleLocation(&psn, &fsRef); - GetIconRefFromFileInfo(&fsRef, 0, 0, 0, 0, kIconServicesNormalUsageFlag, &icon, 0); - if (sp == MessageBoxCritical) { - overlayIcon = icon; - GetIconRef(kOnSystemDisk, kSystemIconsCreator, kAlertCautionIcon, &icon); - } - } + IconRef icon = Q_NULLPTR; + GetIconRef(kOnSystemDisk, kSystemIconsCreator, iconType, &icon); if (icon) { pixmap = qt_mac_convert_iconref(icon, size.width(), size.height()); ReleaseIconRef(icon); } - if (overlayIcon) { - QSizeF littleSize = size / 2; - QPixmap overlayPix = qt_mac_convert_iconref(overlayIcon, littleSize.width(), littleSize.height()); - QPainter painter(&pixmap); - painter.drawPixmap(littleSize.width(), littleSize.height(), overlayPix); - ReleaseIconRef(overlayIcon); - } - return pixmap; } diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 7834c2991d..a72cbd010a 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -443,7 +443,8 @@ static bool _q_dontOverrideCtrlLMB = false; NSUInteger screenIndex = [[NSScreen screens] indexOfObject:self.window.screen]; if (screenIndex != NSNotFound) { QCocoaScreen *cocoaScreen = QCocoaIntegration::instance()->screenAtIndex(screenIndex); - QWindowSystemInterface::handleWindowScreenChanged(m_window, cocoaScreen->screen()); + if (cocoaScreen) + QWindowSystemInterface::handleWindowScreenChanged(m_window, cocoaScreen->screen()); m_platformWindow->updateExposedGeometry(); } } diff --git a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp index c6aab9d86c..3848e99221 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp @@ -82,7 +82,7 @@ QStringList QEglFSDeviceIntegrationFactory::keys(const QString &pluginPath) QCoreApplication::addLibraryPath(pluginPath); list = directLoader()->keyMap().values(); if (!list.isEmpty()) { - const QString postFix = QStringLiteral(" (from ") + const QString postFix = QLatin1String(" (from ") + QDir::toNativeSeparators(pluginPath) + QLatin1Char(')'); const QStringList::iterator end = list.end(); diff --git a/src/plugins/platforms/minimal/minimal.pro b/src/plugins/platforms/minimal/minimal.pro index bd6f2d8e6f..3aca27b555 100644 --- a/src/plugins/platforms/minimal/minimal.pro +++ b/src/plugins/platforms/minimal/minimal.pro @@ -11,7 +11,7 @@ HEADERS = qminimalintegration.h \ OTHER_FILES += minimal.json CONFIG += qpa/genericunixfontdatabase -darwin: DEFINES += QT_NO_FONTCONFIG +win32|darwin: DEFINES += QT_NO_FONTCONFIG PLUGIN_TYPE = platforms PLUGIN_CLASS_NAME = QMinimalIntegrationPlugin diff --git a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp index b075690e3d..7f11de228e 100644 --- a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp @@ -178,7 +178,7 @@ void QQnxRasterWindow::adjustBufferSize() { // When having a raster window we don't need any buffers, since // Qt will draw to the parent TLW backing store. - const QSize windowSize = window()->parent() ? QSize(1,1) : window()->size(); + const QSize windowSize = window()->parent() ? QSize(0,0) : window()->size(); if (windowSize != bufferSize()) setBufferSize(windowSize); } @@ -194,6 +194,13 @@ void QQnxRasterWindow::resetBuffers() m_currentBufferIndex = -1; m_previousDirty = QRegion(); m_scrolled = QRegion(); + if (window()->parent() && bufferSize() == QSize(1,1)) { + // If we have a parent then we're not really rendering. But if we don't render we'll + // be invisible and any children won't show up. This should be harmless since we're + // rendering into a 1x1 window that has transparency set to discard. + renderBuffer(); + post(QRegion(0,0,1,1)); + } } void QQnxRasterWindow::blitPreviousToCurrent(const QRegion ®ion, int dx, int dy, bool flush) diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index e04f16db92..f4e6ca9804 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -386,7 +386,12 @@ void QQnxWindow::setBufferSize(const QSize &size) // Set the transparency. According to QNX technical support, setting the window // transparency property should always be done *after* creating the window // buffers in order to guarantee the property is paid attention to. - if (window()->requestedFormat().alphaBufferSize() == 0) { + if (size.isEmpty()) { + // We can't create 0x0 buffers and instead make them 1x1. But to allow these windows to + // still be 'visible' (thus allowing their children to be visible), we need to allow + // them to be posted but still not show up. + val[0] = SCREEN_TRANSPARENCY_DISCARD; + } else if (window()->requestedFormat().alphaBufferSize() == 0) { // To avoid overhead in the composition manager, disable blending // when the underlying window buffer doesn't have an alpha channel. val[0] = SCREEN_TRANSPARENCY_NONE; diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index ef0962c2ff..3a683bd7a0 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -47,6 +47,7 @@ #include "qwindowsmime.h" #include "qwindowsinputcontext.h" #include "qwindowstabletsupport.h" +#include "qwindowstheme.h" #include <private/qguiapplication_p.h> #ifndef QT_NO_ACCESSIBILITY # include "accessible/qwindowsaccessibility.h" @@ -339,7 +340,9 @@ void QWindowsContext::setProcessDpiAwareness(QtWindows::ProcessDpiAwareness dpiA qCDebug(lcQpaWindows) << __FUNCTION__ << dpiAwareness; if (QWindowsContext::shcoredll.isValid()) { const HRESULT hr = QWindowsContext::shcoredll.setProcessDpiAwareness(dpiAwareness); - if (FAILED(hr)) { + // E_ACCESSDENIED means set externally (MSVC manifest or external app loading Qt plugin). + // Silence warning in that case unless debug is enabled. + if (FAILED(hr) && (hr != E_ACCESSDENIED || lcQpaWindows().isDebugEnabled())) { qWarning().noquote().nospace() << "SetProcessDpiAwareness(" << dpiAwareness << ") failed: " << QWindowsContext::comErrorString(hr) << ", using " << QWindowsContext::processDpiAwareness(); @@ -428,28 +431,29 @@ QString QWindowsContext::registerWindowClass(const QWindow *w) break; } // Create a unique name for the flag combination - QString cname = QStringLiteral("Qt5QWindow"); + QString cname; + cname += QLatin1String("Qt5QWindow"); switch (type) { case Qt::Tool: - cname += QStringLiteral("Tool"); + cname += QLatin1String("Tool"); break; case Qt::ToolTip: - cname += QStringLiteral("ToolTip"); + cname += QLatin1String("ToolTip"); break; case Qt::Popup: - cname += QStringLiteral("Popup"); + cname += QLatin1String("Popup"); break; default: break; } if (style & CS_DROPSHADOW) - cname += QStringLiteral("DropShadow"); + cname += QLatin1String("DropShadow"); if (style & CS_SAVEBITS) - cname += QStringLiteral("SaveBits"); + cname += QLatin1String("SaveBits"); if (style & CS_OWNDC) - cname += QStringLiteral("OwnDC"); + cname += QLatin1String("OwnDC"); if (icon) - cname += QStringLiteral("Icon"); + cname += QLatin1String("Icon"); return registerWindowClass(cname, qWindowsWndProc, style, GetSysColorBrush(COLOR_WINDOW), icon); } @@ -714,8 +718,8 @@ static inline QString errorMessageFromComError(const _com_error &comError) return result; } if (const WORD wCode = comError.WCode()) - return QStringLiteral("IDispatch error #") + QString::number(wCode); - return QStringLiteral("Unknown error 0x0") + QString::number(comError.Error(), 16); + return QString::asprintf("IDispatch error #%u", uint(wCode)); + return QString::asprintf("Unknown error 0x0%x", uint(comError.Error())); } /*! @@ -736,6 +740,9 @@ QByteArray QWindowsContext::comErrorString(HRESULT hr) case E_UNEXPECTED: result += QByteArrayLiteral("E_UNEXPECTED"); break; + case E_ACCESSDENIED: + result += QByteArrayLiteral("E_ACCESSDENIED"); + break; case CO_E_ALREADYINITIALIZED: result += QByteArrayLiteral("CO_E_ALREADYINITIALIZED"); break; @@ -891,6 +898,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, #endif case QtWindows::DisplayChangedEvent: return d->m_screenManager.handleDisplayChange(wParam, lParam); + if (QWindowsTheme *t = QWindowsTheme::instance()) + t->displayChanged(); case QtWindows::SettingChangedEvent: return d->m_screenManager.handleScreenChanges(); default: diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp index 6124b004b6..a4738dc100 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp @@ -367,7 +367,7 @@ QSurfaceFormat QWindowsEGLStaticContext::formatFromConfig(EGLDisplay display, EG \list \o Install the Direct X SDK \o Checkout and build ANGLE (SVN repository) as explained here: - \l{http://code.google.com/p/angleproject/wiki/DevSetup}{ANGLE-Project}. + \l{https://chromium.googlesource.com/angle/angle/+/master/README.md} When building for 64bit, de-activate the "WarnAsError" option in every project file (as otherwise integer conversion warnings will break the build). diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index d6375693d8..30d438a127 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -696,7 +696,7 @@ QVariant QWindowsMimeText::convertToMime(const QString &mime, LPDATAOBJECT pData QByteArray data = getData(CF_UNICODETEXT, pDataObj); if (!data.isEmpty()) { str = QString::fromWCharArray(reinterpret_cast<const wchar_t *>(data.constData())); - str.replace(QStringLiteral("\r\n"), QStringLiteral("\n")); + str.replace(QLatin1String("\r\n"), QLatin1String("\n")); } else { data = getData(CF_TEXT, pDataObj); if (!data.isEmpty()) { diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index 45fbb4fdd3..3f6230172e 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -420,6 +420,8 @@ static bool isValidWheelReceiver(QWindow *candidate) { if (candidate) { const QWindow *toplevel = QWindowsWindow::topLevelOf(candidate); + if (toplevel->type() == Qt::ForeignWindow) + return true; if (const QWindowsWindow *ww = QWindowsWindow::windowsWindowOf(toplevel)) return !ww->testFlag(QWindowsWindow::BlockedByModal); } diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp index d5d50a69cd..5283d6b260 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp @@ -226,15 +226,16 @@ QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(c if (!glesOnly && testDesktopGL()) result |= QWindowsOpenGLTester::DesktopGl; - QSet<QString> features; const char bugListFileVar[] = "QT_OPENGL_BUGLIST"; + QString buglistFileName = QStringLiteral(":/qt-project.org/windows/openglblacklists/default.json"); + if (qEnvironmentVariableIsSet(bugListFileVar)) { const QString fileName = resolveBugListFile(QFile::decodeName(qgetenv(bugListFileVar))); if (!fileName.isEmpty()) - features = QOpenGLConfig::gpuFeatures(qgpu, fileName); - } else { - features = QOpenGLConfig::gpuFeatures(qgpu, QStringLiteral(":/qt-project.org/windows/openglblacklists/default.json")); + buglistFileName = fileName; } + + QSet<QString> features = QOpenGLConfig::gpuFeatures(qgpu, buglistFileName); qCDebug(lcQpaGl) << "GPU features:" << features; if (features.contains(QStringLiteral("disable_desktopgl"))) { // Qt-specific diff --git a/src/plugins/platforms/windows/qwindowsservices.cpp b/src/plugins/platforms/windows/qwindowsservices.cpp index d559273950..6cc56372ec 100644 --- a/src/plugins/platforms/windows/qwindowsservices.cpp +++ b/src/plugins/platforms/windows/qwindowsservices.cpp @@ -87,9 +87,8 @@ static inline QString mailCommand() keyName = QString::fromWCharArray(command); RegCloseKey(handle); } - if (keyName.isEmpty()) - keyName = QStringLiteral("mailto"); - keyName += QStringLiteral("\\Shell\\Open\\Command"); + const QLatin1String mailto = keyName.isEmpty() ? QLatin1String("mailto") : QLatin1String(); + keyName += mailto + QLatin1String("\\Shell\\Open\\Command"); if (debug) qDebug() << __FUNCTION__ << "keyName=" << keyName; command[0] = 0; @@ -123,7 +122,7 @@ static inline bool launchMail(const QUrl &url) } // Pass the url as the parameter. Should use QProcess::startDetached(), // but that cannot handle a Windows command line [yet]. - command.replace(QStringLiteral("%1"), url.toString(QUrl::FullyEncoded)); + command.replace(QLatin1String("%1"), url.toString(QUrl::FullyEncoded)); if (debug) qDebug() << __FUNCTION__ << "Launching" << command; //start the process diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp index 3689978b41..46306d438f 100644 --- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp +++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp @@ -53,7 +53,7 @@ #include <QtGui/QGuiApplication> #include <QtGui/QWindow> #include <QtCore/QDebug> -#include <QtCore/QScopedArrayPointer> +#include <QtCore/QVarLengthArray> #include <QtCore/QtMath> #include <private/qguiapplication_p.h> @@ -233,7 +233,7 @@ QString QWindowsTabletSupport::description() const const unsigned size = m_winTab32DLL.wTInfo(WTI_INTERFACE, IFC_WINTABID, 0); if (!size) return QString(); - QScopedPointer<TCHAR> winTabId(new TCHAR[size + 1]); + QVarLengthArray<TCHAR> winTabId(size + 1); m_winTab32DLL.wTInfo(WTI_INTERFACE, IFC_WINTABID, winTabId.data()); WORD implementationVersion = 0; m_winTab32DLL.wTInfo(WTI_INTERFACE, IFC_IMPLVERSION, &implementationVersion); @@ -246,11 +246,11 @@ QString QWindowsTabletSupport::description() const .arg(implementationVersion >> 8).arg(implementationVersion & 0xFF) .arg(opts, 0, 16); if (opts & CXO_MESSAGES) - result += QStringLiteral(" CXO_MESSAGES"); + result += QLatin1String(" CXO_MESSAGES"); if (opts & CXO_CSRMESSAGES) - result += QStringLiteral(" CXO_CSRMESSAGES"); + result += QLatin1String(" CXO_CSRMESSAGES"); if (m_tiltSupport) - result += QStringLiteral(" tilt"); + result += QLatin1String(" tilt"); return result; } diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 6c6eb42d63..ff556caeaf 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -319,6 +319,7 @@ QWindowsTheme::QWindowsTheme() std::fill(m_fonts, m_fonts + NFonts, static_cast<QFont *>(0)); std::fill(m_palettes, m_palettes + NPalettes, static_cast<QPalette *>(0)); refresh(); + refreshIconPixmapSizes(); } QWindowsTheme::~QWindowsTheme() @@ -330,7 +331,7 @@ QWindowsTheme::~QWindowsTheme() static inline QStringList iconThemeSearchPaths() { - const QFileInfo appDir(QCoreApplication::applicationDirPath() + QStringLiteral("/icons")); + const QFileInfo appDir(QCoreApplication::applicationDirPath() + QLatin1String("/icons")); return appDir.isDir() ? QStringList(appDir.absoluteFilePath()) : QStringList(); } @@ -382,16 +383,8 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const return QVariant(int(WindowsKeyboardScheme)); case UiEffects: return QVariant(uiEffects()); - case IconPixmapSizes: { - QList<int> sizes; - sizes << 16 << 32; -#ifdef USE_IIMAGELIST - sizes << 48; // sHIL_EXTRALARGE - if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) - sizes << 256; // SHIL_JUMBO -#endif // USE_IIMAGELIST - return QVariant::fromValue(sizes); - } + case IconPixmapSizes: + return m_fileIconSizes; case DialogSnapToDefaultButton: return QVariant(booleanSystemParametersInfo(SPI_GETSNAPTODEFBUTTON, false)); case ContextMenuOnMouseRelease: @@ -459,6 +452,15 @@ void QWindowsTheme::refreshFonts() m_fonts[FixedFont] = new QFont(fixedFont); } +enum FileIconSize { + // Standard icons obtainable via shGetFileInfo(), SHGFI_SMALLICON, SHGFI_LARGEICON + SmallFileIcon, LargeFileIcon, + // Larger icons obtainable via SHGetImageList() + ExtraLargeFileIcon, + JumboFileIcon, // Vista onwards + FileIconSizeCount +}; + bool QWindowsTheme::usePlatformNativeDialog(DialogType type) const { return QWindowsDialogs::useHelper(type); @@ -475,6 +477,27 @@ void QWindowsTheme::windowsThemeChanged(QWindow * window) QWindowSystemInterface::handleThemeChange(window); } +static int fileIconSizes[FileIconSizeCount]; + +void QWindowsTheme::refreshIconPixmapSizes() +{ + // Standard sizes: 16, 32, 48, 256 + fileIconSizes[SmallFileIcon] = GetSystemMetrics(SM_CXSMICON); // corresponds to SHGFI_SMALLICON); + fileIconSizes[LargeFileIcon] = GetSystemMetrics(SM_CXICON); // corresponds to SHGFI_LARGEICON + fileIconSizes[ExtraLargeFileIcon] = + fileIconSizes[LargeFileIcon] + fileIconSizes[LargeFileIcon] / 2; + fileIconSizes[JumboFileIcon] = 8 * fileIconSizes[LargeFileIcon]; // empirical, has not been observed to work + QList<int> sizes; + sizes << fileIconSizes[SmallFileIcon] << fileIconSizes[LargeFileIcon]; +#ifdef USE_IIMAGELIST + sizes << fileIconSizes[ExtraLargeFileIcon]; // sHIL_EXTRALARGE + if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) + sizes << fileIconSizes[JumboFileIcon]; // SHIL_JUMBO +#endif // USE_IIMAGELIST + qCDebug(lcQpaWindows) << __FUNCTION__ << sizes; + m_fileIconSizes = QVariant::fromValue(sizes); +} + // Defined in qpixmap_win.cpp Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon); @@ -702,10 +725,12 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s QPixmap pixmap; const QString filePath = QDir::toNativeSeparators(fileInfo.filePath()); const int width = int(size.width()); - const int iconSize = width > 16 ? SHGFI_LARGEICON : SHGFI_SMALLICON; + const int iconSize = width > fileIconSizes[SmallFileIcon] ? SHGFI_LARGEICON : SHGFI_SMALLICON; const int requestedImageListSize = #ifdef USE_IIMAGELIST - width > 48 ? sHIL_JUMBO : (width > 32 ? sHIL_EXTRALARGE : 0); + width > fileIconSizes[ExtraLargeFileIcon] + ? sHIL_JUMBO + : (width > fileIconSizes[LargeFileIcon] ? sHIL_EXTRALARGE : 0); #else 0; #endif // !USE_IIMAGELIST diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h index acf89306c2..fa1fb4d998 100644 --- a/src/plugins/platforms/windows/qwindowstheme.h +++ b/src/plugins/platforms/windows/qwindowstheme.h @@ -43,6 +43,8 @@ #include "qwindowsthreadpoolrunner.h" #include <qpa/qplatformtheme.h> +#include <QtCore/QVariant> + QT_BEGIN_NAMESPACE class QWindow; @@ -68,6 +70,7 @@ public: QPlatformTheme::IconOptions iconOptions = 0) const Q_DECL_OVERRIDE; void windowsThemeChanged(QWindow *window); + void displayChanged() { refreshIconPixmapSizes(); } static const char *name; @@ -77,11 +80,13 @@ private: void refreshPalettes(); void clearFonts(); void refreshFonts(); + void refreshIconPixmapSizes(); static QWindowsTheme *m_instance; QPalette *m_palettes[NPalettes]; QFont *m_fonts[NFonts]; mutable QWindowsThreadPoolRunner m_threadPoolRunner; + QVariant m_fileIconSizes; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index e58058010d..29f0af4621 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -2395,9 +2395,10 @@ void QWindowsWindow::aboutToMakeCurrent() void QWindowsWindow::setHasBorderInFullScreenStatic(QWindow *window, bool border) { - if (!window->handle()) - return; - static_cast<QWindowsWindow *>(window->handle())->setHasBorderInFullScreen(border); + if (QPlatformWindow *handle = window->handle()) + static_cast<QWindowsWindow *>(handle)->setHasBorderInFullScreen(border); + else + qWarning("%s invoked without window handle; call has no effect.", Q_FUNC_INFO); } void QWindowsWindow::setHasBorderInFullScreen(bool border) diff --git a/src/plugins/platforms/winrt/qwinrtclipboard.cpp b/src/plugins/platforms/winrt/qwinrtclipboard.cpp index aee9fc617d..2811f1f018 100644 --- a/src/plugins/platforms/winrt/qwinrtclipboard.cpp +++ b/src/plugins/platforms/winrt/qwinrtclipboard.cpp @@ -102,7 +102,7 @@ QMimeData *QWinRTClipboard::mimeData(QClipboard::Mode mode) quint32 size; const wchar_t *textStr = result.GetRawBuffer(&size); QString text = QString::fromWCharArray(textStr, size); - text.replace(QStringLiteral("\r\n"), QStringLiteral("\n")); + text.replace(QLatin1String("\r\n"), QLatin1String("\n")); m_mimeData.setText(text); return &m_mimeData; diff --git a/src/plugins/platforms/winrt/qwinrtdrag.cpp b/src/plugins/platforms/winrt/qwinrtdrag.cpp index 2ef50aa4e2..055aacbf56 100644 --- a/src/plugins/platforms/winrt/qwinrtdrag.cpp +++ b/src/plugins/platforms/winrt/qwinrtdrag.cpp @@ -504,8 +504,8 @@ static HRESULT qt_drop(IInspectable *sender, ABI::Windows::UI::Xaml::IDragEventA class QtDragEventHandler##name : public IDragEventHandler \ { \ public: \ - virtual HRESULT STDMETHODCALLTYPE Invoke(IInspectable *sender, \ - ABI::Windows::UI::Xaml::IDragEventArgs *e) \ + STDMETHODIMP Invoke(IInspectable *sender, \ + ABI::Windows::UI::Xaml::IDragEventArgs *e) \ { \ return qt_##func(sender, e);\ } \ diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 5d46c53b30..7065bb0ffb 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -265,8 +265,8 @@ void QXcbConnection::updateScreens(const xcb_randr_notify_event_t *event) } else { screen = createScreen(virtualDesktop, output, outputInfo.data()); qCDebug(lcQpaScreen) << "output" << screen->name() << "is connected and enabled"; - QHighDpiScaling::updateHighDpiScaling(); } + QHighDpiScaling::updateHighDpiScaling(); } } else if (screen) { if (output.crtc == XCB_NONE && output.mode == XCB_NONE) { diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index 7168e6e3bd..811ef4251a 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -979,10 +979,21 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const xkb_layout_index_t lockedLayout = xkb_state_serialize_layout(xkb_state, XKB_STATE_LAYOUT_LOCKED); xkb_mod_mask_t latchedMods = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LATCHED); xkb_mod_mask_t lockedMods = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LOCKED); + xkb_mod_mask_t depressedMods = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_DEPRESSED); - xkb_state_update_mask(kb_state, 0, latchedMods, lockedMods, 0, 0, lockedLayout); - + xkb_state_update_mask(kb_state, depressedMods, latchedMods, lockedMods, 0, 0, lockedLayout); quint32 keycode = event->nativeScanCode(); + // handle shortcuts for level three and above + xkb_layout_index_t layoutIndex = xkb_state_key_get_layout(kb_state, keycode); + xkb_level_index_t levelIndex = 0; + if (layoutIndex != XKB_LAYOUT_INVALID) { + levelIndex = xkb_state_key_get_level(kb_state, keycode, layoutIndex); + if (levelIndex == XKB_LEVEL_INVALID) + levelIndex = 0; + } + if (levelIndex <= 1) + xkb_state_update_mask(kb_state, 0, latchedMods, lockedMods, 0, 0, lockedLayout); + xkb_keysym_t sym = xkb_state_key_get_one_sym(kb_state, keycode); if (sym == XKB_KEY_NoSymbol) { xkb_state_unref(kb_state); diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp index 825a8acd1f..f7244739a5 100644 --- a/src/plugins/platforms/xcb/qxcbmime.cpp +++ b/src/plugins/platforms/xcb/qxcbmime.cpp @@ -131,6 +131,11 @@ bool QXcbMime::mimeDataForAtom(QXcbConnection *connection, xcb_atom_t a, QMimeDa ret = true; } else if ((a == XCB_ATOM_PIXMAP || a == XCB_ATOM_BITMAP) && mimeData->hasImage()) { ret = true; + } else if (atomName == QLatin1String("text/plain") + && mimeData->hasFormat(QLatin1String("text/uri-list"))) { + // Return URLs also as plain text. + *data = QInternalMimeData::renderDataHelper(atomName, mimeData); + ret = true; } return ret; } @@ -149,8 +154,10 @@ QVector<xcb_atom_t> QXcbMime::mimeAtomsForFormat(QXcbConnection *connection, con } // special cases for uris - if (format == QLatin1String("text/uri-list")) + if (format == QLatin1String("text/uri-list")) { atoms.append(connection->internAtom("text/x-moz-url")); + atoms.append(connection->internAtom("text/plain")); + } //special cases for images if (format == QLatin1String("image/ppm")) diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp index a57b72b13e..b3dc33895b 100644 --- a/src/printsupport/kernel/qprintengine_win.cpp +++ b/src/printsupport/kernel/qprintengine_win.cpp @@ -394,6 +394,9 @@ int QWin32PrintEngine::metric(QPaintDevice::PaintDeviceMetric m) const case QPaintDevice::PdmDevicePixelRatio: val = 1; break; + case QPaintDevice::PdmDevicePixelRatioScaled: + val = 1 * QPaintDevice::devicePixelRatioFScale(); + break; default: qWarning("QPrinter::metric: Invalid metric command"); return 0; diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index 49a0c2104b..63e79c777f 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -108,43 +108,63 @@ template<> inline char *toString(const QDateTime &dateTime) template<> inline char *toString(const QChar &c) { + const ushort uc = c.unicode(); + if (uc < 128) { + char msg[32] = {'\0'}; + qsnprintf(msg, sizeof(msg), "QChar: '%c' (0x%x)", char(uc), unsigned(uc)); + return qstrdup(msg); + } return qstrdup(qPrintable(QString::fromLatin1("QChar: '%1' (0x%2)").arg(c).arg(QString::number(static_cast<int>(c.unicode()), 16)))); } template<> inline char *toString(const QPoint &p) { - return qstrdup(QString::fromLatin1("QPoint(%1,%2)").arg(p.x()).arg(p.y()).toLatin1().constData()); + char msg[128] = {'\0'}; + qsnprintf(msg, sizeof(msg), "QPoint(%d,%d)", p.x(), p.y()); + return qstrdup(msg); } template<> inline char *toString(const QSize &s) { - return qstrdup(QString::fromLatin1("QSize(%1x%2)").arg(s.width()).arg(s.height()).toLatin1().constData()); + char msg[128] = {'\0'}; + qsnprintf(msg, sizeof(msg), "QSize(%dx%d)", s.width(), s.height()); + return qstrdup(msg); } template<> inline char *toString(const QRect &s) { - return qstrdup(QString::fromLatin1("QRect(%1,%2 %5x%6) (bottomright %3,%4)").arg(s.left()).arg(s.top()).arg(s.right()).arg(s.bottom()).arg(s.width()).arg(s.height()).toLatin1().constData()); + char msg[256] = {'\0'}; + qsnprintf(msg, sizeof(msg), "QRect(%d,%d %dx%d) (bottomright %d,%d)", + s.left(), s.top(), s.width(), s.height(), s.right(), s.bottom()); + return qstrdup(msg); } template<> inline char *toString(const QPointF &p) { - return qstrdup(QString::fromLatin1("QPointF(%1,%2)").arg(p.x()).arg(p.y()).toLatin1().constData()); + char msg[64] = {'\0'}; + qsnprintf(msg, sizeof(msg), "QPointF(%g,%g)", p.x(), p.y()); + return qstrdup(msg); } template<> inline char *toString(const QSizeF &s) { - return qstrdup(QString::fromLatin1("QSizeF(%1x%2)").arg(s.width()).arg(s.height()).toLatin1().constData()); + char msg[64] = {'\0'}; + qsnprintf(msg, sizeof(msg), "QSizeF(%gx%g)", s.width(), s.height()); + return qstrdup(msg); } template<> inline char *toString(const QRectF &s) { - return qstrdup(QString::fromLatin1("QRectF(%1,%2 %5x%6) (bottomright %3,%4)").arg(s.left()).arg(s.top()).arg(s.right()).arg(s.bottom()).arg(s.width()).arg(s.height()).toLatin1().constData()); + char msg[256] = {'\0'}; + qsnprintf(msg, sizeof(msg), "QRectF(%g,%g %gx%g) (bottomright %g,%g)", + s.left(), s.top(), s.width(), s.height(), s.right(), s.bottom()); + return qstrdup(msg); } template<> inline char *toString(const QUrl &uri) { if (!uri.isValid()) - return qstrdup(qPrintable(QStringLiteral("Invalid URL: ") + uri.errorString())); + return qstrdup(qPrintable(QLatin1String("Invalid URL: ") + uri.errorString())); return qstrdup(uri.toEncoded().constData()); } diff --git a/src/testlib/qtest_gui.h b/src/testlib/qtest_gui.h index 5027aea732..d0d56e7bd0 100644 --- a/src/testlib/qtest_gui.h +++ b/src/testlib/qtest_gui.h @@ -58,6 +58,7 @@ #include <QtGui/qcolor.h> #include <QtGui/qpixmap.h> #include <QtGui/qimage.h> +#include <QtGui/qregion.h> #ifdef QT_WIDGETS_LIB #include <QtGui/qicon.h> @@ -82,6 +83,39 @@ template<> inline char *toString(const QColor &color) return qstrdup(color.name().toLocal8Bit().constData()); } +template<> inline char *toString(const QRegion ®ion) +{ + QByteArray result = "QRegion("; + if (region.isNull()) { + result += "null"; + } else if (region.isEmpty()) { + result += "empty"; + } else { + const QVector<QRect> &rects = region.rects(); + const int rectCount = rects.size(); + if (rectCount > 1) { + result += QByteArray::number(rectCount); + result += " rectangles, "; + } + for (int i = 0; i < rectCount; ++i) { + if (i) + result += ", "; + const QRect &r = rects.at(i); + result += QByteArray::number(r.width()); + result += 'x'; + result += QByteArray::number(r.height()); + if (r.x() >= 0) + result += '+'; + result += QByteArray::number(r.x()); + if (r.y() >= 0) + result += '+'; + result += QByteArray::number(r.y()); + } + } + result += ')'; + return qstrdup(result.constData()); +} + inline bool qCompare(QIcon const &t1, QIcon const &t2, const char *actual, const char *expected, const char *file, int line) { diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index b6c70fdd86..cfa7d1b8ca 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -958,7 +958,7 @@ bool TestMethods::invokeTest(int index, const char *data, WatchDog *watchDog) co QBenchmarkTestMethodData::current = &benchmarkData; const QByteArray &name = m_methods[index].name(); - QBenchmarkGlobalData::current->context.slotName = QLatin1String(name) + QStringLiteral("()"); + QBenchmarkGlobalData::current->context.slotName = QLatin1String(name) + QLatin1String("()"); char member[512]; QTestTable table; diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index 14d1cd46dc..befc280f4e 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -188,7 +188,8 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso token = keywords[state].ident; if (token == NOTOKEN) { - ++data; + if (*data) + ++data; // an error really, but let's ignore this input // to not confuse moc later. However in pre-processor // only mode let's continue. @@ -362,7 +363,6 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso ++data; continue; } - int nextindex = pp_keywords[state].next; int next = 0; if (*data == pp_keywords[state].defchar) @@ -381,7 +381,8 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso switch (token) { case NOTOKEN: - ++data; + if (*data) + ++data; break; case PP_DEFINE: mode = PrepareDefine; @@ -1252,7 +1253,6 @@ void Preprocessor::parseDefineArguments(Macro *m) error("missing ')' in macro argument list"); break; } else if (!is_identifier(l.constData(), l.length())) { - qDebug() << l; error("Unexpected character in macro argument list."); } } diff --git a/src/tools/uic/cpp/cppwriteincludes.cpp b/src/tools/uic/cpp/cppwriteincludes.cpp index e93e6bb26c..a99d6adf07 100644 --- a/src/tools/uic/cpp/cppwriteincludes.cpp +++ b/src/tools/uic/cpp/cppwriteincludes.cpp @@ -291,9 +291,8 @@ void WriteIncludes::writeHeaders(const OrderedSet &headers, bool global) const StringMap::const_iterator hit = m_oldHeaderToNewHeader.constFind(sit.key()); const bool mapped = hit != m_oldHeaderToNewHeader.constEnd(); const QString header = mapped ? hit.value() : sit.key(); - if (!header.trimmed().isEmpty()) { + if (!QStringRef(&header).trimmed().isEmpty()) m_output << "#include " << openingQuote << header << closingQuote << QLatin1Char('\n'); - } } } diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 8c8141f9e5..ade3c5db35 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -1255,14 +1255,14 @@ void WriteInitialization::writeProperties(const QString &varName, QString setFunction; if (stdset) { - setFunction = QLatin1String("->set"); - setFunction += propertyName.left(1).toUpper(); - setFunction += propertyName.mid(1); - setFunction += QLatin1Char('('); + setFunction = QLatin1String("->set") + + propertyName.left(1).toUpper() + + propertyName.midRef(1) + + QLatin1Char('('); } else { - setFunction = QLatin1String("->setProperty(\""); - setFunction += propertyName; - setFunction += QLatin1String("\", QVariant"); + setFunction += QLatin1String("->setProperty(\"") + + propertyName + + QLatin1String("\", QVariant"); if (p->kind() == DomProperty::Enum) setFunction += QLatin1String("::fromValue"); setFunction += QLatin1Char('('); @@ -1286,9 +1286,9 @@ void WriteInitialization::writeProperties(const QString &varName, if (stdset) propertyValue = fixString(p->elementCstring(), m_dindent); else { - propertyValue = QLatin1String("QByteArray("); - propertyValue += fixString(p->elementCstring(), m_dindent); - propertyValue += QLatin1Char(')'); + propertyValue = QLatin1String("QByteArray(") + + fixString(p->elementCstring(), m_dindent) + + QLatin1Char(')'); } } break; @@ -1304,11 +1304,8 @@ void WriteInitialization::writeProperties(const QString &varName, break; case DomProperty::Enum: propertyValue = p->elementEnum(); - if (!propertyValue.contains(QLatin1String("::"))) { - QString scope = className; - scope += QLatin1String("::"); - propertyValue.prepend(scope); - } + if (!propertyValue.contains(QLatin1String("::"))) + propertyValue = className + QLatin1String("::") + propertyValue; break; case DomProperty::Set: propertyValue = p->elementSet(); @@ -1898,31 +1895,29 @@ QString WriteInitialization::pixCall(const QString &t, const QString &text) cons if (m_option.extractImages) { const QString format = image->elementData()->attributeFormat(); const QString extension = format.left(format.indexOf(QLatin1Char('.'))).toLower(); - QString rc = QLatin1String("QPixmap(QString::fromUtf8(\":/"); - rc += m_generatedClass; - rc += QLatin1String("/images/"); - rc += text; - rc += QLatin1Char('.'); - rc += extension; - rc += QLatin1String("\"))"); - return rc; - } - QString rc = WriteIconInitialization::iconFromDataFunction(); - rc += QLatin1Char('('); - rc += text; - rc += QLatin1String("_ID)"); - return rc; + return QLatin1String("QPixmap(QString::fromUtf8(\":/") + + m_generatedClass + + QLatin1String("/images/") + + text + + QLatin1Char('.') + + extension + + QLatin1String("\"))"); + } + return WriteIconInitialization::iconFromDataFunction() + + QLatin1Char('(') + + text + + QLatin1String("_ID)"); } QString pixFunc = m_uic->pixmapFunction(); if (pixFunc.isEmpty()) pixFunc = QLatin1String("QString::fromUtf8"); - type += QLatin1Char('('); - type += pixFunc; - type += QLatin1Char('('); - type += fixString(text, m_dindent); - type += QLatin1String("))"); + type += QLatin1Char('(') + + pixFunc + + QLatin1Char('(') + + fixString(text, m_dindent) + + QLatin1String("))"); return type; } @@ -2316,23 +2311,20 @@ QString WriteInitialization::trCall(const QString &str, const QString &commentHi if (m_option.translateFunction.isEmpty()) { if (m_option.idBased) { - result = QLatin1String("qtTrId("); + result += QLatin1String("qtTrId("); } else { - result = QLatin1String("QApplication::translate(\""); - result += m_generatedClass; - result += QLatin1Char('"'); - result += QLatin1String(", "); + result += QLatin1String("QApplication::translate(\"") + + m_generatedClass + + QLatin1String("\", "); } } else { - result = m_option.translateFunction; - result += QLatin1Char('('); + result += m_option.translateFunction + QLatin1Char('('); } result += fixString(str, m_dindent); if (!m_option.idBased) { - result += QLatin1String(", "); - result += comment; + result += QLatin1String(", ") + comment; } result += QLatin1Char(')'); @@ -2473,10 +2465,8 @@ void WriteInitialization::acceptWidgetScripts(const DomScripts &widgetScripts, D QString script; for (const DomScript *domScript : qAsConst(scripts)) { const QString snippet = domScript->text(); - if (!snippet.isEmpty()) { - script += snippet.trimmed(); - script += QLatin1Char('\n'); - } + if (!snippet.isEmpty()) + script += QStringRef(&snippet).trimmed() + QLatin1Char('\n'); } if (script.isEmpty()) return; diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index 2f57fa08ee..95888924fb 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -824,12 +824,12 @@ QString QAccessibleTextWidget::attributes(int offset, int *startOffset, int *end AttributeFormatter attrs; QString family = charFormatFont.family(); if (!family.isEmpty()) { - family = family.replace('\\',QStringLiteral("\\\\")); - family = family.replace(':',QStringLiteral("\\:")); - family = family.replace(',',QStringLiteral("\\,")); - family = family.replace('=',QStringLiteral("\\=")); - family = family.replace(';',QStringLiteral("\\;")); - family = family.replace('\"',QStringLiteral("\\\"")); + family = family.replace('\\', QLatin1String("\\\\")); + family = family.replace(':', QLatin1String("\\:")); + family = family.replace(',', QLatin1String("\\,")); + family = family.replace('=', QLatin1String("\\=")); + family = family.replace(';', QLatin1String("\\;")); + family = family.replace('\"', QLatin1String("\\\"")); attrs["font-family"] = QString::fromLatin1("\"%1\"").arg(family); } diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 5424a4126a..11b3659990 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -87,7 +87,7 @@ QT_BEGIN_NAMESPACE about the underlying files and directories related to items in the model. Directories can be created and removed using mkdir(), rmdir(). - \note QFileSystemModel requires an instance of a GUI application. + \note QFileSystemModel requires an instance of \l QApplication. \section1 Example Usage diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp index 53db11d2d7..4c01219d87 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp @@ -1082,7 +1082,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP if (candidates.isEmpty()) after = (beforeSequence == adjacents.last() ? adjacents.first() : adjacents.last()); else - after = (candidates.last() == adjacents.last() ? adjacents.first() : adjacents.last()); + after = (candidates.constLast() == adjacents.last() ? adjacents.first() : adjacents.last()); // ### At this point we assumed that candidates will not contain 'after', this may not hold // when simplifying FLOATing anchors. @@ -1134,9 +1134,9 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP // One restriction we have is to not simplify half of an anchor and let the other half // unsimplified. So we remove center edges before and after the sequence. - const AnchorData *firstAnchor = g.edgeData(beforeSequence, candidates.first()); + const AnchorData *firstAnchor = g.edgeData(beforeSequence, candidates.constFirst()); if (firstAnchor->isCenterAnchor) { - beforeSequence = candidates.first(); + beforeSequence = candidates.constFirst(); candidates.remove(0); // If there's not candidates to be simplified, leave. @@ -1144,9 +1144,9 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP continue; } - const AnchorData *lastAnchor = g.edgeData(candidates.last(), afterSequence); + const AnchorData *lastAnchor = g.edgeData(candidates.constLast(), afterSequence); if (lastAnchor->isCenterAnchor) { - afterSequence = candidates.last(); + afterSequence = candidates.constLast(); candidates.remove(candidates.count() - 1); if (candidates.isEmpty()) diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index b00a950823..4b5e380f4b 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -2151,7 +2151,7 @@ bool QGraphicsItem::isBlockedByModalPanel(QGraphicsItem **blockingPanel) const if (!blockingPanel) blockingPanel = &dummy; - QGraphicsScenePrivate *scene_d = d_ptr->scene->d_func(); + const QGraphicsScenePrivate *scene_d = d_ptr->scene->d_func(); if (scene_d->modalPanels.isEmpty()) return false; diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index da5c2849ae..aa781e8f8b 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -940,7 +940,7 @@ void QGraphicsScenePrivate::grabMouse(QGraphicsItem *item, bool implicit) { // Append to list of mouse grabber items, and send a mouse grab event. if (mouseGrabberItems.contains(item)) { - if (mouseGrabberItems.last() == item) { + if (mouseGrabberItems.constLast() == item) { Q_ASSERT(!implicit); if (!lastMouseGrabberItemHasImplicitMouseGrab) { qWarning("QGraphicsItem::grabMouse: already a mouse grabber"); @@ -950,14 +950,14 @@ void QGraphicsScenePrivate::grabMouse(QGraphicsItem *item, bool implicit) } } else { qWarning("QGraphicsItem::grabMouse: already blocked by mouse grabber: %p", - mouseGrabberItems.last()); + mouseGrabberItems.constLast()); } return; } // Send ungrab event to the last grabber. if (!mouseGrabberItems.isEmpty()) { - QGraphicsItem *last = mouseGrabberItems.last(); + QGraphicsItem *last = mouseGrabberItems.constLast(); if (lastMouseGrabberItemHasImplicitMouseGrab) { // Implicit mouse grab is immediately lost. last->ungrabMouse(); @@ -987,12 +987,12 @@ void QGraphicsScenePrivate::ungrabMouse(QGraphicsItem *item, bool itemIsDying) return; } - if (item != mouseGrabberItems.last()) { + if (item != mouseGrabberItems.constLast()) { // Recursively ungrab the next mouse grabber until we reach this item // to ensure state consistency. ungrabMouse(mouseGrabberItems.at(index + 1), itemIsDying); } - if (!popupWidgets.isEmpty() && item == popupWidgets.last()) { + if (!popupWidgets.isEmpty() && item == popupWidgets.constLast()) { // If the item is a popup, go via removePopup to ensure state // consistency and that it gets hidden correctly - beware that // removePopup() reenters this function to continue removing the grab. @@ -1017,7 +1017,7 @@ void QGraphicsScenePrivate::ungrabMouse(QGraphicsItem *item, bool itemIsDying) // items get a GrabMouse event, but this is a rare case with a simple // implementation and it does ensure a consistent state. if (!itemIsDying && !mouseGrabberItems.isEmpty()) { - QGraphicsItem *last = mouseGrabberItems.last(); + QGraphicsItem *last = mouseGrabberItems.constLast(); QEvent event(QEvent::GrabMouse); sendEvent(last, &event); } @@ -1039,11 +1039,11 @@ void QGraphicsScenePrivate::clearMouseGrabber() void QGraphicsScenePrivate::grabKeyboard(QGraphicsItem *item) { if (keyboardGrabberItems.contains(item)) { - if (keyboardGrabberItems.last() == item) + if (keyboardGrabberItems.constLast() == item) qWarning("QGraphicsItem::grabKeyboard: already a keyboard grabber"); else qWarning("QGraphicsItem::grabKeyboard: already blocked by keyboard grabber: %p", - keyboardGrabberItems.last()); + keyboardGrabberItems.constLast()); return; } @@ -1051,7 +1051,7 @@ void QGraphicsScenePrivate::grabKeyboard(QGraphicsItem *item) if (!keyboardGrabberItems.isEmpty()) { // Just send ungrab event to current grabber. QEvent ungrabEvent(QEvent::UngrabKeyboard); - sendEvent(keyboardGrabberItems.last(), &ungrabEvent); + sendEvent(keyboardGrabberItems.constLast(), &ungrabEvent); } keyboardGrabberItems << item; @@ -1071,7 +1071,7 @@ void QGraphicsScenePrivate::ungrabKeyboard(QGraphicsItem *item, bool itemIsDying qWarning("QGraphicsItem::ungrabKeyboard: not a keyboard grabber"); return; } - if (item != keyboardGrabberItems.last()) { + if (item != keyboardGrabberItems.constLast()) { // Recursively ungrab the topmost keyboard grabber until we reach this // item to ensure state consistency. ungrabKeyboard(keyboardGrabberItems.at(index + 1), itemIsDying); @@ -1088,7 +1088,7 @@ void QGraphicsScenePrivate::ungrabKeyboard(QGraphicsItem *item, bool itemIsDying // Send notification about mouse regrab. if (!itemIsDying && !keyboardGrabberItems.isEmpty()) { - QGraphicsItem *last = keyboardGrabberItems.last(); + QGraphicsItem *last = keyboardGrabberItems.constLast(); QEvent event(QEvent::GrabKeyboard); sendEvent(last, &event); } @@ -1100,7 +1100,7 @@ void QGraphicsScenePrivate::ungrabKeyboard(QGraphicsItem *item, bool itemIsDying void QGraphicsScenePrivate::clearKeyboardGrabber() { if (!keyboardGrabberItems.isEmpty()) - ungrabKeyboard(keyboardGrabberItems.first()); + ungrabKeyboard(keyboardGrabberItems.constFirst()); } void QGraphicsScenePrivate::enableMouseTrackingOnViews() @@ -1142,8 +1142,8 @@ void QGraphicsScenePrivate::storeMouseButtonsForMouseGrabber(QGraphicsSceneMouse for (int i = 0x1; i <= 0x10; i <<= 1) { if (event->buttons() & i) { mouseGrabberButtonDownPos.insert(Qt::MouseButton(i), - mouseGrabberItems.last()->d_ptr->genericMapFromScene(event->scenePos(), - event->widget())); + mouseGrabberItems.constLast()->d_ptr->genericMapFromScene(event->scenePos(), + event->widget())); mouseGrabberButtonDownScenePos.insert(Qt::MouseButton(i), event->scenePos()); mouseGrabberButtonDownScreenPos.insert(Qt::MouseButton(i), event->screenPos()); } @@ -1308,7 +1308,7 @@ void QGraphicsScenePrivate::sendMouseEvent(QGraphicsSceneMouseEvent *mouseEvent) return; } - QGraphicsItem *item = mouseGrabberItems.last(); + QGraphicsItem *item = mouseGrabberItems.constLast(); if (item->isBlockedByModalPanel()) return; @@ -1335,7 +1335,7 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou // Deliver to any existing mouse grabber. if (!mouseGrabberItems.isEmpty()) { - if (mouseGrabberItems.last()->isBlockedByModalPanel()) + if (mouseGrabberItems.constLast()->isBlockedByModalPanel()) return; // The event is ignored by default, but we disregard the event's // accepted state after delivery; the mouse is grabbed, after all. @@ -1401,7 +1401,7 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou // Any item will do. if (sceneModality && cachedItemsUnderMouse.isEmpty()) - cachedItemsUnderMouse << modalPanels.first(); + cachedItemsUnderMouse << modalPanels.constFirst(); // Find a mouse grabber by sending mouse press events to all mouse grabber // candidates one at a time, until the event is accepted. It's accepted by @@ -1450,7 +1450,7 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou sendMouseEvent(mouseEvent); } - bool dontSendUngrabEvents = mouseGrabberItems.isEmpty() || mouseGrabberItems.last() != item; + bool dontSendUngrabEvents = mouseGrabberItems.isEmpty() || mouseGrabberItems.constLast() != item; if (disabled) { ungrabMouse(item, /* itemIsDying = */ dontSendUngrabEvents); break; @@ -2167,8 +2167,8 @@ QList<QGraphicsItem *> QGraphicsScene::collidingItems(const QGraphicsItem *item, */ QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position, const QTransform &deviceTransform) const { - QList<QGraphicsItem *> itemsAtPoint = items(position, Qt::IntersectsItemShape, - Qt::DescendingOrder, deviceTransform); + const QList<QGraphicsItem *> itemsAtPoint = items(position, Qt::IntersectsItemShape, + Qt::DescendingOrder, deviceTransform); return itemsAtPoint.isEmpty() ? 0 : itemsAtPoint.first(); } @@ -3771,7 +3771,7 @@ void QGraphicsScene::focusOutEvent(QFocusEvent *focusEvent) // Remove all popups when the scene loses focus. if (!d->popupWidgets.isEmpty()) - d->removePopup(d->popupWidgets.first()); + d->removePopup(d->popupWidgets.constFirst()); } /*! @@ -3868,7 +3868,7 @@ bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEv // Find the common ancestor item for the new topmost hoverItem and the // last item in the hoverItem list. - QGraphicsItem *commonAncestorItem = (item && !hoverItems.isEmpty()) ? item->commonAncestorItem(hoverItems.last()) : 0; + QGraphicsItem *commonAncestorItem = (item && !hoverItems.isEmpty()) ? item->commonAncestorItem(hoverItems.constLast()) : 0; while (commonAncestorItem && !itemAcceptsHoverEvents_helper(commonAncestorItem)) commonAncestorItem = commonAncestorItem->parentItem(); if (commonAncestorItem && commonAncestorItem->panel() != item->panel()) { @@ -3909,7 +3909,7 @@ bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEv // Generate a move event for the item itself if (item && !hoverItems.isEmpty() - && item == hoverItems.last()) { + && item == hoverItems.constLast()) { sendHoverEvent(QEvent::GraphicsSceneHoverMove, item, hoverEvent); return true; } @@ -3959,7 +3959,7 @@ void QGraphicsScene::keyPressEvent(QKeyEvent *keyEvent) // ### Merge this function with keyReleaseEvent; they are identical // ### (except this comment). Q_D(QGraphicsScene); - QGraphicsItem *item = !d->keyboardGrabberItems.isEmpty() ? d->keyboardGrabberItems.last() : 0; + QGraphicsItem *item = !d->keyboardGrabberItems.isEmpty() ? d->keyboardGrabberItems.constLast() : 0; if (!item) item = focusItem(); if (item) { @@ -3991,7 +3991,7 @@ void QGraphicsScene::keyReleaseEvent(QKeyEvent *keyEvent) // ### Merge this function with keyPressEvent; they are identical (except // ### this comment). Q_D(QGraphicsScene); - QGraphicsItem *item = !d->keyboardGrabberItems.isEmpty() ? d->keyboardGrabberItems.last() : 0; + QGraphicsItem *item = !d->keyboardGrabberItems.isEmpty() ? d->keyboardGrabberItems.constLast() : 0; if (!item) item = focusItem(); if (item) { @@ -4100,9 +4100,9 @@ void QGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) // Reset the mouse grabber when the last mouse button has been released. if (!mouseEvent->buttons()) { if (!d->mouseGrabberItems.isEmpty()) { - d->lastMouseGrabberItem = d->mouseGrabberItems.last(); + d->lastMouseGrabberItem = d->mouseGrabberItems.constLast(); if (d->lastMouseGrabberItemHasImplicitMouseGrab) - d->mouseGrabberItems.last()->ungrabMouse(); + d->mouseGrabberItems.constLast()->ungrabMouse(); } else { d->lastMouseGrabberItem = 0; } @@ -5902,7 +5902,7 @@ void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent) cachedItemsUnderMouse = itemsAtPosition(touchPoint.screenPos().toPoint(), touchPoint.scenePos(), static_cast<QWidget *>(sceneTouchEvent->target())); - item = cachedItemsUnderMouse.isEmpty() ? 0 : cachedItemsUnderMouse.first(); + item = cachedItemsUnderMouse.isEmpty() ? 0 : cachedItemsUnderMouse.constFirst(); } if (sceneTouchEvent->device()->type() == QTouchDevice::TouchScreen) { @@ -6013,7 +6013,7 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve { Q_Q(QGraphicsScene); - if (cachedItemsUnderMouse.isEmpty() || cachedItemsUnderMouse.first() != origin) { + if (cachedItemsUnderMouse.isEmpty() || cachedItemsUnderMouse.constFirst() != origin) { const QTouchEvent::TouchPoint &firstTouchPoint = touchEvent->touchPoints().first(); cachedItemsUnderMouse = itemsAtPosition(firstTouchPoint.screenPos().toPoint(), firstTouchPoint.scenePos(), @@ -6129,7 +6129,7 @@ void QGraphicsScenePrivate::enterModal(QGraphicsItem *panel, QGraphicsItem::Pane } if (!mouseGrabberItems.isEmpty() && lastMouseGrabberItemHasImplicitMouseGrab) { - QGraphicsItem *item = mouseGrabberItems.last(); + QGraphicsItem *item = mouseGrabberItems.constLast(); if (item->isBlockedByModalPanel()) ungrabMouse(item, /*itemIsDying =*/ false); } diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index 44e80ebeb9..3f7d2d1cd1 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -2375,7 +2375,7 @@ QGraphicsItem *QGraphicsView::itemAt(const QPoint &pos) const Q_D(const QGraphicsView); if (!d->scene) return 0; - QList<QGraphicsItem *> itemsAtPos = items(pos); + const QList<QGraphicsItem *> itemsAtPos = items(pos); return itemsAtPos.isEmpty() ? 0 : itemsAtPos.first(); } @@ -2860,7 +2860,7 @@ bool QGraphicsView::viewportEvent(QEvent *event) // the mouse grab. // Remove all popups when the scene loses focus. if (!d->scene->d_func()->popupWidgets.isEmpty()) - d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.first()); + d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.constFirst()); QApplication::sendEvent(d->scene, event); break; case QEvent::Show: @@ -2884,7 +2884,7 @@ bool QGraphicsView::viewportEvent(QEvent *event) || (QApplication::activeModalWidget() && QApplication::activeModalWidget() != window()) || (QApplication::activeWindow() != window())) { if (!d->scene->d_func()->popupWidgets.isEmpty()) - d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.first()); + d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.constFirst()); } d->useLastMouseEvent = false; // a hack to pass a viewport pointer to the scene inside the leave event diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp index 26173b5e92..6c7c914bc0 100644 --- a/src/widgets/itemviews/qcolumnview.cpp +++ b/src/widgets/itemviews/qcolumnview.cpp @@ -412,9 +412,9 @@ void QColumnViewPrivate::updateScrollbars() // find the total horizontal length of the laid out columns int horizontalLength = 0; if (!columns.isEmpty()) { - horizontalLength = (columns.last()->x() + columns.last()->width()) - columns.first()->x(); + horizontalLength = (columns.constLast()->x() + columns.constLast()->width()) - columns.constFirst()->x(); if (horizontalLength <= 0) // reverse mode - horizontalLength = (columns.first()->x() + columns.first()->width()) - columns.last()->x(); + horizontalLength = (columns.constFirst()->x() + columns.constFirst()->width()) - columns.constLast()->x(); } QSize viewportSize = viewport->size(); @@ -629,7 +629,7 @@ void QColumnViewPrivate::closeColumns(const QModelIndex &parent, bool build) while (!dirsToAppend.isEmpty()) { QAbstractItemView *newView = createColumn(dirsToAppend.takeLast(), true); if (!dirsToAppend.isEmpty()) - newView->setCurrentIndex(dirsToAppend.last()); + newView->setCurrentIndex(dirsToAppend.constLast()); } if (build && !alreadyExists) @@ -713,8 +713,8 @@ QAbstractItemView *QColumnViewPrivate::createColumn(const QModelIndex &index, bo columnSizes.resize(qMax(columnSizes.count(), columns.count() + 1)); columnSizes[columns.count()] = initialWidth; } - if (!columns.isEmpty() && columns.last()->isHidden()) - columns.last()->setVisible(true); + if (!columns.isEmpty() && columns.constLast()->isHidden()) + columns.constLast()->setVisible(true); columns.append(view); doLayout(); @@ -835,7 +835,7 @@ void QColumnViewPrivate::setPreviewWidget(QWidget *widget) { Q_Q(QColumnView); if (previewColumn) { - if (!columns.isEmpty() && columns.last() == previewColumn) + if (!columns.isEmpty() && columns.constLast() == previewColumn) columns.removeLast(); previewColumn->deleteLater(); } @@ -1003,11 +1003,11 @@ void QColumnViewPrivate::_q_changeCurrentColumn() parentColumn->setCurrentIndex(current.parent()); } - if (columns.last()->isHidden()) { - columns.last()->setVisible(true); + if (columns.constLast()->isHidden()) { + columns.constLast()->setVisible(true); } - if (columns.last()->selectionModel()) - columns.last()->selectionModel()->clear(); + if (columns.constLast()->selectionModel()) + columns.constLast()->selectionModel()->clear(); updateScrollbars(); } diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index 315d2503a4..95e6a1840d 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -212,7 +212,7 @@ void QDirModelPrivate::invalidate() Directories can be created and removed using mkdir(), rmdir(), and the model will be automatically updated to take the changes into account. - \note QDirModel requires an instance of a GUI application. + \note QDirModel requires an instance of \l QApplication. \sa nameFilters(), setFilter(), filter(), QListView, QTreeView, QFileSystemModel, {Dir View Example}, {Model Classes} @@ -885,7 +885,7 @@ QModelIndex QDirModel::index(const QString &path, int column) const #if defined(Q_OS_WIN) if (absolutePath.startsWith(QLatin1String("//"))) { // UNC path - QString host = pathElements.first(); + QString host = pathElements.constFirst(); int r = 0; for (; r < d->root.children.count(); ++r) if (d->root.children.at(r).info.fileName() == host) diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 3303aac6ed..0788e0287a 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -2396,9 +2396,9 @@ QPoint QListModeViewBase::initStaticLayout(const QListViewLayoutInfo &info) } else if (info.wrap) { if (info.flow == QListView::LeftToRight) { x = batchSavedPosition; - y = segmentPositions.last(); + y = segmentPositions.constLast(); } else { // flow == QListView::TopToBottom - x = segmentPositions.last(); + x = segmentPositions.constLast(); y = batchSavedPosition; } } else { // not first and not wrap @@ -2613,7 +2613,7 @@ int QListModeViewBase::perItemScrollingPageSteps(int length, int bounds, bool wr int steps = positions.count() - 1; int max = qMax(length, bounds); int min = qMin(length, bounds); - int pos = min - (max - positions.last()); + int pos = min - (max - positions.constLast()); while (pos >= 0 && steps > 0) { pos -= (positions.at(steps) - positions.at(steps - 1)); diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index ca1e8f13ee..cfe68d6b6a 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -2356,10 +2356,10 @@ void QTreeView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFl return; } if (!topLeft.isValid() && !d->viewItems.isEmpty()) - topLeft = d->viewItems.first().index; + topLeft = d->viewItems.constFirst().index; if (!bottomRight.isValid() && !d->viewItems.isEmpty()) { const int column = d->header->logicalIndex(d->header->count() - 1); - const QModelIndex index = d->viewItems.last().index; + const QModelIndex index = d->viewItems.constLast().index; bottomRight = index.sibling(index.row(), column); } @@ -2667,9 +2667,9 @@ void QTreeView::selectAll() SelectionMode mode = d->selectionMode; d->executePostedLayout(); //make sure we lay out the items if (mode != SingleSelection && mode != NoSelection && !d->viewItems.isEmpty()) { - const QModelIndex &idx = d->viewItems.last().index; + const QModelIndex &idx = d->viewItems.constLast().index; QModelIndex lastItemIndex = idx.sibling(idx.row(), d->model->columnCount(idx.parent()) - 1); - d->select(d->viewItems.first().index, lastItemIndex, + d->select(d->viewItems.constFirst().index, lastItemIndex, QItemSelectionModel::ClearAndSelect |QItemSelectionModel::Rows); } diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index ce5e58642c..0bc1c029fe 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -65,13 +65,9 @@ public: T &operator()(int r, int c) { return m_storage[r * NumColumns + c]; } int rowCount() const { return m_storage.size() / NumColumns; } - void addRow(const T &value); void insertRow(int r, const T &value); void removeRow(int r); - bool find(const T &value, int *rowPtr, int *colPtr) const ; - int count(const T &value) const { return m_storage.count(value); } - // Hmmpf.. Some things are faster that way. const Storage &storage() const { return m_storage; } @@ -82,13 +78,6 @@ private: }; template <class T, int NumColumns> -void FixedColumnMatrix<T, NumColumns>::addRow(const T &value) -{ - for (int i = 0; i < NumColumns; ++i) - m_storage.append(value); -} - -template <class T, int NumColumns> void FixedColumnMatrix<T, NumColumns>::insertRow(int r, const T &value) { typename Storage::iterator it = m_storage.begin(); @@ -103,16 +92,6 @@ void FixedColumnMatrix<T, NumColumns>::removeRow(int r) } template <class T, int NumColumns> -bool FixedColumnMatrix<T, NumColumns>::find(const T &value, int *rowPtr, int *colPtr) const -{ - const int idx = m_storage.indexOf(value); - if (idx == -1) - return false; - storageIndexToPosition(idx, rowPtr, colPtr); - return true; -} - -template <class T, int NumColumns> void FixedColumnMatrix<T, NumColumns>::storageIndexToPosition(int idx, int *rowPtr, int *colPtr) { *rowPtr = idx / NumColumns; diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index a71089793c..25874e9bcc 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -565,7 +565,7 @@ void QWidget::setAutoFillBackground(bool enabled) Composite widgets can also be created by subclassing a standard widget, such as QWidget or QFrame, and adding the necessary layout and child - widgets in the constructor of the subclass. Many of the \l{Qt Examples} + widgets in the constructor of the subclass. Many of the \l{Qt Widgets Examples} {examples provided with Qt} use this approach, and it is also covered in the Qt \l{Tutorials}. diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index 242e62572b..81fbe49a43 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -1012,9 +1012,11 @@ static QPlatformTextureList *widgetTexturesFor(QWidget *tlw, QWidget *widget) // The Windows compositor handles fullscreen OpenGL window specially. Besides // having trouble with popups, it also has issues with flip-flopping between // OpenGL-based and normal flushing. Therefore, stick with GL for fullscreen -// windows. (QTBUG-53515) +// windows (QTBUG-53515). Similary, translucent windows should not switch to +// layered native windows (QTBUG-54734). #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE) || tlw->windowState().testFlag(Qt::WindowFullScreen) + || tlw->testAttribute(Qt::WA_TranslucentBackground) #endif ) { diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 6b9e5577a4..36975c5877 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -5248,6 +5248,13 @@ static QPixmap cachedPixmapFromXPM(const char * const *xpm) return result; } +#ifndef QT_NO_IMAGEFORMAT_PNG +static inline QString clearText16IconPath() +{ + return QStringLiteral(":/qt-project.org/styles/commonstyle/images/cleartext-16.png"); +} +#endif // !QT_NO_IMAGEFORMAT_PNG + static QIcon clearTextIcon(bool rtl) { const QString directionalThemeName = rtl @@ -5260,7 +5267,7 @@ static QIcon clearTextIcon(bool rtl) QIcon icon; #ifndef QT_NO_IMAGEFORMAT_PNG - QPixmap clearText16(QStringLiteral(":/qt-project.org/styles/commonstyle/images/cleartext-16.png")); + QPixmap clearText16(clearText16IconPath()); Q_ASSERT(!clearText16.size().isEmpty()); icon.addPixmap(clearText16); QPixmap clearText32(QStringLiteral(":/qt-project.org/styles/commonstyle/images/cleartext-32.png")); @@ -5575,6 +5582,8 @@ QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *opti return QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/media-volume-16.png")); case SP_MediaVolumeMuted: return QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/media-volume-muted-16.png")); + case SP_LineEditClearButton: + return QPixmap(clearText16IconPath()); #endif // QT_NO_IMAGEFORMAT_PNG default: break; diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 56531b10de..d28bd644c6 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -2933,7 +2933,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w QImage img; QSize pixmapSize = opt->rect.size(); - if (pixmapSize.isValid()) { + if (!pixmapSize.isEmpty()) { QPixmap pix(pixmapSize); pix.fill(QColor(fillR, fillG, fillB)); QPainter pix_paint(&pix); diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index d72a898ee9..93bc00f662 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -733,7 +733,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value State_None Indicates that the widget does not have a state. \value State_Active Indicates that the widget is active. - \value State_AutoRaise Used to indicate if auto-raise appearance should be usd on a tool button. + \value State_AutoRaise Used to indicate if auto-raise appearance should be used on a tool button. \value State_Children Used to indicate if an item view branch has children. \value State_DownArrow Used to indicate if a down arrow should be visible on the widget. \value State_Editing Used to indicate if an editor is opened on the widget. diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index 5425644b41..3006f0c9ce 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -1044,6 +1044,10 @@ void QCompleter::setModel(QAbstractItemModel *model) { Q_D(QCompleter); QAbstractItemModel *oldModel = d->proxy->sourceModel(); +#ifndef QT_NO_FILESYSTEMMODEL + if (qobject_cast<const QFileSystemModel *>(oldModel)) + setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel +#endif d->proxy->setSourceModel(model); if (d->popup) setPopup(d->popup); // set the model and make new connections diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index 774f5a708d..5778d16456 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -757,8 +757,7 @@ bool QAbstractSpinBox::event(QEvent *event) case QEvent::HoverEnter: case QEvent::HoverLeave: case QEvent::HoverMove: - if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event)) - d->updateHoverControl(he->pos()); + d->updateHoverControl(static_cast<const QHoverEvent *>(event)->pos()); break; case QEvent::ShortcutOverride: if (d->edit->event(event)) diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 51e23ca7f9..af178ce8f5 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -2108,9 +2108,9 @@ void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi) if (lineEdit) { const QString newText = itemText(normalized); if (lineEdit->text() != newText) { - lineEdit->setText(newText); + lineEdit->setText(newText); // may cause lineEdit -> nullptr (QTBUG-54191) #ifndef QT_NO_COMPLETER - if (lineEdit->completer()) + if (lineEdit && lineEdit->completer()) lineEdit->completer()->setCompletionPrefix(newText); #endif } diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index cfba2cc87f..b168c98410 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -52,6 +52,8 @@ #include <qset.h> #include <qstyle.h> +#include <algorithm> + #ifndef QT_NO_DATETIMEEDIT //#define QDATETIMEEDIT_QDTEDEBUG @@ -246,9 +248,10 @@ void QDateTimeEdit::setDateTime(const QDateTime &datetime) Q_D(QDateTimeEdit); if (datetime.isValid()) { d->clearCache(); + const QDate date = datetime.date(); if (!(d->sections & DateSections_Mask)) - setDateRange(datetime.date(), datetime.date()); - d->setValue(QDateTime(datetime.date(), datetime.time(), d->spec), EmitIfChanged); + setDateRange(date, date); + d->setValue(QDateTime(date, datetime.time(), d->spec), EmitIfChanged); } } @@ -861,14 +864,6 @@ QString QDateTimeEdit::displayFormat() const return isRightToLeft() ? d->unreversedFormat : d->displayFormat; } -template<typename C> static inline C reverse(const C &l) -{ - C ret; - for (int i=l.size() - 1; i>=0; --i) - ret.append(l.at(i)); - return ret; -} - void QDateTimeEdit::setDisplayFormat(const QString &format) { Q_D(QDateTimeEdit); @@ -882,8 +877,8 @@ void QDateTimeEdit::setDisplayFormat(const QString &format) d->displayFormat += d->sectionNode(i).format(); } d->displayFormat += d->separators.at(0); - d->separators = reverse(d->separators); - d->sectionNodes = reverse(d->sectionNodes); + std::reverse(d->separators.begin(), d->separators.end()); + std::reverse(d->sectionNodes.begin(), d->sectionNodes.end()); } d->formatExplicitlySet = true; @@ -1776,15 +1771,18 @@ void QDateTimeEditPrivate::setSelected(int sectionIndex, bool forward) int QDateTimeEditPrivate::sectionAt(int pos) const { - if (pos < separators.first().size()) { + if (pos < separators.first().size()) return (pos == 0 ? FirstSectionIndex : NoSectionIndex); - } else if (displayText().size() - pos < separators.last().size() + 1) { + + const QString text = displayText(); + const int textSize = text.size(); + if (textSize - pos < separators.last().size() + 1) { if (separators.last().size() == 0) { return sectionNodes.count() - 1; } - return (pos == displayText().size() ? LastSectionIndex : NoSectionIndex); + return (pos == textSize ? LastSectionIndex : NoSectionIndex); } - updateCache(value, displayText()); + updateCache(value, text); for (int i=0; i<sectionNodes.size(); ++i) { const int tmp = sectionPos(i); @@ -1805,12 +1803,14 @@ int QDateTimeEditPrivate::sectionAt(int pos) const int QDateTimeEditPrivate::closestSection(int pos, bool forward) const { Q_ASSERT(pos >= 0); - if (pos < separators.first().size()) { + if (pos < separators.first().size()) return forward ? 0 : FirstSectionIndex; - } else if (displayText().size() - pos < separators.last().size() + 1) { + + const QString text = displayText(); + if (text.size() - pos < separators.last().size() + 1) return forward ? LastSectionIndex : sectionNodes.size() - 1; - } - updateCache(value, displayText()); + + updateCache(value, text); for (int i=0; i<sectionNodes.size(); ++i) { const int tmp = sectionPos(sectionNodes.at(i)); if (pos < tmp + sectionSize(i)) { diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index 55e774024a..b347e93807 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -3170,7 +3170,7 @@ void QDockAreaLayout::splitDockWidget(QDockWidget *after, QDockWidget *dockWidget, Qt::Orientation orientation) { - QList<int> path = indexOf(after); + const QList<int> path = indexOf(after); if (path.isEmpty()) return; diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index d2fa9a7c06..9e95d086bd 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -811,7 +811,8 @@ void QDockWidgetPrivate::endDrag(bool abort) } else { setResizerActive(false); } - undockedGeometry = q->geometry(); + if (q->isFloating()) // Might not be floating when dragging a QDockWidgetGroupWindow + undockedGeometry = q->geometry(); q->activateWindow(); } else { // The tab was not plugged back in the QMainWindow but the QDockWidget cannot diff --git a/src/widgets/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp index 1d736c8e96..9bd33409ae 100644 --- a/src/widgets/widgets/qfontcombobox.cpp +++ b/src/widgets/widgets/qfontcombobox.cpp @@ -162,7 +162,7 @@ static QFontDatabase::WritingSystem writingSystemForFont(const QFont &font, bool return QFontDatabase::TraditionalChinese; } - system = writingSystems.last(); + system = writingSystems.constLast(); if (!*hasLatin) { // we need to show something diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 5dfa439b2e..c31e9750bf 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -1729,10 +1729,20 @@ QMenu *QMainWindow::createPopupMenu() menu = new QMenu(this); for (int i = 0; i < dockwidgets.size(); ++i) { QDockWidget *dockWidget = dockwidgets.at(i); - if (dockWidget->parentWidget() == this - && !d->layout->layoutState.dockAreaLayout.indexOf(dockWidget).isEmpty()) { - menu->addAction(dockwidgets.at(i)->toggleViewAction()); + // filter to find out if we own this QDockWidget + if (dockWidget->parentWidget() == this) { + if (d->layout->layoutState.dockAreaLayout.indexOf(dockWidget).isEmpty()) + continue; + } else if (QDockWidgetGroupWindow *dwgw = + qobject_cast<QDockWidgetGroupWindow *>(dockWidget->parentWidget())) { + if (dwgw->parentWidget() != this) + continue; + if (dwgw->layoutInfo()->indexOf(dockWidget).isEmpty()) + continue; + } else { + continue; } + menu->addAction(dockwidgets.at(i)->toggleViewAction()); } menu->addSeparator(); } diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index ee6da73302..c5b08387a3 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -2384,13 +2384,10 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) QWidget *w = qobject_cast<QWidget*>(c); if (!w) continue; - if (w == widget) - continue; - if (!w->isTopLevel() || !w->isVisible() || w->isMinimized()) - continue; if (!qobject_cast<QDockWidget*>(w) && !qobject_cast<QDockWidgetGroupWindow *>(w)) continue; - candidates << w; + if (w != widget && w->isTopLevel() && w->isVisible() && !w->isMinimized()) + candidates << w; if (QDockWidgetGroupWindow *group = qobject_cast<QDockWidgetGroupWindow *>(w)) { // Sometimes, there are floating QDockWidget that have a QDockWidgetGroupWindow as a parent. foreach (QObject *c, group->children()) { diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp index a5c096c3a8..0daa624ae8 100644 --- a/src/widgets/widgets/qspinbox.cpp +++ b/src/widgets/widgets/qspinbox.cpp @@ -479,9 +479,8 @@ QString QSpinBox::textFromValue(int value) const QString str; if (d->displayIntegerBase != 10) { - str = QString::number(qAbs(value), d->displayIntegerBase); - if (value < 0) - str.prepend('-'); + const QLatin1String prefix = value < 0 ? QLatin1String("-") : QLatin1String(); + str = prefix + QString::number(qAbs(value), d->displayIntegerBase); } else { str = locale().toString(value); if (!d->showGroupSeparator && (qAbs(value) >= 1000 || value == INT_MIN)) { diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 77b5a4830b..d5ecb150a8 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -2641,8 +2641,8 @@ void QWidgetTextControl::insertFromMimeData(const QMimeData *source) #ifndef QT_NO_TEXTHTMLPARSER if (source->hasFormat(QLatin1String("application/x-qrichtext")) && d->acceptRichText) { // x-qrichtext is always UTF-8 (taken from Qt3 since we don't use it anymore). - QString richtext = QString::fromUtf8(source->data(QLatin1String("application/x-qrichtext"))); - richtext.prepend(QLatin1String("<meta name=\"qrichtext\" content=\"1\" />")); + const QString richtext = QLatin1String("<meta name=\"qrichtext\" content=\"1\" />") + + QString::fromUtf8(source->data(QLatin1String("application/x-qrichtext"))); fragment = QTextDocumentFragment::fromHtml(richtext, d->doc); hasData = true; } else if (source->hasHtml() && d->acceptRichText) { diff --git a/src/winmain/qtmain_winrt.cpp b/src/winmain/qtmain_winrt.cpp index 1ac0a98cb1..83a7dc800c 100644 --- a/src/winmain/qtmain_winrt.cpp +++ b/src/winmain/qtmain_winrt.cpp @@ -307,7 +307,7 @@ private: if (develMode) { // Write a PID file to help runner const QString pidFileName = QDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation)) - .absoluteFilePath(QString::number(uint(GetCurrentProcessId())) + QStringLiteral(".pid")); + .absoluteFilePath(QString::asprintf("%u.pid", uint(GetCurrentProcessId()))); CREATEFILE2_EXTENDED_PARAMETERS params = { sizeof(CREATEFILE2_EXTENDED_PARAMETERS), FILE_ATTRIBUTE_NORMAL diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp index d4c8519d67..1724076b84 100644 --- a/src/xml/sax/qxml.cpp +++ b/src/xml/sax/qxml.cpp @@ -1295,7 +1295,7 @@ static QString extractEncodingDecl(const QString &text, bool *needMoreText) *needMoreText = false; int l = text.length(); - QString snip = QString::fromLatin1("<?xml").left(l); + const QLatin1String snip("<?xml", std::min(l, 5)); if (l > 0 && !text.startsWith(snip)) return QString(); |