From d7b0581c1c2ef60c08d238dae39298af6904918f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 12 Feb 2014 21:51:58 -0800 Subject: Make sure that the compiler is strict in QtCore ICC defaults to "fast math" mode, which allows it to do non-compliant operations that may or may not result in unexpected values. Generally, it's ok, but apparently the code in qlocale_tools.cpp is too complex, so we're not taking chances. I can't rule out an issue in the code, though. Task-number: QTBUG-36795 Change-Id: Ica5cb77fb3a65d22ae8ad22e13b4ba78f1b5dadf Reviewed-by: Lars Knoll --- src/corelib/tools/tools.pri | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index cac596f0bc..52bb987506 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -1,5 +1,7 @@ # Qt tools module +intel_icc: QMAKE_CXXFLAGS += -fp-model strict + HEADERS += \ tools/qalgorithms.h \ tools/qarraydata.h \ -- cgit v1.2.3 From 121e71293500e08148d3c2ce31a8e9b618943cba Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sat, 15 Feb 2014 01:17:27 +0100 Subject: QHash: use prime numbers when rebucketing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QHash uses an array representing the difference between 2^i and the next prime; when growing, it calculates 2^x + array[x] (with `x' representing the "hash table size in bits"). For some reason lost in history the differences are actually wrong and the calculation above leads to using composite numbers. Hence: use the right sequence and always produce primes. The right sequence is actually A092131 from OEIS: http://oeis.org/A092131 Note that the sequence starts at A(1), but we need A(0) too. Also we truncate the sequence to when growing too much, just like the old code did, and use powers of two in that case instead. Task-number: QTBUG-36866 Change-Id: Id2e3fc9cb567c0fdca305dee38f480e17639ca04 Reviewed-by: Morten Johan Sørvig Reviewed-by: Jędrzej Nowacki --- src/corelib/tools/qhash.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 5320ea1fbf..a5d14a3535 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -337,20 +337,29 @@ uint qt_hash(const QStringRef &key) Q_DECL_NOTHROW } /* - The prime_deltas array is a table of selected prime values, even - though it doesn't look like one. The primes we are using are 1, - 2, 5, 11, 17, 37, 67, 131, 257, ..., i.e. primes in the immediate - surrounding of a power of two. + The prime_deltas array contains the difference between a power + of two and the next prime number: - The primeForNumBits() function returns the prime associated to a - power of two. For example, primeForNumBits(8) returns 257. + prime_deltas[i] = nextprime(2^i) - 2^i + + Basically, it's sequence A092131 from OEIS, assuming: + - nextprime(1) = 1 + - nextprime(2) = 2 + and + - left-extending it for the offset 0 (A092131 starts at i=1) + - stopping the sequence at i = 28 (the table is big enough...) */ static const uchar prime_deltas[] = { - 0, 0, 1, 3, 1, 5, 3, 3, 1, 9, 7, 5, 3, 9, 25, 3, - 1, 21, 3, 21, 7, 15, 9, 5, 3, 29, 15, 0, 0, 0, 0, 0 + 0, 0, 1, 3, 1, 5, 3, 3, 1, 9, 7, 5, 3, 17, 27, 3, + 1, 29, 3, 21, 7, 17, 15, 9, 43, 35, 15, 0, 0, 0, 0, 0 }; +/* + The primeForNumBits() function returns the prime associated to a + power of two. For example, primeForNumBits(8) returns 257. +*/ + static inline int primeForNumBits(int numBits) { return (1 << numBits) + prime_deltas[numBits]; -- cgit v1.2.3 From ac127a8c09ab91d15adb1cb9d44123f3e0185e00 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Tue, 18 Feb 2014 12:08:19 +0100 Subject: Blackberry: Fix QFileSystemEngine::tempPath() Fall back to /var/tmp instead of /tmp if neither TMPDIR nor TEMP are set. /tmp is not a true filesystem on BB10 but rather a symbolic link to /dev/shmem For more info see http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/user_guide/fsystems.html#RAM Change-Id: Ie690ed74ffd81b52ef4623458c3ff88629aee00a Reviewed-by: Thiago Macieira --- src/corelib/io/qfilesystemengine_unix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 2327c11c69..ea3a3ca13d 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -720,8 +720,8 @@ QString QFileSystemEngine::tempPath() temp = QFile::decodeName(qgetenv("TMPDIR")); if (temp.isEmpty()) { - qWarning("Neither the TEMP nor the TMPDIR environment variable is set, falling back to /tmp."); - temp = QLatin1String("/tmp"); + qWarning("Neither the TEMP nor the TMPDIR environment variable is set, falling back to /var/tmp."); + temp = QLatin1String("/var/tmp"); } return QDir::cleanPath(temp); #else -- cgit v1.2.3 From 22f0dc4f893581f53d1f030587ae535128afccf8 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 10 Jan 2014 13:19:55 +0100 Subject: Loosen checks for Q_COMPILER_VARIADIC_MACROS So far we did bind the definition of Q_COMPILER_VARIADIC_MACROS to C++11 (so gcc, clang will not define it in default gnu++98 standard). However, variadic macros are a feature of the gcc preprocessor since version 2.97, and are enabled in the default configurations on gcc, clang, icc. This might cause warnings and errors though if one enables additional warnings in gcc, clang (e.g. by -pedantic). Anyhow, as a precedent qglobal.h already relies on 'long long' ... The warning can be disabled by adding '-Wno-variadic-macros'. [ChangeLog][Compiler Specific Changes] Variadic macros are now enabled more liberally for gcc, clang, icc. If you have warnings (because you e.g. compile with -pedantic), disable them by -Wno-variadic-macros. Change-Id: Ie979b85809508ad70cab75e6981f20496429f463 Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 70f45345c6..1eb442aa5f 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -489,6 +489,7 @@ #ifdef Q_CC_INTEL # define Q_COMPILER_RESTRICTED_VLA +# define Q_COMPILER_VARIADIC_MACROS // C++11 feature supported as an extension in other modes, too # if __INTEL_COMPILER < 1200 # define Q_NO_TEMPLATE_FRIENDS # endif @@ -498,7 +499,6 @@ # define Q_COMPILER_BINARY_LITERALS # endif # if __cplusplus >= 201103L -# define Q_COMPILER_VARIADIC_MACROS # if __INTEL_COMPILER >= 1200 # define Q_COMPILER_AUTO_TYPE # define Q_COMPILER_CLASS_ENUM @@ -560,6 +560,15 @@ # define Q_COMPILER_BINARY_LITERALS # endif +// Variadic macros are supported for gnu++98, c++11, c99 ... since 2.9 +# if ((__clang_major__ * 100) + __clang_minor__) >= 209 +# if !defined(__STRICT_ANSI__) || defined(__GXX_EXPERIMENTAL_CXX0X__) \ + || (defined(__cplusplus) && (__cplusplus >= 201103L)) \ + || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) +# define Q_COMPILER_VARIADIC_MACROS +# endif +# endif + /* C++11 features, see http://clang.llvm.org/cxx_status.html */ # if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) /* Detect C++ features using __has_feature(), see http://clang.llvm.org/docs/LanguageExtensions.html#cxx11 */ @@ -656,7 +665,6 @@ /* Features that have no __has_feature() check */ # if ((__clang_major__ * 100) + __clang_minor__) >= 209 /* since clang 2.9 */ # define Q_COMPILER_EXTERN_TEMPLATES -# define Q_COMPILER_VARIADIC_MACROS # endif # endif @@ -693,13 +701,18 @@ // GCC supports binary literals in C, C++98 and C++11 modes # define Q_COMPILER_BINARY_LITERALS # endif +# if !defined(__STRICT_ANSI__) || defined(__GXX_EXPERIMENTAL_CXX0X__) \ + || (defined(__cplusplus) && (__cplusplus >= 201103L)) \ + || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) + // Variadic macros are supported for gnu++98, c++11, C99 ... since forever (gcc 2.97) +# define Q_COMPILER_VARIADIC_MACROS +# endif # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403 /* C++11 features supported in GCC 4.3: */ # define Q_COMPILER_DECLTYPE # define Q_COMPILER_RVALUE_REFS # define Q_COMPILER_STATIC_ASSERT -# define Q_COMPILER_VARIADIC_MACROS # endif # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 /* C++11 features supported in GCC 4.4: */ -- cgit v1.2.3 From db352e1e97a0eb38cb5756f264b3162efeb86c02 Mon Sep 17 00:00:00 2001 From: John Layt Date: Fri, 14 Feb 2014 01:45:37 +0100 Subject: QRect - Move QMargins operators Move QMargins operators to QRect file, change include sequence. Change-Id: I0e2ad91859ae65eb67c6ece50f8e4037516b463e Reviewed-by: Lars Knoll Reviewed-by: Friedemann Kleint --- src/corelib/tools/qmargins.cpp | 59 ------------------------------------------ src/corelib/tools/qmargins.h | 37 +------------------------- src/corelib/tools/qrect.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++ src/corelib/tools/qrect.h | 43 +++++++++++++++++++++++++++--- 4 files changed, 99 insertions(+), 99 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp index c5bd8468bc..06f41a6737 100644 --- a/src/corelib/tools/qmargins.cpp +++ b/src/corelib/tools/qmargins.cpp @@ -157,65 +157,6 @@ QT_BEGIN_NAMESPACE Returns \c true if \a m1 and \a m2 are different; otherwise returns \c false. */ -/*! - \fn QRect operator+(const QRect &rectangle, const QMargins &margins) - \relates QRect - - Returns the \a rectangle grown by the \a margins. - - \since 5.1 -*/ - -/*! - \fn QRect operator+(const QMargins &margins, const QRect &rectangle) - \relates QRect - \overload - - Returns the \a rectangle grown by the \a margins. - - \since 5.1 -*/ - -/*! - \fn QRect QRect::marginsAdded(const QMargins &margins) const - - Returns a rectangle grown by the \a margins. - - \sa operator+=(), marginsRemoved(), operator-=() - - \since 5.1 -*/ - -/*! - \fn QRect QRect::operator+=(const QMargins &margins) const - - Adds the \a margins to the rectangle, growing it. - - \sa marginsAdded(), marginsRemoved(), operator-=() - - \since 5.1 -*/ - -/*! - \fn QRect QRect::marginsRemoved(const QMargins &margins) const - - Removes the \a margins from the rectangle, shrinking it. - - \sa marginsAdded(), operator+=(), operator-=() - - \since 5.1 -*/ - -/*! - \fn QRect QRect::operator -=(const QMargins &margins) const - - Returns a rectangle shrunk by the \a margins. - - \sa marginsRemoved(), operator+=(), marginsAdded() - - \since 5.1 -*/ - /*! \fn const QMargins operator+(const QMargins &m1, const QMargins &m2) \relates QMargins diff --git a/src/corelib/tools/qmargins.h b/src/corelib/tools/qmargins.h index ad5e94cefe..6bffa544c1 100644 --- a/src/corelib/tools/qmargins.h +++ b/src/corelib/tools/qmargins.h @@ -42,7 +42,7 @@ #ifndef QMARGINS_H #define QMARGINS_H -#include +#include QT_BEGIN_NAMESPACE @@ -149,41 +149,6 @@ Q_DECL_CONSTEXPR inline bool operator!=(const QMargins &m1, const QMargins &m2) m1.m_bottom != m2.m_bottom; } -Q_DECL_CONSTEXPR inline QRect operator+(const QRect &rectangle, const QMargins &margins) -{ - return QRect(QPoint(rectangle.left() - margins.left(), rectangle.top() - margins.top()), - QPoint(rectangle.right() + margins.right(), rectangle.bottom() + margins.bottom())); -} - -Q_DECL_CONSTEXPR inline QRect operator+(const QMargins &margins, const QRect &rectangle) -{ - return QRect(QPoint(rectangle.left() - margins.left(), rectangle.top() - margins.top()), - QPoint(rectangle.right() + margins.right(), rectangle.bottom() + margins.bottom())); -} - -inline QRect QRect::marginsAdded(const QMargins &margins) const -{ - return *this + margins; -} - -inline QRect QRect::marginsRemoved(const QMargins &margins) const -{ - return QRect(QPoint(x1 + margins.left(), y1 + margins.top()), - QPoint(x2 - margins.right(), y2 - margins.bottom())); -} - -inline QRect &QRect::operator+=(const QMargins &margins) -{ - *this = marginsAdded(margins); - return *this; -} - -inline QRect &QRect::operator-=(const QMargins &margins) -{ - *this = marginsRemoved(margins); - return *this; -} - Q_DECL_CONSTEXPR inline QMargins operator+(const QMargins &m1, const QMargins &m2) { return QMargins(m1.left() + m2.left(), m1.top() + m2.top(), diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index fcff8931e8..e67b74ea6c 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -1162,6 +1162,65 @@ bool QRect::intersects(const QRect &r) const returns \c false. */ +/*! + \fn QRect operator+(const QRect &rectangle, const QMargins &margins) + \relates QRect + + Returns the \a rectangle grown by the \a margins. + + \since 5.1 +*/ + +/*! + \fn QRect operator+(const QMargins &margins, const QRect &rectangle) + \relates QRect + \overload + + Returns the \a rectangle grown by the \a margins. + + \since 5.1 +*/ + +/*! + \fn QRect QRect::marginsAdded(const QMargins &margins) const + + Returns a rectangle grown by the \a margins. + + \sa operator+=(), marginsRemoved(), operator-=() + + \since 5.1 +*/ + +/*! + \fn QRect QRect::operator+=(const QMargins &margins) const + + Adds the \a margins to the rectangle, growing it. + + \sa marginsAdded(), marginsRemoved(), operator-=() + + \since 5.1 +*/ + +/*! + \fn QRect QRect::marginsRemoved(const QMargins &margins) const + + Removes the \a margins from the rectangle, shrinking it. + + \sa marginsAdded(), operator+=(), operator-=() + + \since 5.1 +*/ + +/*! + \fn QRect QRect::operator -=(const QMargins &margins) const + + Returns a rectangle shrunk by the \a margins. + + \sa marginsRemoved(), operator+=(), marginsAdded() + + \since 5.1 +*/ + /***************************************************************************** QRect stream functions diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h index 22696f9edf..52f1a79362 100644 --- a/src/corelib/tools/qrect.h +++ b/src/corelib/tools/qrect.h @@ -42,6 +42,7 @@ #ifndef QRECT_H #define QRECT_H +#include #include #include @@ -51,8 +52,6 @@ QT_BEGIN_NAMESPACE -class QMargins; - class Q_CORE_EXPORT QRect { public: @@ -138,8 +137,8 @@ public: inline QRect intersected(const QRect &other) const; bool intersects(const QRect &r) const; - inline QRect marginsAdded(const QMargins &margins) const; - inline QRect marginsRemoved(const QMargins &margins) const; + Q_DECL_CONSTEXPR inline QRect marginsAdded(const QMargins &margins) const; + Q_DECL_CONSTEXPR inline QRect marginsRemoved(const QMargins &margins) const; inline QRect &operator+=(const QMargins &margins); inline QRect &operator-=(const QMargins &margins); @@ -452,6 +451,42 @@ Q_DECL_CONSTEXPR inline bool operator!=(const QRect &r1, const QRect &r2) return r1.x1!=r2.x1 || r1.x2!=r2.x2 || r1.y1!=r2.y1 || r1.y2!=r2.y2; } +Q_DECL_CONSTEXPR inline QRect operator+(const QRect &rectangle, const QMargins &margins) +{ + return QRect(QPoint(rectangle.left() - margins.left(), rectangle.top() - margins.top()), + QPoint(rectangle.right() + margins.right(), rectangle.bottom() + margins.bottom())); +} + +Q_DECL_CONSTEXPR inline QRect operator+(const QMargins &margins, const QRect &rectangle) +{ + return QRect(QPoint(rectangle.left() - margins.left(), rectangle.top() - margins.top()), + QPoint(rectangle.right() + margins.right(), rectangle.bottom() + margins.bottom())); +} + +Q_DECL_CONSTEXPR inline QRect QRect::marginsAdded(const QMargins &margins) const +{ + return QRect(QPoint(x1 - margins.left(), y1 - margins.top()), + QPoint(x2 + margins.right(), y2 + margins.bottom())); +} + +Q_DECL_CONSTEXPR inline QRect QRect::marginsRemoved(const QMargins &margins) const +{ + return QRect(QPoint(x1 + margins.left(), y1 + margins.top()), + QPoint(x2 - margins.right(), y2 - margins.bottom())); +} + +inline QRect &QRect::operator+=(const QMargins &margins) +{ + *this = marginsAdded(margins); + return *this; +} + +inline QRect &QRect::operator-=(const QMargins &margins) +{ + *this = marginsRemoved(margins); + return *this; +} + #ifndef QT_NO_DEBUG_STREAM Q_CORE_EXPORT QDebug operator<<(QDebug, const QRect &); #endif -- cgit v1.2.3 From 9c6447e0815a18102e5ebe236c52ba4343dbb8fa Mon Sep 17 00:00:00 2001 From: John Layt Date: Fri, 14 Feb 2014 15:23:47 +0100 Subject: QMargins - Add missing operators Add missing standard operators. [ChangeLog][QtCore][QMargins] Added missing addition and subtraction operators. Change-Id: I6aeed39531a736c12d378a817a9431279da79bc4 Reviewed-by: Lars Knoll Reviewed-by: Friedemann Kleint --- src/corelib/tools/qmargins.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++ src/corelib/tools/qmargins.h | 23 +++++++++++++++++++++ 2 files changed, 68 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp index 06f41a6737..7d8a167a88 100644 --- a/src/corelib/tools/qmargins.cpp +++ b/src/corelib/tools/qmargins.cpp @@ -181,6 +181,42 @@ QT_BEGIN_NAMESPACE \since 5.1 */ +/*! + \fn const QMargins operator+(const QMargins &lhs, int rhs) + \relates QMargins + + Returns a QMargins object that is formed by adding \a rhs to + \a lhs. + + \sa QMargins::operator+=(), QMargins::operator-=() + + \since 5.3 +*/ + +/*! + \fn const QMargins operator+(int lhs, const QMargins &rhs) + \relates QMargins + + Returns a QMargins object that is formed by adding \a lhs to + \a rhs. + + \sa QMargins::operator+=(), QMargins::operator-=() + + \since 5.3 +*/ + +/*! + \fn const QMargins operator-(const QMargins &lhs, int rhs) + \relates QMargins + + Returns a QMargins object that is formed by subtracting \a rhs from + \a lhs. + + \sa QMargins::operator+=(), QMargins::operator-=() + + \since 5.3 +*/ + /*! \fn const QMargins operator*(const QMargins &margins, int factor) \relates QMargins @@ -257,6 +293,15 @@ QT_BEGIN_NAMESPACE \since 5.1 */ +/*! + \fn QMargins operator+(const QMargins &margins) + \relates QMargins + + Returns a QMargin object that is formed from all components of \a margins. + + \since 5.3 +*/ + /*! \fn QMargins operator-(const QMargins &margins) \relates QMargins diff --git a/src/corelib/tools/qmargins.h b/src/corelib/tools/qmargins.h index 6bffa544c1..55355ac859 100644 --- a/src/corelib/tools/qmargins.h +++ b/src/corelib/tools/qmargins.h @@ -161,6 +161,24 @@ Q_DECL_CONSTEXPR inline QMargins operator-(const QMargins &m1, const QMargins &m m1.right() - m2.right(), m1.bottom() - m2.bottom()); } +Q_DECL_CONSTEXPR inline QMargins operator+(const QMargins &lhs, int rhs) +{ + return QMargins(lhs.left() + rhs, lhs.top() + rhs, + lhs.right() + rhs, lhs.bottom() + rhs); +} + +Q_DECL_CONSTEXPR inline QMargins operator+(int lhs, const QMargins &rhs) +{ + return QMargins(rhs.left() + lhs, rhs.top() + lhs, + rhs.right() + lhs, rhs.bottom() + lhs); +} + +Q_DECL_CONSTEXPR inline QMargins operator-(const QMargins &lhs, int rhs) +{ + return QMargins(lhs.left() - rhs, lhs.top() - rhs, + lhs.right() - rhs, lhs.bottom() - rhs); +} + Q_DECL_CONSTEXPR inline QMargins operator*(const QMargins &margins, int factor) { return QMargins(margins.left() * factor, margins.top() * factor, @@ -245,6 +263,11 @@ inline QMargins &QMargins::operator/=(qreal divisor) return *this = *this / divisor; } +Q_DECL_CONSTEXPR inline QMargins operator+(const QMargins &margins) +{ + return margins; +} + Q_DECL_CONSTEXPR inline QMargins operator-(const QMargins &margins) { return QMargins(-margins.left(), -margins.top(), -margins.right(), -margins.bottom()); -- cgit v1.2.3 From c7aa3a69253c82b8ae814c88ebbdfad7e48d0b2d Mon Sep 17 00:00:00 2001 From: John Layt Date: Sat, 15 Feb 2014 16:07:52 +0100 Subject: QRect - Add missing QMargins subtraction operator [ChangeLog][QtCore][QRect] Added QMargins subtraction operator. Change-Id: I64d449e2bae81a34df2cd019cff3fb186f8aaaae Reviewed-by: Lars Knoll Reviewed-by: Friedemann Kleint --- src/corelib/tools/qrect.cpp | 9 +++++++++ src/corelib/tools/qrect.h | 6 ++++++ 2 files changed, 15 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index e67b74ea6c..e3ecdbb2ca 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -1181,6 +1181,15 @@ bool QRect::intersects(const QRect &r) const \since 5.1 */ +/*! + \fn QRect operator-(const QRect &lhs, const QMargins &rhs) + \relates QRect + + Returns the \a lhs rectangle shrunken by the \a rhs margins. + + \since 5.3 +*/ + /*! \fn QRect QRect::marginsAdded(const QMargins &margins) const diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h index 52f1a79362..5f59bde269 100644 --- a/src/corelib/tools/qrect.h +++ b/src/corelib/tools/qrect.h @@ -463,6 +463,12 @@ Q_DECL_CONSTEXPR inline QRect operator+(const QMargins &margins, const QRect &re QPoint(rectangle.right() + margins.right(), rectangle.bottom() + margins.bottom())); } +Q_DECL_CONSTEXPR inline QRect operator-(const QRect &lhs, const QMargins &rhs) +{ + return QRect(QPoint(lhs.left() + rhs.left(), lhs.top() + rhs.top()), + QPoint(lhs.right() - rhs.right(), lhs.bottom() - rhs.bottom())); +} + Q_DECL_CONSTEXPR inline QRect QRect::marginsAdded(const QMargins &margins) const { return QRect(QPoint(x1 - margins.left(), y1 - margins.top()), -- cgit v1.2.3 From 3aae3e81ef55b4131eff0520d67f2594ee9e507c Mon Sep 17 00:00:00 2001 From: John Layt Date: Fri, 7 Feb 2014 11:47:24 +0100 Subject: QMarginsF - Add new QMarginsF class Add a new QMarginsF class to complement QMargins in the style of QSize/QSizeF and QRect/QRectF. [ChangeLog][QtCore] Added class QMarginsF to support handling margins with floating-point values. Change-Id: Iaaa95ec85f5d126d9d864fc4b607241a8c8a8f3a Reviewed-by: Lars Knoll Reviewed-by: Friedemann Kleint --- src/corelib/tools/qmargins.cpp | 332 +++++++++++++++++++++++++++++++++++++++++ src/corelib/tools/qmargins.h | 211 ++++++++++++++++++++++++++ src/corelib/tools/qrect.cpp | 65 ++++++++ src/corelib/tools/qrect.h | 47 ++++++ 4 files changed, 655 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp index 7d8a167a88..088f0dc083 100644 --- a/src/corelib/tools/qmargins.cpp +++ b/src/corelib/tools/qmargins.cpp @@ -426,4 +426,336 @@ QDebug operator<<(QDebug dbg, const QMargins &m) { } #endif +/*! + \class QMarginsF + \inmodule QtCore + \ingroup painting + \since 5.3 + + \brief The QMarginsF class defines the four margins of a rectangle. + + QMarginsF defines a set of four margins; left, top, right and bottom, + that describe the size of the borders surrounding a rectangle. + + The isNull() function returns \c true only if all margins are set to zero. + + QMarginsF objects can be streamed as well as compared. +*/ + + +/***************************************************************************** + QMarginsF member functions + *****************************************************************************/ + +/*! + \fn QMarginsF::QMarginsF() + + Constructs a margins object with all margins set to 0. + + \sa isNull() +*/ + +/*! + \fn QMarginsF::QMarginsF(qreal left, qreal top, qreal right, qreal bottom) + + Constructs margins with the given \a left, \a top, \a right, \a bottom + + \sa setLeft(), setRight(), setTop(), setBottom() +*/ + +/*! + \fn QMarginsF::QMarginsF(const QMargins &margins) + + Constructs margins copied from the given \a margins +*/ + +/*! + \fn bool QMarginsF::isNull() const + + Returns \c true if all margins are is 0; otherwise returns + false. +*/ + + +/*! + \fn qreal QMarginsF::left() const + + Returns the left margin. + + \sa setLeft() +*/ + +/*! + \fn qreal QMarginsF::top() const + + Returns the top margin. + + \sa setTop() +*/ + +/*! + \fn qreal QMarginsF::right() const + + Returns the right margin. +*/ + +/*! + \fn qreal QMarginsF::bottom() const + + Returns the bottom margin. +*/ + + +/*! + \fn void QMarginsF::setLeft(qreal left) + + Sets the left margin to \a left. +*/ + +/*! + \fn void QMarginsF::setTop(qreal Top) + + Sets the Top margin to \a Top. +*/ + +/*! + \fn void QMarginsF::setRight(qreal right) + + Sets the right margin to \a right. +*/ + +/*! + \fn void QMarginsF::setBottom(qreal bottom) + + Sets the bottom margin to \a bottom. +*/ + +/*! + \fn bool operator==(const QMarginsF &lhs, const QMarginsF &rhs) + \relates QMarginsF + + Returns \c true if \a lhs and \a rhs are equal; otherwise returns \c false. +*/ + +/*! + \fn bool operator!=(const QMarginsF &lhs, const QMarginsF &rhs) + \relates QMarginsF + + Returns \c true if \a lhs and \a rhs are different; otherwise returns \c false. +*/ + +/*! + \fn const QMarginsF operator+(const QMarginsF &lhs, const QMarginsF &rhs) + \relates QMarginsF + + Returns a QMarginsF object that is the sum of the given margins, \a lhs + and \a rhs; each component is added separately. + + \sa QMarginsF::operator+=(), QMarginsF::operator-=() +*/ + +/*! + \fn const QMarginsF operator-(const QMarginsF &lhs, const QMarginsF &rhs) + \relates QMarginsF + + Returns a QMarginsF object that is formed by subtracting \a rhs from + \a lhs; each component is subtracted separately. + + \sa QMarginsF::operator+=(), QMarginsF::operator-=() +*/ + +/*! + \fn const QMarginsF operator+(const QMarginsF &lhs, qreal rhs) + \relates QMarginsF + + Returns a QMarginsF object that is formed by adding \a rhs to + \a lhs. + + \sa QMarginsF::operator+=(), QMarginsF::operator-=() +*/ + +/*! + \fn const QMarginsF operator+(qreal lhs, const QMarginsF &rhs) + \relates QMarginsF + + Returns a QMarginsF object that is formed by adding \a lhs to + \a rhs. + + \sa QMarginsF::operator+=(), QMarginsF::operator-=() +*/ + +/*! + \fn const QMarginsF operator-(const QMarginsF &lhs, qreal rhs) + \relates QMarginsF + + Returns a QMarginsF object that is formed by subtracting \a rhs from + \a lhs. + + \sa QMarginsF::operator+=(), QMarginsF::operator-=() +*/ + +/*! + \fn const QMarginsF operator*(const QMarginsF &lhs, qreal rhs) + \relates QMarginsF + \overload + + Returns a QMarginsF object that is formed by multiplying each component + of the given \a lhs margins by \a rhs factor. + + \sa QMarginsF::operator*=(), QMarginsF::operator/=() +*/ + +/*! + \fn const QMarginsF operator*(qreal lhs, const QMarginsF &rhs) + \relates QMarginsF + \overload + + Returns a QMarginsF object that is formed by multiplying each component + of the given \a lhs margins by \a rhs factor. + + \sa QMarginsF::operator*=(), QMarginsF::operator/=() +*/ + +/*! + \fn const QMarginsF operator/(const QMarginsF &lhs, qreal rhs) + \relates QMarginsF + \overload + + Returns a QMarginsF object that is formed by dividing the components of + the given \a lhs margins by the given \a rhs divisor. + + \sa QMarginsF::operator*=(), QMarginsF::operator/=() +*/ + +/*! + \fn QMarginsF operator+(const QMarginsF &margins) + \relates QMarginsF + + Returns a QMargin object that is formed from all components of \a margins. +*/ + +/*! + \fn QMarginsF operator-(const QMarginsF &margins) + \relates QMarginsF + + Returns a QMargin object that is formed by negating all components of \a margins. +*/ + +/*! + \fn QMarginsF &QMarginsF::operator+=(const QMarginsF &margins) + + Add each component of \a margins to the respective component of this object + and returns a reference to it. + + \sa operator-=() +*/ + +/*! + \fn QMarginsF &QMarginsF::operator-=(const QMarginsF &margins) + + Subtract each component of \a margins from the respective component of this object + and returns a reference to it. + + \sa operator+=() +*/ + +/*! + \fn QMarginsF &QMarginsF::operator+=(qreal addend) + \overload + + Adds the \a addend to each component of this object + and returns a reference to it. + + \sa operator-=() +*/ + +/*! + \fn QMarginsF &QMarginsF::operator-=(qreal subtrahend) + \overload + + Subtracts the \a subtrahend from each component of this object + and returns a reference to it. + + \sa operator+=() +*/ + +/*! + \fn QMarginsF &QMarginsF::operator*=(qreal factor) + + Multiplies each component of this object by \a factor + and returns a reference to it. + + \sa operator/=() +*/ + +/*! + \fn QMarginsF &QMarginsF::operator/=(qreal divisor) + + Divides each component of this object by \a divisor + and returns a reference to it. + + \sa operator*=() +*/ + +/*! + \fn QMargins QMarginsF::toMargins() const + + Returns an integer based copy of this margins object. + + Note that the components in the returned margins will be rounded to + the nearest integer. + + \sa QMarginsF() +*/ + +/***************************************************************************** + QMarginsF stream functions + *****************************************************************************/ +#ifndef QT_NO_DATASTREAM +/*! + \fn QDataStream &operator<<(QDataStream &stream, const QMarginsF &m) + \relates QMarginsF + + Writes margin \a m to the given \a stream and returns a + reference to the stream. + + \sa {Serializing Qt Data Types} +*/ + +QDataStream &operator<<(QDataStream &s, const QMarginsF &m) +{ + s << double(m.left()) << double(m.top()) << double(m.right()) << double(m.bottom()); + return s; +} + +/*! + \fn QDataStream &operator>>(QDataStream &stream, QMarginsF &m) + \relates QMarginsF + + Reads a margin from the given \a stream into margin \a m + and returns a reference to the stream. + + \sa {Serializing Qt Data Types} +*/ + +QDataStream &operator>>(QDataStream &s, QMarginsF &m) +{ + double left, top, right, bottom; + s >> left; + s >> top; + s >> right; + s >> bottom; + m = QMarginsF(qreal(left), qreal(top), qreal(right), qreal(bottom)); + return s; +} +#endif // QT_NO_DATASTREAM + +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug dbg, const QMarginsF &m) { + dbg.nospace() << "QMarginsF(" << m.left() << ", " + << m.top() << ", " << m.right() << ", " << m.bottom() << ')'; + return dbg.space(); +} +#endif + QT_END_NAMESPACE diff --git a/src/corelib/tools/qmargins.h b/src/corelib/tools/qmargins.h index 55355ac859..d96ccaccae 100644 --- a/src/corelib/tools/qmargins.h +++ b/src/corelib/tools/qmargins.h @@ -46,6 +46,9 @@ QT_BEGIN_NAMESPACE +/***************************************************************************** + QMargins class + *****************************************************************************/ class QMargins { @@ -277,6 +280,214 @@ Q_DECL_CONSTEXPR inline QMargins operator-(const QMargins &margins) Q_CORE_EXPORT QDebug operator<<(QDebug, const QMargins &); #endif +/***************************************************************************** + QMarginsF class + *****************************************************************************/ + +class QMarginsF +{ +public: + Q_DECL_CONSTEXPR QMarginsF(); + Q_DECL_CONSTEXPR QMarginsF(qreal left, qreal top, qreal right, qreal bottom); + Q_DECL_CONSTEXPR QMarginsF(const QMargins &margins); + + Q_DECL_CONSTEXPR bool isNull() const; + + Q_DECL_CONSTEXPR qreal left() const; + Q_DECL_CONSTEXPR qreal top() const; + Q_DECL_CONSTEXPR qreal right() const; + Q_DECL_CONSTEXPR qreal bottom() const; + + void setLeft(qreal left); + void setTop(qreal top); + void setRight(qreal right); + void setBottom(qreal bottom); + + QMarginsF &operator+=(const QMarginsF &margins); + QMarginsF &operator-=(const QMarginsF &margins); + QMarginsF &operator+=(qreal addend); + QMarginsF &operator-=(qreal subtrahend); + QMarginsF &operator*=(qreal factor); + QMarginsF &operator/=(qreal divisor); + + Q_DECL_CONSTEXPR inline QMargins toMargins() const; + +private: + qreal m_left; + qreal m_top; + qreal m_right; + qreal m_bottom; +}; + +Q_DECLARE_TYPEINFO(QMarginsF, Q_MOVABLE_TYPE); + +/***************************************************************************** + QMarginsF stream functions + *****************************************************************************/ + +#ifndef QT_NO_DATASTREAM +Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QMarginsF &); +Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QMarginsF &); +#endif + +/***************************************************************************** + QMarginsF inline functions + *****************************************************************************/ + +Q_DECL_CONSTEXPR inline QMarginsF::QMarginsF() : m_left(0), m_top(0), m_right(0), m_bottom(0) {} + +Q_DECL_CONSTEXPR inline QMarginsF::QMarginsF(qreal aleft, qreal atop, qreal aright, qreal abottom) + : m_left(aleft), m_top(atop), m_right(aright), m_bottom(abottom) {} + +Q_DECL_CONSTEXPR inline QMarginsF::QMarginsF(const QMargins &margins) + : m_left(margins.left()), m_top(margins.top()), m_right(margins.right()), m_bottom(margins.bottom()) {} + +Q_DECL_CONSTEXPR inline bool QMarginsF::isNull() const +{ return qFuzzyIsNull(m_left) && qFuzzyIsNull(m_top) && qFuzzyIsNull(m_right) && qFuzzyIsNull(m_bottom); } + +Q_DECL_CONSTEXPR inline qreal QMarginsF::left() const +{ return m_left; } + +Q_DECL_CONSTEXPR inline qreal QMarginsF::top() const +{ return m_top; } + +Q_DECL_CONSTEXPR inline qreal QMarginsF::right() const +{ return m_right; } + +Q_DECL_CONSTEXPR inline qreal QMarginsF::bottom() const +{ return m_bottom; } + + +inline void QMarginsF::setLeft(qreal aleft) +{ m_left = aleft; } + +inline void QMarginsF::setTop(qreal atop) +{ m_top = atop; } + +inline void QMarginsF::setRight(qreal aright) +{ m_right = aright; } + +inline void QMarginsF::setBottom(qreal abottom) +{ m_bottom = abottom; } + +Q_DECL_CONSTEXPR inline bool operator==(const QMarginsF &lhs, const QMarginsF &rhs) +{ + return qFuzzyCompare(lhs.left(), rhs.left()) + && qFuzzyCompare(lhs.top(), rhs.top()) + && qFuzzyCompare(lhs.right(), rhs.right()) + && qFuzzyCompare(lhs.bottom(), rhs.bottom()); +} + +Q_DECL_CONSTEXPR inline bool operator!=(const QMarginsF &lhs, const QMarginsF &rhs) +{ + return !operator==(lhs, rhs); +} + +Q_DECL_CONSTEXPR inline QMarginsF operator+(const QMarginsF &lhs, const QMarginsF &rhs) +{ + return QMarginsF(lhs.left() + rhs.left(), lhs.top() + rhs.top(), + lhs.right() + rhs.right(), lhs.bottom() + rhs.bottom()); +} + +Q_DECL_CONSTEXPR inline QMarginsF operator-(const QMarginsF &lhs, const QMarginsF &rhs) +{ + return QMarginsF(lhs.left() - rhs.left(), lhs.top() - rhs.top(), + lhs.right() - rhs.right(), lhs.bottom() - rhs.bottom()); +} + +Q_DECL_CONSTEXPR inline QMarginsF operator+(const QMarginsF &lhs, qreal rhs) +{ + return QMarginsF(lhs.left() + rhs, lhs.top() + rhs, + lhs.right() + rhs, lhs.bottom() + rhs); +} + +Q_DECL_CONSTEXPR inline QMarginsF operator+(qreal lhs, const QMarginsF &rhs) +{ + return QMarginsF(rhs.left() + lhs, rhs.top() + lhs, + rhs.right() + lhs, rhs.bottom() + lhs); +} + +Q_DECL_CONSTEXPR inline QMarginsF operator-(const QMarginsF &lhs, qreal rhs) +{ + return QMarginsF(lhs.left() - rhs, lhs.top() - rhs, + lhs.right() - rhs, lhs.bottom() - rhs); +} + +Q_DECL_CONSTEXPR inline QMarginsF operator*(const QMarginsF &lhs, qreal rhs) +{ + return QMarginsF(lhs.left() * rhs, lhs.top() * rhs, + lhs.right() * rhs, lhs.bottom() * rhs); +} + +Q_DECL_CONSTEXPR inline QMarginsF operator*(qreal lhs, const QMarginsF &rhs) +{ + return QMarginsF(rhs.left() * lhs, rhs.top() * lhs, + rhs.right() * lhs, rhs.bottom() * lhs); +} + +Q_DECL_CONSTEXPR inline QMarginsF operator/(const QMarginsF &lhs, qreal divisor) +{ + return QMarginsF(lhs.left() / divisor, lhs.top() / divisor, + lhs.right() / divisor, lhs.bottom() / divisor); +} + +inline QMarginsF &QMarginsF::operator+=(const QMarginsF &margins) +{ + return *this = *this + margins; +} + +inline QMarginsF &QMarginsF::operator-=(const QMarginsF &margins) +{ + return *this = *this - margins; +} + +inline QMarginsF &QMarginsF::operator+=(qreal addend) +{ + m_left += addend; + m_top += addend; + m_right += addend; + m_bottom += addend; + return *this; +} + +inline QMarginsF &QMarginsF::operator-=(qreal subtrahend) +{ + m_left -= subtrahend; + m_top -= subtrahend; + m_right -= subtrahend; + m_bottom -= subtrahend; + return *this; +} + +inline QMarginsF &QMarginsF::operator*=(qreal factor) +{ + return *this = *this * factor; +} + +inline QMarginsF &QMarginsF::operator/=(qreal divisor) +{ + return *this = *this / divisor; +} + +Q_DECL_CONSTEXPR inline QMarginsF operator+(const QMarginsF &margins) +{ + return margins; +} + +Q_DECL_CONSTEXPR inline QMarginsF operator-(const QMarginsF &margins) +{ + return QMarginsF(-margins.left(), -margins.top(), -margins.right(), -margins.bottom()); +} + +Q_DECL_CONSTEXPR inline QMargins QMarginsF::toMargins() const +{ + return QMargins(qRound(m_left), qRound(m_top), qRound(m_right), qRound(m_bottom)); +} + +#ifndef QT_NO_DEBUG_STREAM +Q_CORE_EXPORT QDebug operator<<(QDebug, const QMarginsF &); +#endif + QT_END_NAMESPACE #endif // QMARGINS_H diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index e3ecdbb2ca..33e8dd23fc 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -2379,6 +2379,71 @@ QRect QRectF::toAlignedRect() const returns \c false. */ +/*! + \fn QRectF operator+(const QRectF &lhs, const QMarginsF &rhs) + \relates QRectF + \since 5.3 + + Returns the \a lhs rectangle grown by the \a rhs margins. +*/ + +/*! + \fn QRectF operator-(const QRectF &lhs, const QMarginsF &rhs) + \relates QRectF + \since 5.3 + + Returns the \a lhs rectangle grown by the \a rhs margins. +*/ + +/*! + \fn QRectF operator+(const QMarginsF &lhs, const QRectF &rhs) + \relates QRectF + \overload + \since 5.3 + + Returns the \a lhs rectangle grown by the \a rhs margins. +*/ + +/*! + \fn QRectF QRectF::marginsAdded(const QMarginsF &margins) const + \relates QRectF + \since 5.3 + + Returns a rectangle grown by the \a margins. + + \sa operator+=(), marginsRemoved(), operator-=() +*/ + +/*! + \fn QRectF QRectF::marginsRemoved(const QMarginsF &margins) const + \relates QRectF + \since 5.3 + + Removes the \a margins from the rectangle, shrinking it. + + \sa marginsAdded(), operator+=(), operator-=() +*/ + +/*! + \fn QRectF QRectF::operator+=(const QMarginsF &margins) + \relates QRectF + \since 5.3 + + Adds the \a margins to the rectangle, growing it. + + \sa marginsAdded(), marginsRemoved(), operator-=() +*/ + +/*! + \fn QRectF QRectF::operator-=(const QMarginsF &margins) + \relates QRectF + \since 5.3 + + Returns a rectangle shrunk by the \a margins. + + \sa marginsRemoved(), operator+=(), marginsAdded() +*/ + /***************************************************************************** QRectF stream functions *****************************************************************************/ diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h index 5f59bde269..2bb74e8221 100644 --- a/src/corelib/tools/qrect.h +++ b/src/corelib/tools/qrect.h @@ -584,6 +584,11 @@ public: inline QRectF intersected(const QRectF &other) const; bool intersects(const QRectF &r) const; + Q_DECL_CONSTEXPR inline QRectF marginsAdded(const QMarginsF &margins) const; + Q_DECL_CONSTEXPR inline QRectF marginsRemoved(const QMarginsF &margins) const; + inline QRectF &operator+=(const QMarginsF &margins); + inline QRectF &operator-=(const QMarginsF &margins); + #if QT_DEPRECATED_SINCE(5, 0) QT_DEPRECATED QRectF unite(const QRectF &r) const { return united(r); } QT_DEPRECATED QRectF intersect(const QRectF &r) const { return intersected(r); } @@ -825,6 +830,48 @@ Q_DECL_CONSTEXPR inline QRect QRectF::toRect() const return QRect(qRound(xp), qRound(yp), qRound(w), qRound(h)); } +Q_DECL_CONSTEXPR inline QRectF operator+(const QRectF &lhs, const QMarginsF &rhs) +{ + return QRectF(QPointF(lhs.left() - rhs.left(), lhs.top() - rhs.top()), + QSizeF(lhs.width() + rhs.left() + rhs.right(), lhs.height() + rhs.top() + rhs.bottom())); +} + +Q_DECL_CONSTEXPR inline QRectF operator+(const QMarginsF &lhs, const QRectF &rhs) +{ + return QRectF(QPointF(rhs.left() - lhs.left(), rhs.top() - lhs.top()), + QSizeF(rhs.width() + lhs.left() + lhs.right(), rhs.height() + lhs.top() + lhs.bottom())); +} + +Q_DECL_CONSTEXPR inline QRectF operator-(const QRectF &lhs, const QMarginsF &rhs) +{ + return QRectF(QPointF(lhs.left() + rhs.left(), lhs.top() + rhs.top()), + QSizeF(lhs.width() - rhs.left() - rhs.right(), lhs.height() - rhs.top() - rhs.bottom())); +} + +Q_DECL_CONSTEXPR inline QRectF QRectF::marginsAdded(const QMarginsF &margins) const +{ + return QRectF(QPointF(xp - margins.left(), yp - margins.top()), + QSizeF(w + margins.left() + margins.right(), h + margins.top() + margins.bottom())); +} + +Q_DECL_CONSTEXPR inline QRectF QRectF::marginsRemoved(const QMarginsF &margins) const +{ + return QRectF(QPointF(xp + margins.left(), yp + margins.top()), + QSizeF(w - margins.left() - margins.right(), h - margins.top() - margins.bottom())); +} + +inline QRectF &QRectF::operator+=(const QMarginsF &margins) +{ + *this = marginsAdded(margins); + return *this; +} + +inline QRectF &QRectF::operator-=(const QMarginsF &margins) +{ + *this = marginsRemoved(margins); + return *this; +} + #ifndef QT_NO_DEBUG_STREAM Q_CORE_EXPORT QDebug operator<<(QDebug, const QRectF &); #endif -- cgit v1.2.3 From 208acff3fc53a33e1f0a38dfd029dca411537db1 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 20 Feb 2014 23:22:43 +0100 Subject: QLibraryInfo: mark build() function as nothrow Change-Id: Ie95fa52e4e00fd0747d3554c9f2a4d8076faaaf6 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/corelib/global/qlibraryinfo.cpp | 2 +- src/corelib/global/qlibraryinfo.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index ed1715ddb5..93d5407184 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -287,7 +287,7 @@ QLibraryInfo::buildDate() \since 5.3 */ -const char *QLibraryInfo::build() +const char *QLibraryInfo::build() Q_DECL_NOTHROW { static const char data[] = "Qt " QT_VERSION_STR " (" __DATE__ "), " COMPILER_STRING ", " diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index 2a8a3b84b9..0b573c2e6a 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -59,7 +59,7 @@ public: static QDate buildDate(); #endif //QT_NO_DATESTRING - static const char * build(); + static const char * build() Q_DECL_NOTHROW; static bool isDebugBuild(); -- cgit v1.2.3 From 1c63909ad8caee11ba0ec4af998d981bd50d3ee1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 7 Feb 2013 13:56:57 -0800 Subject: Make sure all containers compile in strict-iterator mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unit-test this by making the QList, QVector, QHash and QMap unit tests be duplicated under strict-iterator mode. There's no test for QLinkedList. The tst_Collections test does not compile under strict-iterator mode. It generated over 15000 errors when I tried. The strict iterators required a small change: the difference_type typedef needs to match the operators that get distances (operator-(iterator)) and move the iterator around (+, -, +=, -=, etc.). Task-number: QTBUG-29608 Change-Id: I834873934c51d0f139a994cd395818da4ec997e2 Reviewed-by: Jędrzej Nowacki Reviewed-by: Jason McDonald --- src/corelib/tools/qarraydata.h | 4 ++-- src/corelib/tools/qarraydataops.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index 7df4694bcd..ffb2b8765e 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -135,7 +135,7 @@ struct QTypedArrayData public: T *i; typedef std::random_access_iterator_tag iterator_category; - typedef qptrdiff difference_type; + typedef int difference_type; typedef T value_type; typedef T *pointer; typedef T &reference; @@ -169,7 +169,7 @@ struct QTypedArrayData public: const T *i; typedef std::random_access_iterator_tag iterator_category; - typedef qptrdiff difference_type; + typedef int difference_type; typedef T value_type; typedef const T *pointer; typedef const T &reference; diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index c8a0825480..b94c6b50ea 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -122,7 +122,7 @@ struct QPodArrayOps Q_ASSERT(b >= this->begin() && b < this->end()); Q_ASSERT(e > this->begin() && e < this->end()); - ::memmove(b, e, (this->end() - e) * sizeof(T)); + ::memmove(b, e, (static_cast(this->end()) - e) * sizeof(T)); this->size -= (e - b); } }; -- cgit v1.2.3 From d7287f595a5a8fe5d44d0b8c821362a4bb290c96 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Jan 2014 17:59:45 -0800 Subject: Make QTextDecoder use our qt_from_latin1 code Disassembly shows the Intel compiler does expand to SIMD, but a much worse code than ours. Clang 3.4 does generate a compact SIMD version, probably of the same quality as our hand-written code. And GCC 4.7 through 4.9 don't generate SIMD at all. So let's use the most efficient version. Change-Id: I418e201a774ac0df1fb2b7a7d9589df7c9b655db Reviewed-by: Lars Knoll --- src/corelib/codecs/qtextcodec.cpp | 10 +++++----- src/corelib/tools/qstring.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 2552ddebe9..7e3e629c47 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -993,6 +993,8 @@ QString QTextDecoder::toUnicode(const char *chars, int len) return c->toUnicode(chars, len, &state); } +// in qstring.cpp: +void qt_from_latin1(ushort *dst, const char *str, size_t size); /*! \overload @@ -1005,12 +1007,10 @@ void QTextDecoder::toUnicode(QString *target, const char *chars, int len) case 106: // utf8 static_cast(c)->convertToUnicode(target, chars, len, &state); break; - case 4: { // latin1 + case 4: // latin1 target->resize(len); - ushort *data = (ushort*)target->data(); - for (int i = len; i >=0; --i) - data[i] = (uchar) chars[i]; - } break; + qt_from_latin1((ushort*)target->data(), chars, len); + break; default: *target = c->toUnicode(chars, len, &state); } diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 50f616a010..2b58100baa 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -210,7 +210,7 @@ inline RetType UnrollTailLoop<0>::exec(int, RetType returnIfExited, Functor1, Fu #endif // conversion between Latin 1 and UTF-16 -static void qt_from_latin1(ushort *dst, const char *str, size_t size) +void qt_from_latin1(ushort *dst, const char *str, size_t size) { /* SIMD: * Unpacking with SSE has been shown to improve performance on recent CPUs -- cgit v1.2.3 From 3a3a7f88428a13ddd52d80940fbd086e2355bc23 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 2 Feb 2014 14:03:53 -0800 Subject: Normalize signal & slot signatures in connection Profiling showed that Qt Creator spent 2% of its load time normalizing signals and slots. By pre-normalizing everything, we ensure that there is no runtime cost. Profiling after this commit and the others in this series shows that the cost dropped down to zero. Change-Id: Ifc5a2c2552e245fb9a5f31514e9dd683c5c55327 Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- src/corelib/doc/snippets/signalmapper/filereader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/doc/snippets/signalmapper/filereader.cpp b/src/corelib/doc/snippets/signalmapper/filereader.cpp index cb83ea9362..6770510f5e 100644 --- a/src/corelib/doc/snippets/signalmapper/filereader.cpp +++ b/src/corelib/doc/snippets/signalmapper/filereader.cpp @@ -74,8 +74,8 @@ FileReader::FileReader(QWidget *parent) //! [2] //slower due to signature normalization at runtime - connect(signalMapper, SIGNAL(mapped(const QString &)), - this, SLOT(readFile(const QString &))); + connect(signalMapper, SIGNAL(mapped(QString)), + this, SLOT(readFile(QString))); //! [2] */ QHBoxLayout *buttonLayout = new QHBoxLayout; -- cgit v1.2.3 From c1d4a634cb439a3c1cc3ce762eb5ace6bb6ead95 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 19 Feb 2014 18:59:24 -0800 Subject: Fix off-by-one error: the next ASCII character is next one The bit scan function returns the index of the last non-ASCII character. The next ASCII is the one after this. This means all the benchmarks were made while reentering the SIMD loop uselessly... Change-Id: If7de485a63428bfa36d413049d9239ddda1986aa Reviewed-by: Lars Knoll --- src/corelib/codecs/qutfcodec.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp index a5d16b0b54..54312601e4 100644 --- a/src/corelib/codecs/qutfcodec.cpp +++ b/src/corelib/codecs/qutfcodec.cpp @@ -85,7 +85,7 @@ static inline bool simdEncodeAscii(uchar *&dst, const ushort *&nextAscii, const // we don't want to load 32 bytes again in this loop if we know there are non-ASCII // characters still coming n = _bit_scan_reverse(n); - nextAscii = src + n; + nextAscii = src + n + 1; return false; } @@ -115,7 +115,7 @@ static inline bool simdDecodeAscii(ushort *&dst, const uchar *&nextAscii, const // we don't want to load 16 bytes again in this loop if we know there are non-ASCII // characters still coming n = _bit_scan_reverse(n); - nextAscii = src + n; + nextAscii = src + n + 1; return false; } -- cgit v1.2.3 From acf1cb94587513c29d05b2114d2704f236b7f1b9 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Thu, 20 Feb 2014 15:38:37 +0100 Subject: Fix typo in QLibraryInfo::build() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit before: Config: Using QtTest library 5.4.0, Qt 5.4.0 (Feb 20 2014), GCC 4.6.3, 32 bit, release build) Qt 5.4.0 (Feb 20 2014), GCC 4.6.3, 32 bit, release build) after: Config: Using QtTest library 5.4.0, Qt 5.4.0 (Feb 20 2014, GCC 4.6.3, 32 bit, release build) Qt 5.4.0 (Feb 20 2014, GCC 4.6.3, 32 bit, release build) Change-Id: Ia4c9f994ef7e834831c78e8dbc00a52e06c0ed9a Reviewed-by: Friedemann Kleint Reviewed-by: Jędrzej Nowacki --- src/corelib/global/qlibraryinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 93d5407184..689de48e26 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -289,7 +289,7 @@ QLibraryInfo::buildDate() const char *QLibraryInfo::build() Q_DECL_NOTHROW { - static const char data[] = "Qt " QT_VERSION_STR " (" __DATE__ "), " + static const char data[] = "Qt " QT_VERSION_STR " (" __DATE__ ", " COMPILER_STRING ", " #if QT_POINTER_SIZE == 4 "32" -- cgit v1.2.3 From 0c9c43c1483dbe8146f05a8df6ccb15f15a8f403 Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Sat, 22 Feb 2014 00:33:32 +0800 Subject: Doc: Address some "No documentation for..." QDoc warnings Task-number: QTBUG-36985 Change-Id: I8619fb77e7879399064281f7bbefe5f12d3849a2 Reviewed-by: Frederik Gladhorn --- src/corelib/tools/qbytearray.cpp | 11 +++++------ src/corelib/tools/qstring.cpp | 9 +++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 304ce69449..73fd6369a7 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -3665,12 +3665,6 @@ QByteArray QByteArray::toBase64(Base64Options options) const \sa toUShort() */ -/*! - \overload - - \sa toLongLong() -*/ - static char *qulltoa2(char *p, qulonglong n, int base) { #if defined(QT_CHECK_RANGE) @@ -3689,6 +3683,11 @@ static char *qulltoa2(char *p, qulonglong n, int base) return p; } +/*! + \overload + + \sa toLongLong() +*/ QByteArray &QByteArray::setNum(qlonglong n, int base) { const int buffsize = 66; // big enough for MAX_ULLONG in base 2 diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 2b58100baa..c433120f6f 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -1494,6 +1494,10 @@ QString::QString(QChar ch) \internal */ +/*! \fn QString::QString(QStringDataPtr) + \internal +*/ + /*! \fn QString &QString::operator=(const Null &) \internal */ @@ -8464,6 +8468,11 @@ bool operator<(const QStringRef &s1,const QStringRef &s2) this string reference, returning the result. */ +/*! + \typedef QString::Data + \internal +*/ + /*! \typedef QString::DataPtr \internal -- cgit v1.2.3 From f12b0f9a38c792abb13f3e6ecff4542986a6f96b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 20 Feb 2014 22:55:22 +0100 Subject: QByteArrayList: optimize op+ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old code creates a default-constructed QByteArrayList, then performed two list-appends, the first one of which just performs assignment. Optimize by replacing the default construction and assignment with a copy constructor call. Change-Id: I6d5bd14172798c925b05bd3602e6d1d037d90796 Reviewed-by: Lars Knoll Reviewed-by: Jędrzej Nowacki --- src/corelib/tools/qbytearraylist.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qbytearraylist.h b/src/corelib/tools/qbytearraylist.h index 5ce6509c28..882bc68f09 100644 --- a/src/corelib/tools/qbytearraylist.h +++ b/src/corelib/tools/qbytearraylist.h @@ -97,9 +97,8 @@ inline QByteArray QByteArrayList::join(char sep) const inline QByteArrayList operator+(const QByteArrayList &lhs, const QByteArrayList &rhs) { - QByteArrayList res; - res.append( lhs ); - res.append( rhs ); + QByteArrayList res = lhs; + res += rhs; return res; } -- cgit v1.2.3 From 6813a21c522631e5388b2cbf3f8e4e273b0d27ce Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 24 Feb 2014 14:05:58 +0100 Subject: Fix compilation on armv5 Two changes broke compilation on armv5, where we're currently not CI-testing: 634f82f1f1fda7983abf70b58e43c580b1f01df0 changed the signature in a function definition without changing its declaration, while it was actually intending to add this as a new overload. bfe0db6fbea6376dbe395af6d76995a54bbc3b49 added an #error condition without fixing compilation on armv5. I don't know if the fix is correct, but at least it compiles. Task-number: QTBUG-37034 Change-Id: If99142fafb9bd55afc20b17f8b3cce5ee0ffec13 Reviewed-by: Thiago Macieira --- src/corelib/arch/qatomic_armv5.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/arch/qatomic_armv5.h b/src/corelib/arch/qatomic_armv5.h index 6939650c54..253b9263de 100644 --- a/src/corelib/arch/qatomic_armv5.h +++ b/src/corelib/arch/qatomic_armv5.h @@ -54,6 +54,7 @@ QT_END_NAMESPACE #pragma qt_sync_stop_processing #endif +#define Q_ATOMIC_INT32_IS_SUPPORTED #define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_NOT_NATIVE #define Q_ATOMIC_INT_TEST_AND_SET_IS_NOT_NATIVE #define Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE @@ -98,6 +99,7 @@ template struct QBasicAtomicOps: QGenericAtomicOps static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW; + template static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW; template static T fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW; template static T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW; @@ -132,6 +134,18 @@ bool QBasicAtomicOps<4>::deref(T &_q_value) Q_DECL_NOTHROW return newValue != 0; } +template<> template inline +bool QBasicAtomicOps<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW +{ + T originalValue; + do { + originalValue = _q_value; + if (originalValue != expectedValue) + return false; + } while (_q_cmpxchg(expectedValue, newValue, &_q_value) != 0); + return true; +} + template<> template inline bool QBasicAtomicOps<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW { -- cgit v1.2.3 From 9f983eac9f926b4ea3ee4ec860f58dc33a5b7fe7 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 22 Feb 2014 23:30:22 +0100 Subject: QJNI: optimize QSharedPointer creation Instead of QSharedPointer(new T), use QSharedPointer::create(), since the latter co-locates the refcount and the T instance in a single memory allocation, unlike the first form, which uses separate memory allocations. Change-Id: I5095ac43448aad9a7e3ec07ed4dcdca869bcd9e8 Reviewed-by: Lars Knoll Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/corelib/kernel/qjni_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qjni_p.h b/src/corelib/kernel/qjni_p.h index b1f0011b94..83dd3a00af 100644 --- a/src/corelib/kernel/qjni_p.h +++ b/src/corelib/kernel/qjni_p.h @@ -177,7 +177,7 @@ public: { jobject jobj = static_cast(o); if (!isSameObject(jobj)) { - d = QSharedPointer(new QJNIObjectData()); + d = QSharedPointer::create(); if (jobj) { QJNIEnvironmentPrivate env; d->m_jobject = env->NewGlobalRef(jobj); -- cgit v1.2.3 From 51572d3d8f85f8836c25d1f793e69b170672cc3c Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 24 Feb 2014 16:09:23 +0100 Subject: QAssociative/SequentialIterable: add missing \since 5.2 Change-Id: Ia78fa0d70c85f06f48c3bbab47370e15008abe03 Reviewed-by: Jerome Pasion Reviewed-by: Stephen Kelly --- src/corelib/kernel/qvariant.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index dd9a7693ca..f7540dc20f 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -3488,7 +3488,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p) /*! \class QSequentialIterable - + \since 5.2 \inmodule QtCore \brief The QSequentialIterable class is an iterable interface for a container in a QVariant. @@ -3591,7 +3591,7 @@ bool QSequentialIterable::canReverseIterate() const /*! \class QSequentialIterable::const_iterator - + \since 5.2 \inmodule QtCore \brief The QSequentialIterable::const_iterator allows iteration over a container in a QVariant. @@ -3794,7 +3794,7 @@ QSequentialIterable::const_iterator QSequentialIterable::const_iterator::operato /*! \class QAssociativeIterable - + \since 5.2 \inmodule QtCore \brief The QAssociativeIterable class is an iterable interface for an associative container in a QVariant. @@ -3899,7 +3899,7 @@ int QAssociativeIterable::size() const /*! \class QAssociativeIterable::const_iterator - + \since 5.2 \inmodule QtCore \brief The QAssociativeIterable::const_iterator allows iteration over a container in a QVariant. -- cgit v1.2.3 From 7129ec0f476f33f32760e4b7801adaae14164444 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 24 Feb 2014 09:29:41 +0100 Subject: Document qPrintable encoding issues Change-Id: I8936203afaa100ac4665ed668f7729fc8da1d445 Reviewed-by: Oswald Buddenhagen Reviewed-by: Jerome Pasion --- src/corelib/global/qglobal.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index fe10c493a7..0f1968d151 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2810,12 +2810,17 @@ int qrand() The char pointer will be invalid after the statement in which qPrintable() is used. This is because the array returned by - toLocal8Bit() will fall out of scope. + QString::toLocal8Bit() will fall out of scope. Example: \snippet code/src_corelib_global_qglobal.cpp 37 + \note qDebug(), qWarning(), qCritical(), qFatal() expect %s + arguments to be UTF-8 encoded, while qPrintable() converts to + local 8-bit encoding. Therefore using qPrintable for logging + strings is only safe if the argument contains only ASCII + characters. \sa qDebug(), qWarning(), qCritical(), qFatal() */ -- cgit v1.2.3 From ee55244df4747712f953c448244c68ba3e95e31c Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 24 Feb 2014 11:43:13 +0100 Subject: Fix link to argument formats in QString::setNum documentation Also drop mentioning of 'F', which is (though supported) not mentioned in the linked section. Change-Id: I9bf763f25b8b0309c338adbf3d63d94678ecee5e Reviewed-by: Jerome Pasion --- src/corelib/tools/qstring.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index c433120f6f..116da9e383 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -6428,8 +6428,8 @@ QString &QString::setNum(qulonglong n, int base) to the given \a format and \a precision, and returns a reference to the string. - The \a format can be 'f', 'F', 'e', 'E', 'g' or 'G' (see the - arg() function documentation for an explanation of the formats). + The \a format can be 'e', 'E', 'f', 'g' or 'G' (see + \l{Argument Formats} for an explanation of the formats). The formatting always uses QLocale::C, i.e., English/UnitedStates. To get a localized string representation of a number, use -- cgit v1.2.3 From b648195c314ab0b342e5883ba13efbdc7104fd9e Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Sat, 15 Feb 2014 11:54:53 +0800 Subject: Doc: Replace obsolete types with their newer counterparts This patch ignores: - Docs for obsolete types themselves - Comparisons between new and obsolete types Change-Id: Id9b1e628255113e7c44520abe0f8a4e0db4a283d Reviewed-by: Jerome Pasion --- src/corelib/global/qglobal.cpp | 2 +- src/corelib/itemmodels/qsortfilterproxymodel.cpp | 20 +++++++++--------- src/corelib/json/qjsondocument.cpp | 4 ++-- src/corelib/json/qjsonvalue.cpp | 26 ++++++++++++------------ src/corelib/kernel/qvariant.cpp | 8 ++++---- 5 files changed, 30 insertions(+), 30 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 0f1968d151..710f7e8ba1 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -743,7 +743,7 @@ Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits"); \relates This enum describes the messages that can be sent to a message - handler (QtMsgHandler). You can use the enum to identify and + handler (QtMessageHandler). You can use the enum to identify and associate the various message types with the appropriate actions. diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index ebc97ca2d9..1e377abf3e 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -2606,16 +2606,16 @@ void QSortFilterProxyModel::invalidateFilter() the following QVariant types: \list - \li QVariant::Int - \li QVariant::UInt - \li QVariant::LongLong - \li QVariant::ULongLong - \li QVariant::Double - \li QVariant::Char - \li QVariant::Date - \li QVariant::Time - \li QVariant::DateTime - \li QVariant::String + \li QMetaType::Int + \li QMetaType::UInt + \li QMetaType::LongLong + \li QMetaType::ULongLong + \li QMetaType::Double + \li QMetaType::QChar + \li QMetaType::QDate + \li QMetaType::QTime + \li QMetaType::QDateTime + \li QMetaType::QString \endlist Any other type will be converted to a QString using diff --git a/src/corelib/json/qjsondocument.cpp b/src/corelib/json/qjsondocument.cpp index 6e257df39d..90ce8c63a5 100644 --- a/src/corelib/json/qjsondocument.cpp +++ b/src/corelib/json/qjsondocument.cpp @@ -260,8 +260,8 @@ QJsonDocument QJsonDocument::fromBinaryData(const QByteArray &data, DataValidati /*! Creates a QJsonDocument from the QVariant \a variant. - If the \a variant contains any other type than a QVariant::Map, - QVariant::List or QVariant::StringList, the returned document + If the \a variant contains any other type than a QVariantMap, + QVariantList or QStringList, the returned document document is invalid. \sa toVariant() diff --git a/src/corelib/json/qjsonvalue.cpp b/src/corelib/json/qjsonvalue.cpp index c16824ebd2..487a431b8f 100644 --- a/src/corelib/json/qjsonvalue.cpp +++ b/src/corelib/json/qjsonvalue.cpp @@ -344,16 +344,16 @@ QJsonValue &QJsonValue::operator =(const QJsonValue &other) The conversion will convert QVariant types as follows: \list - \li QVariant::Bool to Bool - \li QVariant::Int - \li QVariant::Double - \li QVariant::LongLong - \li QVariant::ULongLong - \li QVariant::UInt to Double - \li QVariant::String to String - \li QVariant::StringList - \li QVariant::VariantList to Array - \li QVariant::VariantMap to Object + \li QMetaType::Bool to Bool + \li QMetaType::Int + \li QMetaType::Double + \li QMetaType::LongLong + \li QMetaType::ULongLong + \li QMetaType::UInt to Double + \li QMetaType::QString to String + \li QMetaType::QStringList + \li QMetaType::QVariantList to Array + \li QMetaType::QVariantMap to Object \endlist For all other QVariant types a conversion to a QString will be attempted. If the returned string @@ -395,9 +395,9 @@ QJsonValue QJsonValue::fromVariant(const QVariant &variant) The QJsonValue types will be converted as follows: \value Null QVariant() - \value Bool QVariant::Bool - \value Double QVariant::Double - \value String QVariant::String + \value Bool QMetaType::Bool + \value Double QMetaType::Double + \value String QString \value Array QVariantList \value Object QVariantMap \value Undefined QVariant() diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index f7540dc20f..5e8f330a92 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1165,7 +1165,7 @@ Q_CORE_EXPORT void QVariantPrivate::registerHandler(const int /* Modules::Names instead to construct variants from the pointer types represented by \c QMetaType::VoidStar, and \c QMetaType::QObjectStar. - \sa QVariant::fromValue(), Type + \sa QVariant::fromValue(), QMetaType::Type */ /*! @@ -1765,7 +1765,7 @@ const char *QVariant::typeName() const } /*! - Convert this variant to type Invalid and free up any resources + Convert this variant to type QMetaType::UnknownType and free up any resources used. */ void QVariant::clear() @@ -1781,7 +1781,7 @@ void QVariant::clear() Converts the int representation of the storage type, \a typeId, to its string representation. - Returns a null pointer if the type is QVariant::Invalid or doesn't exist. + Returns a null pointer if the type is QMetaType::UnknownType or doesn't exist. */ const char *QVariant::typeToName(int typeId) { @@ -2019,7 +2019,7 @@ QDataStream& operator<<(QDataStream &s, const QVariant::Type p) \fn bool QVariant::isValid() const Returns \c true if the storage type of this variant is not - QVariant::Invalid; otherwise returns \c false. + QMetaType::UnknownType; otherwise returns \c false. */ template -- cgit v1.2.3 From f3ed93e4862a1384cf176b17675cfa78cbbeef74 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 24 Feb 2014 14:20:44 +0100 Subject: Logging: Change 'rules' section name to 'Rules' This is more consistent with e.g. qt.conf, where section names also start with an upper case character. Change-Id: I9ddaf72baeb9334d081807412512242d5d46cbbf Reviewed-by: Friedemann Kleint Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qloggingcategory.cpp | 2 +- src/corelib/io/qloggingregistry.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp index f37b9575aa..eb8aeaca50 100644 --- a/src/corelib/io/qloggingcategory.cpp +++ b/src/corelib/io/qloggingcategory.cpp @@ -109,7 +109,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QLoggingCategory, qtDefaultCategory, apply to a category/type, the rule that comes later is applied. Rules can be set via \l setFilterRules(). Since Qt 5.3 logging rules - are also automatically loaded from the \c [rules] section of a logging + are also automatically loaded from the \c [Rules] section of a logging configuration file. Such configuration files are looked up in the QtProject configuration directory, or explicitly set in a \c QT_LOGGING_CONF environment variable. diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index b8fef16c0e..2619743ff4 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -203,7 +203,7 @@ void QLoggingSettingsParser::setContent(QTextStream &stream) continue; } - if (_section == QLatin1String("rules")) { + if (_section == QLatin1String("Rules")) { int equalPos = line.indexOf(QLatin1Char('=')); if ((equalPos != -1) && (line.lastIndexOf(QLatin1Char('=')) == equalPos)) { @@ -298,7 +298,7 @@ void QLoggingRegistry::unregisterCategory(QLoggingCategory *cat) void QLoggingRegistry::setApiRules(const QString &content) { QLoggingSettingsParser parser; - parser.setSection(QStringLiteral("rules")); + parser.setSection(QStringLiteral("Rules")); parser.setContent(content); QMutexLocker locker(®istryMutex); -- cgit v1.2.3 From a2f79b0d0f2373179998dd226bc5a86ad31f4e7e Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 21 Feb 2014 14:21:58 +0100 Subject: Android: Make default permissions less confusing Add comments to explain the magic placeholders for default permissions and features, and move the INTERNET and WRITE_EXTERNAL_STORAGE permissions from the manifest so that we use the same mechanism for all default permissions. Change-Id: Ia62dd4314c1c10eb201b5203772ffe88b1ce7a04 Reviewed-by: Paul Olav Tvete --- src/corelib/corelib.pro | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index 373b3f148d..79c90e0664 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -24,6 +24,9 @@ ANDROID_LIB_DEPENDENCIES = \ ANDROID_BUNDLED_JAR_DEPENDENCIES = \ jar/QtAndroid-bundled.jar \ jar/QtAndroidAccessibility-bundled.jar +ANDROID_PERMISSIONS = \ + android.permission.INTERNET \ + android.permission.WRITE_EXTERNAL_STORAGE load(qt_module) -- cgit v1.2.3 From c8cde619a5f53521c86114cec64b9dbe73e6fa55 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 24 Feb 2014 16:21:02 -0800 Subject: Fix ARM atomics for 8- and 16-bit types This has apparently never worked for any negative value. That's because the compiler sign-extends the incoming expectedValue to fill the 32-bit register, instead of zero-extending it, and it also expects any returned values to also be sign-extended. Task-number: QTBUG-37031 Change-Id: I836eddba7b1acc56bb0ac1d41de7001d06255b9b Reviewed-by: Sergio Ahumada --- src/corelib/arch/qatomic_armv6.h | 54 ++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 10 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/arch/qatomic_armv6.h b/src/corelib/arch/qatomic_armv6.h index 4f1c758ded..31a06541ed 100644 --- a/src/corelib/arch/qatomic_armv6.h +++ b/src/corelib/arch/qatomic_armv6.h @@ -90,6 +90,10 @@ template struct QBasicAtomicOps: QGenericAtomicOps static T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW; + +private: + template static inline T shrinkFrom32Bit(T value); + template static inline T extendTo32Bit(T value); }; template struct QAtomicOps : QBasicAtomicOps @@ -257,6 +261,36 @@ template<> struct QAtomicOpsSupport<8> { enum { IsSupported = 1 }; }; #define Q_ATOMIC_INT64_FETCH_AND_STORE_IS_ALWAYS_NATIVE #define Q_ATOMIC_INT64_FETCH_AND_ADD_IS_ALWAYS_NATIVE +// note: if T is signed, parameters are passed sign-extended in the +// registers. However, our 8- and 16-bit operations don't do sign +// extension. So we need to clear out the input on entry and sign-extend again +// on exit. +template template +T QBasicAtomicOps::shrinkFrom32Bit(T value) +{ + Q_STATIC_ASSERT(Size == 1 || Size == 2); + if (T(-1) > T(0)) + return value; // unsigned, ABI will zero extend + if (Size == 1) + asm volatile("and %0, %0, %1" : "+r" (value) : "I" (0xff)); + else + asm volatile("and %0, %0, %1" : "+r" (value) : "r" (0xffff)); + return value; +} + +template template +T QBasicAtomicOps::extendTo32Bit(T value) +{ + Q_STATIC_ASSERT(Size == 1 || Size == 2); + if (T(-1) > T(0)) + return value; // unsigned, ABI will zero extend + if (Size == 1) + asm volatile("sxtb %0, %0" : "+r" (value)); + else + asm volatile("sxth %0, %0" : "+r" (value)); + return value; +} + template<> template inline bool QBasicAtomicOps<1>::ref(T &_q_value) Q_DECL_NOTHROW { @@ -308,7 +342,7 @@ bool QBasicAtomicOps<1>::testAndSetRelaxed(T &_q_value, T expectedValue, T newVa "beq 0b\n" : [result] "=&r" (result), "+m" (_q_value) - : [expectedValue] "r" (expectedValue), + : [expectedValue] "r" (shrinkFrom32Bit(expectedValue)), [newValue] "r" (newValue), [_q_value] "r" (&_q_value) : "cc"); @@ -330,11 +364,11 @@ bool QBasicAtomicOps<1>::testAndSetRelaxed(T &_q_value, T expectedValue, T newVa : [result] "=&r" (result), [tempValue] "=&r" (tempValue), "+m" (_q_value) - : [expectedValue] "r" (expectedValue), + : [expectedValue] "r" (shrinkFrom32Bit(expectedValue)), [newValue] "r" (newValue), [_q_value] "r" (&_q_value) : "cc"); - *currentValue = tempValue; + *currentValue = extendTo32Bit(tempValue); return result == 0; } @@ -354,7 +388,7 @@ T QBasicAtomicOps<1>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHR : [newValue] "r" (newValue), [_q_value] "r" (&_q_value) : "cc"); - return originalValue; + return extendTo32Bit(originalValue); } template<> template inline @@ -376,7 +410,7 @@ T QBasicAtomicOps<1>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveTy : [valueToAdd] "r" (valueToAdd * QAtomicAdditiveType::AddScale), [_q_value] "r" (&_q_value) : "cc"); - return originalValue; + return extendTo32Bit(originalValue); } template<> template inline @@ -430,7 +464,7 @@ bool QBasicAtomicOps<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newVa "beq 0b\n" : [result] "=&r" (result), "+m" (_q_value) - : [expectedValue] "r" (expectedValue), + : [expectedValue] "r" (shrinkFrom32Bit(expectedValue)), [newValue] "r" (newValue), [_q_value] "r" (&_q_value) : "cc"); @@ -452,11 +486,11 @@ bool QBasicAtomicOps<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newVa : [result] "=&r" (result), [tempValue] "=&r" (tempValue), "+m" (_q_value) - : [expectedValue] "r" (expectedValue), + : [expectedValue] "r" (shrinkFrom32Bit(expectedValue)), [newValue] "r" (newValue), [_q_value] "r" (&_q_value) : "cc"); - *currentValue = tempValue; + *currentValue = extendTo32Bit(tempValue); return result == 0; } @@ -476,7 +510,7 @@ T QBasicAtomicOps<2>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHR : [newValue] "r" (newValue), [_q_value] "r" (&_q_value) : "cc"); - return originalValue; + return extendTo32Bit(originalValue); } template<> template inline @@ -498,7 +532,7 @@ T QBasicAtomicOps<2>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveTy : [valueToAdd] "r" (valueToAdd * QAtomicAdditiveType::AddScale), [_q_value] "r" (&_q_value) : "cc"); - return originalValue; + return extendTo32Bit(originalValue); } // Explanation from GCC's source code (config/arm/arm.c) on the modifiers below: -- cgit v1.2.3 From f8c5dd9857211601e2ea4b704df92e240b2c3b4b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 3 Feb 2014 22:22:14 +0100 Subject: automate handling of generated headers some more let the syncqt + qt_module_header.prf pair handle generation of forwarding headers. in qtbase this is ineffective to some degree, as the need to create QtCore's forwarding headers early for QtBootstrap requires qtbase.pro already doing the real work, but at least we get the verification that nothing breaks. Other Modules (TM) will need the full functionality. Change-Id: Ifd3dfa05c4c8a91698a365160edb6dabc84e553f Reviewed-by: Joerg Bornemann --- src/corelib/global/global.pri | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri index 789f500cab..efa585ff3e 100644 --- a/src/corelib/global/global.pri +++ b/src/corelib/global/global.pri @@ -29,15 +29,6 @@ SOURCES += \ # qlibraryinfo.cpp includes qconfig.cpp INCLUDEPATH += $$QT_BUILD_TREE/src/corelib/global -# configure creates these, not syncqt, so we need to manually inject them -qconfig_h_files = \ - $$OUT_PWD/global/qfeatures.h \ - $$OUT_PWD/global/qconfig.h \ - $$QT_BUILD_TREE/include/QtCore/QtConfig -targ_headers.files += $$qconfig_h_files -contains(QMAKE_BUNDLE_DATA, FRAMEWORK_HEADERS): \ - FRAMEWORK_HEADERS.files += $$qconfig_h_files - # Only used on platforms with CONFIG += precompile_header PRECOMPILED_HEADER = global/qt_pch.h -- cgit v1.2.3