diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-04-08 21:24:25 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-04-08 21:24:26 +0200 |
commit | 4973786f0d36fc379c7e88a20c51639e93ddea2a (patch) | |
tree | d4d0e3cc8adc4be3aeef13bffb6907154daf95fd /src/corelib | |
parent | 0b17d2328592c03503c41af7d594e58233255ff5 (diff) | |
parent | 00540a8345c35703aeaab072fd9e4727c9b61d5a (diff) |
Merge remote-tracking branch 'origin/5.5' into dev
Change-Id: I04f9f2749f68c0cb5a427b8d84e43b44bb143e4d
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qprocess_unix.cpp | 15 | ||||
-rw-r--r-- | src/corelib/io/qsavefile.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qtemporaryfile.cpp | 13 | ||||
-rw-r--r-- | src/corelib/io/qtemporaryfile_p.h | 10 | ||||
-rw-r--r-- | src/corelib/tools/qarraydata.cpp | 10 | ||||
-rw-r--r-- | src/corelib/tools/qbytearray.cpp | 34 | ||||
-rw-r--r-- | src/corelib/tools/qdatetime.cpp | 25 | ||||
-rw-r--r-- | src/corelib/tools/qdatetime.h | 1 | ||||
-rw-r--r-- | src/corelib/tools/qqueue.h | 5 | ||||
-rw-r--r-- | src/corelib/tools/qstring.cpp | 4 |
10 files changed, 57 insertions, 62 deletions
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index ffdf6f9e2e..46b557d6e0 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -299,18 +299,6 @@ static char **_q_dupEnvironment(const QProcessEnvironmentPrivate::Hash &environm if (environment.isEmpty()) return 0; - // if LD_LIBRARY_PATH exists in the current environment, but - // not in the environment list passed by the programmer, then - // copy it over. -#if defined(Q_OS_MAC) - static const char libraryPath[] = "DYLD_LIBRARY_PATH"; -#else - static const char libraryPath[] = "LD_LIBRARY_PATH"; -#endif - const QByteArray envLibraryPath = qgetenv(libraryPath); - bool needToAddLibraryPath = !envLibraryPath.isEmpty() && - !environment.contains(QProcessEnvironmentPrivate::Key(QByteArray(libraryPath))); - char **envp = new char *[environment.count() + 2]; envp[environment.count()] = 0; envp[environment.count() + 1] = 0; @@ -327,9 +315,6 @@ static char **_q_dupEnvironment(const QProcessEnvironmentPrivate::Hash &environm envp[(*envc)++] = ::strdup(key.constData()); } - if (needToAddLibraryPath) - envp[(*envc)++] = ::strdup(QByteArray(QByteArray(libraryPath) + '=' + - envLibraryPath).constData()); return envp; } diff --git a/src/corelib/io/qsavefile.cpp b/src/corelib/io/qsavefile.cpp index 33be537433..ffa6ad1c55 100644 --- a/src/corelib/io/qsavefile.cpp +++ b/src/corelib/io/qsavefile.cpp @@ -215,7 +215,7 @@ bool QSaveFile::open(OpenMode mode) d->finalFileName = existingFile.filePath(); } - d->fileEngine = new QTemporaryFileEngine(d->finalFileName); + d->fileEngine = new QTemporaryFileEngine(d->finalFileName, 0666); // Same as in QFile: QIODevice provides the buffering, so there's no need to request it from the file engine. if (!d->fileEngine->open(mode | QIODevice::Unbuffered)) { QFileDevice::FileError err = d->fileEngine->error(); diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index fa851a6d74..556bc6e760 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -103,13 +103,14 @@ typedef int NativeFileHandle; \a path is used as a template when generating unique paths, \a pos identifies the position of the first character that will be replaced in the template and \a length the number of characters that may be substituted. + \a mode specifies the file mode bits (not used on Windows). Returns an open handle to the newly created file if successful, an invalid handle otherwise. In both cases, the string in \a path will be changed and contain the generated path name. */ static bool createFileFromTemplate(NativeFileHandle &file, - QFileSystemEntry::NativePath &path, size_t pos, size_t length, + QFileSystemEntry::NativePath &path, size_t pos, size_t length, quint32 mode, QSystemError &error) { Q_ASSERT(length != 0); @@ -143,6 +144,8 @@ static bool createFileFromTemplate(NativeFileHandle &file, for (;;) { // Atomically create file and obtain handle #if defined(Q_OS_WIN) + Q_UNUSED(mode); + # ifndef Q_OS_WINRT file = CreateFile((const wchar_t *)path.constData(), GENERIC_READ | GENERIC_WRITE, @@ -175,7 +178,7 @@ static bool createFileFromTemplate(NativeFileHandle &file, #else // POSIX file = QT_OPEN(path.constData(), QT_OPEN_CREAT | O_EXCL | QT_OPEN_RDWR | QT_OPEN_LARGEFILE, - 0600); + static_cast<mode_t>(mode)); if (file != -1) return true; @@ -333,7 +336,7 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) NativeFileHandle &file = d->fd; #endif - if (!createFileFromTemplate(file, filename, phPos, phLength, error)) { + if (!createFileFromTemplate(file, filename, phPos, phLength, fileMode, error)) { setError(QFile::OpenError, error.toString()); return false; } @@ -407,9 +410,9 @@ QAbstractFileEngine *QTemporaryFilePrivate::engine() const { if (!fileEngine) { if (fileName.isEmpty()) - fileEngine = new QTemporaryFileEngine(templateName); + fileEngine = new QTemporaryFileEngine(templateName, 0600); else - fileEngine = new QTemporaryFileEngine(fileName, false); + fileEngine = new QTemporaryFileEngine(fileName, 0600, false); } return fileEngine; } diff --git a/src/corelib/io/qtemporaryfile_p.h b/src/corelib/io/qtemporaryfile_p.h index 2045edff02..475298f264 100644 --- a/src/corelib/io/qtemporaryfile_p.h +++ b/src/corelib/io/qtemporaryfile_p.h @@ -77,8 +77,13 @@ class QTemporaryFileEngine : public QFSFileEngine { Q_DECLARE_PRIVATE(QFSFileEngine) public: - QTemporaryFileEngine(const QString &file, bool fileIsTemplate = true) - : QFSFileEngine(), filePathIsTemplate(fileIsTemplate), + + QTemporaryFileEngine(const QString &file, + quint32 fileMode, + bool fileIsTemplate = true) : + QFSFileEngine(), + fileMode(fileMode), + filePathIsTemplate(fileIsTemplate), filePathWasTemplate(fileIsTemplate) { Q_D(QFSFileEngine); @@ -100,6 +105,7 @@ public: bool renameOverwrite(const QString &newName); bool close(); + quint32 fileMode; bool filePathIsTemplate; bool filePathWasTemplate; }; diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index 513d9b4ae3..ef15fae83a 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -38,10 +38,8 @@ QT_BEGIN_NAMESPACE -#if defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) && !defined(Q_CC_INTEL) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wmissing-field-initializers" -#endif +QT_WARNING_PUSH +QT_WARNING_DISABLE_GCC("-Wmissing-field-initializers") const QArrayData QArrayData::shared_null[2] = { { Q_REFCOUNT_INITIALIZE_STATIC, 0, 0, 0, sizeof(QArrayData) }, // shared null @@ -52,9 +50,7 @@ static const QArrayData qt_array[3] = { { { Q_BASIC_ATOMIC_INITIALIZER(0) }, 0, 0, 0, sizeof(QArrayData) }, // unsharable empty /* zero initialized terminator */}; -#if defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) && !defined(Q_CC_INTEL) - #pragma GCC diagnostic pop -#endif +QT_WARNING_POP static const QArrayData &qt_array_empty = qt_array[0]; static const QArrayData &qt_array_unsharable_empty = qt_array[1]; diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index eb96757457..da5d00311a 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -869,44 +869,62 @@ static inline char qToLower(char c) /*! \fn QByteArray::iterator QByteArray::begin() - \internal + Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first character in + the byte-array. + + \sa constBegin(), end() */ /*! \fn QByteArray::const_iterator QByteArray::begin() const - \internal + \overload begin() */ /*! \fn QByteArray::const_iterator QByteArray::cbegin() const \since 5.0 - \internal + Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first character + in the byte-array. + + \sa begin(), cend() */ /*! \fn QByteArray::const_iterator QByteArray::constBegin() const - \internal + Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first character + in the byte-array. + + \sa begin(), constEnd() */ /*! \fn QByteArray::iterator QByteArray::end() - \internal + Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary character + after the last character in the byte-array. + + \sa begin(), constEnd() */ /*! \fn QByteArray::const_iterator QByteArray::end() const - \internal + \overload end() */ /*! \fn QByteArray::const_iterator QByteArray::cend() const \since 5.0 - \internal + Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary + character after the last character in the list. + + \sa cbegin(), end() */ /*! \fn QByteArray::const_iterator QByteArray::constEnd() const - \internal + Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary + character after the last character in the list. + + \sa constBegin(), end() */ /*! \fn void QByteArray::push_back(const QByteArray &other) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 67f16e1f49..e445055e1d 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -3237,7 +3237,6 @@ bool QDateTime::isDaylightTime() const void QDateTime::setDate(const QDate &date) { - detach(); d->setDateTime(date, time()); } @@ -3256,7 +3255,6 @@ void QDateTime::setDate(const QDate &date) void QDateTime::setTime(const QTime &time) { - detach(); d->setDateTime(date(), time); } @@ -3278,7 +3276,7 @@ void QDateTime::setTime(const QTime &time) void QDateTime::setTimeSpec(Qt::TimeSpec spec) { - detach(); + QDateTimePrivate *d = this->d.data(); // detaches (and shadows d) d->setTimeSpec(spec, 0); d->checkValidDateTime(); } @@ -3300,7 +3298,7 @@ void QDateTime::setTimeSpec(Qt::TimeSpec spec) void QDateTime::setOffsetFromUtc(int offsetSeconds) { - detach(); + QDateTimePrivate *d = this->d.data(); // detaches (and shadows d) d->setTimeSpec(Qt::OffsetFromUTC, offsetSeconds); d->checkValidDateTime(); } @@ -3319,7 +3317,7 @@ void QDateTime::setOffsetFromUtc(int offsetSeconds) void QDateTime::setTimeZone(const QTimeZone &toZone) { - detach(); + QDateTimePrivate *d = this->d.data(); // detaches (and shadows d) d->m_spec = Qt::TimeZone; d->m_offsetFromUtc = 0; d->m_timeZone = toZone; @@ -3395,7 +3393,7 @@ uint QDateTime::toTime_t() const */ void QDateTime::setMSecsSinceEpoch(qint64 msecs) { - detach(); + QDateTimePrivate *d = this->d.data(); // detaches (and shadows d) d->m_status = 0; switch (d->m_spec) { @@ -3669,7 +3667,6 @@ QString QDateTime::toString(const QString& format) const QDateTime QDateTime::addDays(qint64 ndays) const { QDateTime dt(*this); - dt.detach(); QPair<QDate, QTime> p = d->getDateTime(); QDate &date = p.first; QTime &time = p.second; @@ -3705,7 +3702,6 @@ QDateTime QDateTime::addDays(qint64 ndays) const QDateTime QDateTime::addMonths(int nmonths) const { QDateTime dt(*this); - dt.detach(); QPair<QDate, QTime> p = d->getDateTime(); QDate &date = p.first; QTime &time = p.second; @@ -3741,7 +3737,6 @@ QDateTime QDateTime::addMonths(int nmonths) const QDateTime QDateTime::addYears(int nyears) const { QDateTime dt(*this); - dt.detach(); QPair<QDate, QTime> p = d->getDateTime(); QDate &date = p.first; QTime &time = p.second; @@ -3790,7 +3785,6 @@ QDateTime QDateTime::addMSecs(qint64 msecs) const return QDateTime(); QDateTime dt(*this); - dt.detach(); if (d->m_spec == Qt::LocalTime || d->m_spec == Qt::TimeZone) // Convert to real UTC first in case crosses daylight transition dt.setMSecsSinceEpoch(d->toMSecsSinceEpoch() + msecs); @@ -4267,7 +4261,6 @@ QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs) QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs, Qt::TimeSpec spec, int offsetSeconds) { QDateTime dt; - dt.detach(); dt.d->setTimeSpec(spec, offsetSeconds); dt.setMSecsSinceEpoch(msecs); return dt; @@ -4687,14 +4680,6 @@ QDateTime QDateTime::fromString(const QString &string, const QString &format) \sa toTimeSpec() */ -/*! - \internal - */ -void QDateTime::detach() -{ - d.detach(); -} - /***************************************************************************** Date/time stream functions *****************************************************************************/ @@ -4846,8 +4831,6 @@ QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime) QDataStream &operator>>(QDataStream &in, QDateTime &dateTime) { - dateTime.detach(); - QDate dt; QTime tm; qint8 ts = 0; diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index 88288872df..78ec2b156a 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -321,7 +321,6 @@ public: private: friend class QDateTimePrivate; - void detach(); // ### Qt6: Using a private here has high impact on runtime // on users such as QFileInfo. In Qt 6, the data members diff --git a/src/corelib/tools/qqueue.h b/src/corelib/tools/qqueue.h index ae07c7d026..9d5bda1210 100644 --- a/src/corelib/tools/qqueue.h +++ b/src/corelib/tools/qqueue.h @@ -46,6 +46,11 @@ public: inline QQueue() {} inline ~QQueue() {} inline void swap(QQueue<T> &other) { QList<T>::swap(other); } // prevent QList<->QQueue swaps +#ifndef Q_QDOC + // bring in QList::swap(int, int). We cannot say using QList<T>::swap, + // because we don't want to make swap(QList&) available. + inline void swap(int i, int j) { QList<T>::swap(i, j); } +#endif inline void enqueue(const T &t) { QList<T>::append(t); } inline T dequeue() { return QList<T>::takeFirst(); } inline T &head() { return QList<T>::first(); } diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 56dab68f33..6315c15818 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -1291,7 +1291,7 @@ const QString::Null QString::null = { }; \since 5.0 Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary - item after the last item in the list. + character after the last character in the list. \sa cbegin(), end() */ @@ -1299,7 +1299,7 @@ const QString::Null QString::null = { }; /*! \fn QString::const_iterator QString::constEnd() const Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary - item after the last item in the list. + character after the last character in the list. \sa constBegin(), end() */ |