diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2012-02-22 16:17:30 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-26 09:14:11 +0100 |
commit | 8397a44bedf542b53284674c87268819f4911d31 (patch) | |
tree | cb3dd1025c99aaac9716d62a39ad3a6a5a17babf /src/corelib/io/qfilesystemengine_unix.cpp | |
parent | ddf4b378f1e7eac62bd504a1e453cb7b894e21f2 (diff) |
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 <faure@kde.org>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib/io/qfilesystemengine_unix.cpp')
-rw-r--r-- | src/corelib/io/qfilesystemengine_unix.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 5e466e480d..e8ff6107ce 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -476,12 +476,12 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea slash = dirName.length(); } if (slash) { - QByteArray chunk = QFile::encodeName(dirName.left(slash)); + const QByteArray chunk = QFile::encodeName(dirName.left(slash)); QT_STATBUF st; - if (QT_STAT(chunk, &st) != -1) { + if (QT_STAT(chunk.constData(), &st) != -1) { if ((st.st_mode & S_IFMT) != S_IFDIR) return false; - } else if (QT_MKDIR(chunk, 0777) != 0) { + } else if (QT_MKDIR(chunk.constData(), 0777) != 0) { return false; } } @@ -492,7 +492,7 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea if (dirName.endsWith(QLatin1Char('/'))) dirName.chop(1); #endif - return (QT_MKDIR(QFile::encodeName(dirName), 0777) == 0); + return (QT_MKDIR(QFile::encodeName(dirName).constData(), 0777) == 0); } //static @@ -501,12 +501,12 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo if (removeEmptyParents) { QString dirName = QDir::cleanPath(entry.filePath()); for (int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) { - QByteArray chunk = QFile::encodeName(dirName.left(slash)); + const QByteArray chunk = QFile::encodeName(dirName.left(slash)); QT_STATBUF st; - if (QT_STAT(chunk, &st) != -1) { + if (QT_STAT(chunk.constData(), &st) != -1) { if ((st.st_mode & S_IFMT) != S_IFDIR) return false; - if (::rmdir(chunk) != 0) + if (::rmdir(chunk.constData()) != 0) return oldslash != 0; } else { return false; @@ -515,7 +515,7 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo } return true; } - return rmdir(QFile::encodeName(entry.filePath())) == 0; + return rmdir(QFile::encodeName(entry.filePath()).constData()) == 0; } //static @@ -623,7 +623,7 @@ QString QFileSystemEngine::tempPath() bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &path) { int r; - r = QT_CHDIR(path.nativeFilePath()); + r = QT_CHDIR(path.nativeFilePath().constData()); return r >= 0; } |