summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-09-03 12:21:46 +0200
committerLars Knoll <lars.knoll@qt.io>2020-09-11 19:32:36 +0200
commit1316a0aef287e47d63aab247751842a901d8f786 (patch)
treeaccd64be2c7bc3b8bcf946a364821d833b24aec4 /src
parentdefc8414fde0ea9f52fe554e00fe2f04947b7578 (diff)
Fix Qt6 related comments in qdebug
Change-Id: I9861d29a6615863094cd007178f214a816865eb7 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qdebug.cpp19
-rw-r--r--src/corelib/io/qdebug.h59
2 files changed, 33 insertions, 45 deletions
diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp
index d34c2e5a36..c711c28f62 100644
--- a/src/corelib/io/qdebug.cpp
+++ b/src/corelib/io/qdebug.cpp
@@ -304,7 +304,7 @@ static inline void putEscapedString(QTextStreamPrivate *d, const Char *begin, in
*/
void QDebug::putString(const QChar *begin, size_t length)
{
- if (stream->testFlag(Stream::NoQuotes)) {
+ if (stream->noQuotes) {
// no quotes, write the string directly too (no pretty-printing)
// this respects the QTextStream state, though
stream->ts.d_ptr->putString(begin, int(length));
@@ -322,7 +322,7 @@ void QDebug::putString(const QChar *begin, size_t length)
*/
void QDebug::putByteArray(const char *begin, size_t length, Latin1Content content)
{
- if (stream->testFlag(Stream::NoQuotes)) {
+ if (stream->noQuotes) {
// no quotes, write the string directly too (no pretty-printing)
// this respects the QTextStream state, though
QString string = content == ContainsLatin1 ? QString::fromLatin1(begin, int(length)) : QString::fromUtf8(begin, int(length));
@@ -354,9 +354,8 @@ QDebug &QDebug::resetFormat()
{
stream->ts.reset();
stream->space = true;
- if (stream->context.version > 1)
- stream->flags = 0;
- stream->setVerbosity(DefaultVerbosity);
+ stream->noQuotes = false;
+ stream->verbosity = DefaultVerbosity;
return *this;
}
@@ -853,7 +852,8 @@ public:
QDebugStateSaverPrivate(QDebug::Stream *stream)
: m_stream(stream),
m_spaces(stream->space),
- m_flags(stream->context.version > 1 ? stream->flags : 0),
+ m_noQuotes(stream->noQuotes),
+ m_verbosity(stream->verbosity),
m_streamParams(stream->ts.d_ptr->params)
{
}
@@ -865,9 +865,9 @@ public:
m_stream->buffer.chop(1);
m_stream->space = m_spaces;
+ m_stream->noQuotes = m_noQuotes;
m_stream->ts.d_ptr->params = m_streamParams;
- if (m_stream->context.version > 1)
- m_stream->flags = m_flags;
+ m_stream->verbosity = m_verbosity;
if (!currentSpaces && m_spaces)
m_stream->ts << ' ';
@@ -877,7 +877,8 @@ public:
// QDebug state
const bool m_spaces;
- const int m_flags;
+ const bool m_noQuotes;
+ const int m_verbosity;
// QTextStream state
const QTextStreamPrivate::Params m_streamParams;
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h
index b3787f9e78..2663fceb65 100644
--- a/src/corelib/io/qdebug.h
+++ b/src/corelib/io/qdebug.h
@@ -68,39 +68,26 @@ class Q_CORE_EXPORT QDebug : public QIODeviceBase
struct Stream {
enum { 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, WriteOnly), ref(1), type(QtDebugMsg),
- space(true), message_output(false), flags(DefaultVerbosity << VerbosityShift) {}
- Stream(QtMsgType t) : ts(&buffer, WriteOnly), ref(1), type(t),
- space(true), message_output(true), flags(DefaultVerbosity << VerbosityShift) {}
+ Stream(QIODevice *device)
+ : ts(device)
+ {}
+ Stream(QString *string)
+ : ts(string, WriteOnly)
+ {}
+ Stream(QtMsgType t)
+ : ts(&buffer, WriteOnly),
+ type(t),
+ message_output(true)
+ {}
QTextStream ts;
QString buffer;
- int ref;
- QtMsgType type;
- bool space;
- bool message_output;
+ int ref = 1;
+ QtMsgType type = QtDebugMsg;
+ bool space = true;
+ bool noQuotes = false;
+ bool message_output = false;
+ int verbosity = DefaultVerbosity;
QMessageLogContext context;
-
- enum FormatFlag { // Note: Bits 29..31 are reserved for the verbose level introduced in 5.6.
- NoQuotes = 0x1
- };
-
- // ### Qt 6: unify with space, introduce own version member
- 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(DefaultVerbosity); }
- void setVerbosity(int v)
- {
- if (context.version > 1) {
- flags &= ~(uint(VerbosityMask) << VerbosityShift);
- flags |= (v & VerbosityMask) << VerbosityShift;
- }
- }
- // added in 5.4
- int flags;
} *stream;
enum Latin1Content { ContainsBinary = 0, ContainsLatin1 };
@@ -125,17 +112,17 @@ 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; }
- inline QDebug &verbosity(int verbosityLevel) { setVerbosity(verbosityLevel); return *this; }
- int verbosity() const { return stream->verbosity(); }
- void setVerbosity(int verbosityLevel) { stream->setVerbosity(verbosityLevel); }
+ inline QDebug &verbosity(int verbosityLevel) { stream->verbosity = verbosityLevel; return *this; }
+ int verbosity() const { return stream->verbosity; }
+ void setVerbosity(int verbosityLevel) { stream->verbosity = verbosityLevel; }
enum VerbosityLevel { MinimumVerbosity = 0, DefaultVerbosity = 2, MaximumVerbosity = 7 };
bool autoInsertSpaces() const { return stream->space; }
void setAutoInsertSpaces(bool b) { stream->space = b; }
- inline QDebug &quote() { stream->unsetFlag(Stream::NoQuotes); return *this; }
- inline QDebug &noquote() { stream->setFlag(Stream::NoQuotes); return *this; }
- inline QDebug &maybeQuote(char c = '"') { if (!(stream->testFlag(Stream::NoQuotes))) stream->ts << c; return *this; }
+ inline QDebug &quote() { stream->noQuotes = false; return *this; }
+ inline QDebug &noquote() { stream->noQuotes = true; return *this; }
+ inline QDebug &maybeQuote(char c = '"') { if (!stream->noQuotes) stream->ts << c; return *this; }
inline QDebug &operator<<(QChar t) { putUcs4(t.unicode()); return maybeSpace(); }
inline QDebug &operator<<(bool t) { stream->ts << (t ? "true" : "false"); return maybeSpace(); }