diff options
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qdatastream.h | 5 | ||||
-rw-r--r-- | src/corelib/io/qdebug.cpp | 27 | ||||
-rw-r--r-- | src/corelib/io/qdebug.h | 25 | ||||
-rw-r--r-- | src/corelib/io/qfiledevice.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qprocess.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/qprocess_unix.cpp | 5 | ||||
-rw-r--r-- | src/corelib/io/qresource.cpp | 1 | ||||
-rw-r--r-- | src/corelib/io/qsettings.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths.cpp | 1 | ||||
-rw-r--r-- | src/corelib/io/qstorageinfo_unix.cpp | 9 | ||||
-rw-r--r-- | src/corelib/io/qtldurl.cpp | 1 | ||||
-rw-r--r-- | src/corelib/io/qurlquery.cpp | 21 | ||||
-rw-r--r-- | src/corelib/io/qurlquery.h | 3 | ||||
-rw-r--r-- | src/corelib/io/qwindowspipereader.cpp | 8 | ||||
-rw-r--r-- | src/corelib/io/qwindowspipereader_p.h | 4 |
15 files changed, 94 insertions, 30 deletions
diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h index 436bf8dd57..b87dbe4784 100644 --- a/src/corelib/io/qdatastream.h +++ b/src/corelib/io/qdatastream.h @@ -83,10 +83,11 @@ public: Qt_5_3 = Qt_5_2, Qt_5_4 = 16, Qt_5_5 = Qt_5_4, -#if QT_VERSION >= 0x050600 + Qt_5_6 = Qt_5_5, +#if QT_VERSION >= 0x050700 #error Add the datastream version for this Qt version and update Qt_DefaultCompiledVersion #endif - Qt_DefaultCompiledVersion = Qt_5_5 + Qt_DefaultCompiledVersion = Qt_5_6 }; enum ByteOrder { diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index 357d63137c..8676fe0259 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -334,6 +334,7 @@ QDebug &QDebug::resetFormat() stream->space = true; if (stream->context.version > 1) stream->flags = 0; + stream->setVerbosity(Stream::defaultVerbosity); return *this; } @@ -424,6 +425,32 @@ QDebug &QDebug::resetFormat() */ /*! + \fn int QDebug::verbosity() const + \since 5.6 + + Returns the verbosity of the debug stream. + + Streaming operators can check the value to decide whether + verbose output is desired and print more information depending on the + level. Higher values indicate that more information is desired. + + The allowed range is from 0 to 7. The default value is 2. + + \sa setVerbosity() +*/ + +/*! + \fn void QDebug::setVerbosity(int verbosityLevel) + \since 5.6 + + Sets the verbosity of the stream to \a verbosityLevel. + + The allowed range is from 0 to 7. The default value is 2. + + \sa verbosity() +*/ + +/*! \fn QDebug &QDebug::operator<<(QChar t) Writes the character, \a t, to the stream and returns a reference to the diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 59bd32e9a4..9391799624 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -53,9 +53,14 @@ class Q_CORE_EXPORT QDebug friend class QMessageLogger; friend class QDebugStateSaverPrivate; struct Stream { - Stream(QIODevice *device) : ts(device), ref(1), type(QtDebugMsg), space(true), message_output(false), flags(0) {} - Stream(QString *string) : ts(string, QIODevice::WriteOnly), ref(1), type(QtDebugMsg), space(true), message_output(false), flags(0) {} - Stream(QtMsgType t) : ts(&buffer, QIODevice::WriteOnly), ref(1), type(t), space(true), message_output(true), flags(0) {} + enum { defaultVerbosity = 2, verbosityShift = 29, verbosityMask = 0x7 }; + + Stream(QIODevice *device) : ts(device), ref(1), type(QtDebugMsg), + space(true), message_output(false), flags(defaultVerbosity << verbosityShift) {} + Stream(QString *string) : ts(string, QIODevice::WriteOnly), ref(1), type(QtDebugMsg), + space(true), message_output(false), flags(defaultVerbosity << verbosityShift) {} + Stream(QtMsgType t) : ts(&buffer, QIODevice::WriteOnly), ref(1), type(t), + space(true), message_output(true), flags(defaultVerbosity << verbosityShift) {} QTextStream ts; QString buffer; int ref; @@ -64,7 +69,7 @@ class Q_CORE_EXPORT QDebug bool message_output; QMessageLogContext context; - enum FormatFlag { + enum FormatFlag { // Note: Bits 29..31 are reserved for the verbose level introduced in 5.6. NoQuotes = 0x1 }; @@ -72,7 +77,15 @@ class Q_CORE_EXPORT QDebug bool testFlag(FormatFlag flag) const { return (context.version > 1) ? (flags & flag) : false; } void setFlag(FormatFlag flag) { if (context.version > 1) { flags |= flag; } } void unsetFlag(FormatFlag flag) { if (context.version > 1) { flags &= ~flag; } } - + int verbosity() const + { return context.version > 1 ? (flags >> verbosityShift) & verbosityMask : int(Stream::defaultVerbosity); } + void setVerbosity(int v) + { + if (context.version > 1) { + flags &= ~(verbosityMask << verbosityShift); + flags |= (v & verbosityMask) << verbosityShift; + } + } // added in 5.4 int flags; } *stream; @@ -96,6 +109,8 @@ public: inline QDebug &space() { stream->space = true; stream->ts << ' '; return *this; } inline QDebug &nospace() { stream->space = false; return *this; } inline QDebug &maybeSpace() { if (stream->space) stream->ts << ' '; return *this; } + int verbosity() const { return stream->verbosity(); } + void setVerbosity(int verbosityLevel) { stream->setVerbosity(verbosityLevel); } bool autoInsertSpaces() const { return stream->space; } void setAutoInsertSpaces(bool b) { stream->space = b; } diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp index 3ee0e33573..4c5ed0aef6 100644 --- a/src/corelib/io/qfiledevice.cpp +++ b/src/corelib/io/qfiledevice.cpp @@ -481,7 +481,7 @@ bool QFileDevicePrivate::putCharHelper(char c) #else // Cutoff for code that doesn't only touch the buffer. - int writeBufferSize = writeBuffer.size(); + qint64 writeBufferSize = writeBuffer.size(); if ((openMode & QIODevice::Unbuffered) || writeBufferSize + 1 >= QFILE_WRITEBUFFER_SIZE #ifdef Q_OS_WIN || ((openMode & QIODevice::Text) && c == '\n' && writeBufferSize + 2 >= QFILE_WRITEBUFFER_SIZE) diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index ead04791e5..38bd588c37 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1911,12 +1911,12 @@ qint64 QProcess::readData(char *data, qint64 maxlen) return 1; } - qint64 bytesToRead = qint64(qMin(readBuffer->size(), (int)maxlen)); + qint64 bytesToRead = qMin(readBuffer->size(), maxlen); qint64 readSoFar = 0; while (readSoFar < bytesToRead) { const char *ptr = readBuffer->readPointer(); - int bytesToReadFromThisBlock = qMin<qint64>(bytesToRead - readSoFar, - readBuffer->nextDataBlockSize()); + qint64 bytesToReadFromThisBlock = qMin(bytesToRead - readSoFar, + readBuffer->nextDataBlockSize()); memcpy(data + readSoFar, ptr, bytesToReadFromThisBlock); readSoFar += bytesToReadFromThisBlock; readBuffer->free(bytesToReadFromThisBlock); diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 69b631f7e7..5ea3bf8982 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -93,7 +93,6 @@ QT_END_NAMESPACE #include <qfile.h> #include <qfileinfo.h> #include <qlist.h> -#include <qhash.h> #include <qmutex.h> #include <qsemaphore.h> #include <qsocketnotifier.h> @@ -406,7 +405,7 @@ void QProcessPrivate::startProcess() char **path = 0; int pathc = 0; if (!program.contains(QLatin1Char('/'))) { - const QString pathEnv = QString::fromLocal8Bit(::getenv("PATH")); + const QString pathEnv = QString::fromLocal8Bit(qgetenv("PATH")); if (!pathEnv.isEmpty()) { QStringList pathEntries = pathEnv.split(QLatin1Char(':'), QString::SkipEmptyParts); if (!pathEntries.isEmpty()) { @@ -1188,7 +1187,7 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a argv[arguments.size() + 1] = 0; if (!program.contains(QLatin1Char('/'))) { - const QString path = QString::fromLocal8Bit(::getenv("PATH")); + const QString path = QString::fromLocal8Bit(qgetenv("PATH")); if (!path.isEmpty()) { QStringList pathEntries = path.split(QLatin1Char(':')); for (int k = 0; k < pathEntries.size(); ++k) { diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index 4b85645a90..fbda081114 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -35,7 +35,6 @@ #include "qresource_p.h" #include "qresource_iterator_p.h" #include "qset.h" -#include "qhash.h" #include "qmutex.h" #include "qdebug.h" #include "qlocale.h" diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index afe68125d4..cb6de29532 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -1048,12 +1048,12 @@ static void initDefaultPaths(QMutexLocker *locker) // Non XDG platforms (OS X, iOS, Blackberry, Android...) have used this code path erroneously // for some time now. Moving away from that would require migrating existing settings. QString userPath; - char *env = getenv("XDG_CONFIG_HOME"); - if (env == 0) { + QByteArray env = qgetenv("XDG_CONFIG_HOME"); + if (env.isEmpty()) { userPath = QDir::homePath(); userPath += QLatin1Char('/'); userPath += QLatin1String(".config"); - } else if (*env == '/') { + } else if (env.startsWith('/')) { userPath = QFile::decodeName(env); } else { userPath = QDir::homePath(); diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp index c5c596fd2e..5f764549e0 100644 --- a/src/corelib/io/qstandardpaths.cpp +++ b/src/corelib/io/qstandardpaths.cpp @@ -35,7 +35,6 @@ #include <qdir.h> #include <qfileinfo.h> -#include <qhash.h> #ifndef QT_BOOTSTRAPPED #include <qobject.h> diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index 7b8f608050..7823787711 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -49,7 +49,7 @@ # include <sys/mount.h> # include <sys/vfs.h> # include <mntent.h> -#elif defined(Q_OS_LINUX) +#elif defined(Q_OS_LINUX) || defined(Q_OS_HURD) # include <mntent.h> # include <sys/statvfs.h> #elif defined(Q_OS_SOLARIS) @@ -137,7 +137,7 @@ private: QByteArray m_rootPath; QByteArray m_fileSystemType; QByteArray m_device; -#elif defined(Q_OS_LINUX) +#elif defined(Q_OS_LINUX) || defined(Q_OS_HURD) FILE *fp; mntent mnt; QByteArray buffer; @@ -279,10 +279,11 @@ inline QByteArray QStorageIterator::device() const return m_device; } -#elif defined(Q_OS_LINUX) +#elif defined(Q_OS_LINUX) || defined(Q_OS_HURD) static const char pathMounted[] = "/etc/mtab"; -static const int bufferSize = 3*PATH_MAX; // 2 paths (mount point+device) and metainfo +static const int bufferSize = 1024; // 2 paths (mount point+device) and metainfo; + // should be enough inline QStorageIterator::QStorageIterator() : buffer(QByteArray(bufferSize, 0)) diff --git a/src/corelib/io/qtldurl.cpp b/src/corelib/io/qtldurl.cpp index 2e787a1bc5..d68d0ddf46 100644 --- a/src/corelib/io/qtldurl.cpp +++ b/src/corelib/io/qtldurl.cpp @@ -37,7 +37,6 @@ #include "private/qtldurl_p.h" #include "QtCore/qstring.h" #include "QtCore/qvector.h" -#include "QtCore/qhash.h" QT_BEGIN_NAMESPACE diff --git a/src/corelib/io/qurlquery.cpp b/src/corelib/io/qurlquery.cpp index 77d1ab3e24..91e6e21e20 100644 --- a/src/corelib/io/qurlquery.cpp +++ b/src/corelib/io/qurlquery.cpp @@ -34,6 +34,7 @@ #include "qurlquery.h" #include "qurl_p.h" +#include <QtCore/qhashfunctions.h> #include <QtCore/qstringlist.h> QT_BEGIN_NAMESPACE @@ -407,6 +408,7 @@ bool QUrlQuery::operator ==(const QUrlQuery &other) const if (d == other.d) return true; if (d && other.d) + // keep in sync with qHash(QUrlQuery): return d->valueDelimiter == other.d->valueDelimiter && d->pairDelimiter == other.d->pairDelimiter && d->itemList == other.d->itemList; @@ -414,6 +416,25 @@ bool QUrlQuery::operator ==(const QUrlQuery &other) const } /*! + \since 5.6 + \relates QUrlQuery + + Returns the hash value for \a key, + using \a seed to seed the calculation. +*/ +uint qHash(const QUrlQuery &key, uint seed) Q_DECL_NOTHROW +{ + if (const QUrlQueryPrivate *d = key.d) { + QtPrivate::QHashCombine hash; + // keep in sync with operator==: + seed = hash(seed, d->valueDelimiter); + seed = hash(seed, d->pairDelimiter); + seed = hash(seed, d->itemList); + } + return seed; +} + +/*! Returns \c true if this QUrlQuery object contains no key-value pairs, such as after being default-constructed or after parsing an empty query string. diff --git a/src/corelib/io/qurlquery.h b/src/corelib/io/qurlquery.h index 77a0b4a82d..21962fcb22 100644 --- a/src/corelib/io/qurlquery.h +++ b/src/corelib/io/qurlquery.h @@ -44,6 +44,8 @@ QT_BEGIN_NAMESPACE +Q_CORE_EXPORT uint qHash(const QUrlQuery &key, uint seed = 0) Q_DECL_NOTHROW; + class QUrlQueryPrivate; class Q_CORE_EXPORT QUrlQuery { @@ -95,6 +97,7 @@ public: private: friend class QUrl; + friend Q_CORE_EXPORT uint qHash(const QUrlQuery &key, uint seed) Q_DECL_NOTHROW; QSharedDataPointer<QUrlQueryPrivate> d; public: typedef QSharedDataPointer<QUrlQueryPrivate> DataPtr; diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp index ab2025ee5c..1502e5dada 100644 --- a/src/corelib/io/qwindowspipereader.cpp +++ b/src/corelib/io/qwindowspipereader.cpp @@ -45,8 +45,8 @@ QWindowsPipeReader::QWindowsPipeReader(QObject *parent) handle(INVALID_HANDLE_VALUE), readBufferMaxSize(0), actualReadBufferSize(0), - readSequenceStarted(false), emitReadyReadTimer(new QTimer(this)), + readSequenceStarted(false), pipeBroken(false), readyReadEmitted(false) { @@ -133,12 +133,12 @@ qint64 QWindowsPipeReader::read(char *data, qint64 maxlen) actualReadBufferSize--; readSoFar = 1; } else { - qint64 bytesToRead = qMin(qint64(actualReadBufferSize), maxlen); + qint64 bytesToRead = qMin(actualReadBufferSize, maxlen); readSoFar = 0; while (readSoFar < bytesToRead) { const char *ptr = readBuffer.readPointer(); - int bytesToReadFromThisBlock = qMin(bytesToRead - readSoFar, - qint64(readBuffer.nextDataBlockSize())); + qint64 bytesToReadFromThisBlock = qMin(bytesToRead - readSoFar, + readBuffer.nextDataBlockSize()); memcpy(data + readSoFar, ptr, bytesToReadFromThisBlock); readSoFar += bytesToReadFromThisBlock; readBuffer.free(bytesToReadFromThisBlock); diff --git a/src/corelib/io/qwindowspipereader_p.h b/src/corelib/io/qwindowspipereader_p.h index 7904f116cb..53872e2552 100644 --- a/src/corelib/io/qwindowspipereader_p.h +++ b/src/corelib/io/qwindowspipereader_p.h @@ -98,9 +98,9 @@ private: QWinOverlappedIoNotifier *dataReadNotifier; qint64 readBufferMaxSize; QRingBuffer readBuffer; - int actualReadBufferSize; - bool readSequenceStarted; + qint64 actualReadBufferSize; QTimer *emitReadyReadTimer; + bool readSequenceStarted; bool pipeBroken; bool readyReadEmitted; }; |