From 8397a44bedf542b53284674c87268819f4911d31 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 22 Feb 2012 16:17:30 +0100 Subject: QByteArray: deprecate QT_NO_CAST_FROM_BYTEARRAY-protected operators The QByteArray::operator const {char,void}*() implicit conversions are a source of subtle bugs, so they right- fully can be disabled with QT_NO_CAST_FROM_BYTEARRAY. const char *d = qstring.toLatin1(); // implicit conversion while ( d ) // oops: d points to freed memory // ... But almost no-one ever enabled this macros in the wild and many were bitten by these implicit conversions, so this patch deprecates them. I would have liked to remove them completely, but there are just too many occurrences even in Qt itself to hope to find all conditionally-compiled code that uses these. Also fixes all code that needs to compile under QT_NO_DEPRECATED (in qmake/, src/tools/). I984706452db7d0841620a0f64e179906123f3849 separately deals with the bulk of changes in src/ and examples/. Depends on I5ea1ad3c96d9e64167be53c0c418c7b7dba51f68. Change-Id: I8d47e6c293c80f61c6288c9f8d42fda41afe2267 Reviewed-by: David Faure Reviewed-by: Lars Knoll --- src/corelib/tools/qbytearray.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/corelib/tools/qbytearray.cpp') diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index c74c61999d..1d37f578b8 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -343,7 +343,7 @@ int qstrcmp(const QByteArray &str1, const QByteArray &str2) { int l1 = str1.length(); int l2 = str2.length(); - int ret = memcmp(str1, str2, qMin(l1, l2)); + int ret = memcmp(str1.constData(), str2.constData(), qMin(l1, l2)); if (ret != 0) return ret; @@ -995,6 +995,8 @@ QByteArray &QByteArray::operator=(const char *str) /*! \fn QByteArray::operator const char *() const \fn QByteArray::operator const void *() const + \obsolete Use constData() instead. + Returns a pointer to the data stored in the byte array. The pointer can be used to access the bytes that compose the array. The data is '\\0'-terminated. The pointer remains valid as long @@ -2751,7 +2753,7 @@ QDataStream &operator<<(QDataStream &out, const QByteArray &ba) out << (quint32)0xffffffff; return out; } - return out.writeBytes(ba, ba.size()); + return out.writeBytes(ba.constData(), ba.size()); } /*! \relates QByteArray -- cgit v1.2.3 From 95d83cb1b68cc4a415d5d80859b4e74472ad7112 Mon Sep 17 00:00:00 2001 From: Casper van Donderen Date: Thu, 1 Mar 2012 15:28:31 +0100 Subject: Remove the usage of deprecated qdoc macros. QDoc now has support for Doxygen style commands for italics, bold and list items. This change applies that change in QDoc to the actual documentation. Task-number: QTBUG-24578 Change-Id: I519bf9c29b14092e3ab6067612f42bf749eeedf5 Reviewed-by: Shane Kearns Reviewed-by: Lars Knoll --- src/corelib/tools/qbytearray.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/corelib/tools/qbytearray.cpp') diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index c74c61999d..445fe5cd81 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -505,7 +505,7 @@ QByteArray qCompress(const uchar* data, int nbytes, int compressionLevel) from this and any earlier Qt version, back to Qt 3.1 when this feature was added. - \bold{Note:} If you want to use this function to uncompress external + \b{Note:} If you want to use this function to uncompress external data that was compressed using zlib, you first need to prepend a four byte header to the byte array containing the data. The header must contain the expected length (in bytes) of the uncompressed data, @@ -3687,12 +3687,12 @@ QByteArray &QByteArray::setNum(qulonglong n, int base) The format \a f can be any of the following: \table - \header \i Format \i Meaning - \row \i \c e \i format as [-]9.9e[+|-]999 - \row \i \c E \i format as [-]9.9E[+|-]999 - \row \i \c f \i format as [-]9.9 - \row \i \c g \i use \c e or \c f format, whichever is the most concise - \row \i \c G \i use \c E or \c f format, whichever is the most concise + \header \li Format \li Meaning + \row \li \c e \li format as [-]9.9e[+|-]999 + \row \li \c E \li format as [-]9.9E[+|-]999 + \row \li \c f \li format as [-]9.9 + \row \li \c g \li use \c e or \c f format, whichever is the most concise + \row \li \c G \li use \c E or \c f format, whichever is the most concise \endtable With 'e', 'E', and 'f', \a prec is the number of digits after the @@ -3816,12 +3816,12 @@ QByteArray QByteArray::number(qulonglong n, int base) which is \c g by default, and can be any of the following: \table - \header \i Format \i Meaning - \row \i \c e \i format as [-]9.9e[+|-]999 - \row \i \c E \i format as [-]9.9E[+|-]999 - \row \i \c f \i format as [-]9.9 - \row \i \c g \i use \c e or \c f format, whichever is the most concise - \row \i \c G \i use \c E or \c f format, whichever is the most concise + \header \li Format \li Meaning + \row \li \c e \li format as [-]9.9e[+|-]999 + \row \li \c E \li format as [-]9.9E[+|-]999 + \row \li \c f \li format as [-]9.9 + \row \li \c g \li use \c e or \c f format, whichever is the most concise + \row \li \c G \li use \c E or \c f format, whichever is the most concise \endtable With 'e', 'E', and 'f', \a prec is the number of digits after the -- cgit v1.2.3