diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index c72b06f457e..9db36949dc5 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -29,6 +29,8 @@ #define QT_NO_EXCEPTIONS #endif +#define QT_NO_DEBUG_STREAM + #define QT_NO_USING_NAMESPACE #define QT_NO_DEPRECATED diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 3710df8bee2..ea8a32d8d57 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -47,7 +47,7 @@ static void debugBinaryString(const char *input, qint64 maxlen) Q_DECL_COLD_FUNCTION static void checkWarnMessage(const QIODevice *device, const char *function, const char *what) { -#ifndef QT_NO_WARNING_OUTPUT +#if !defined(QT_NO_WARNING_OUTPUT) && !defined(QT_NO_DEBUG_STREAM) QDebug d = qWarning(); d.noquote(); d.nospace(); diff --git a/src/corelib/kernel/qcore_mac.mm b/src/corelib/kernel/qcore_mac.mm index 5af84019787..0c08d4c1c63 100644 --- a/src/corelib/kernel/qcore_mac.mm +++ b/src/corelib/kernel/qcore_mac.mm @@ -174,6 +174,7 @@ os_log_type_t AppleUnifiedLogger::logTypeForMessageType(QtMsgType msgType) #endif // QT_USE_APPLE_UNIFIED_LOGGING +#ifndef QT_NO_DEBUG_STREAM // ------------------------------------------------------------------------- QDebug operator<<(QDebug dbg, id obj) @@ -228,6 +229,7 @@ QT_FOR_EACH_CORE_FOUNDATION_TYPE(QT_DECLARE_WEAK_QDEBUG_OPERATOR_FOR_CF_TYPE); QT_FOR_EACH_MUTABLE_CORE_FOUNDATION_TYPE(QT_DECLARE_WEAK_QDEBUG_OPERATOR_FOR_CF_TYPE); QT_FOR_EACH_CORE_GRAPHICS_TYPE(QT_DECLARE_WEAK_QDEBUG_OPERATOR_FOR_CF_TYPE); QT_FOR_EACH_MUTABLE_CORE_GRAPHICS_TYPE(QT_DECLARE_WEAK_QDEBUG_OPERATOR_FOR_CF_TYPE); +#endif // QT_NO_DEBUG_STREAM // ------------------------------------------------------------------------- @@ -358,13 +360,15 @@ std::optional qt_mac_sipConfiguration() return {}; // SIP config is not available if (auto type = CFGetTypeID(csrConfig); type != CFDataGetTypeID()) { +#ifndef QT_NO_DEBUG_STREAM qWarning() << "Unexpected SIP config type" << CFCopyTypeIDDescription(type); +#endif return {}; } QByteArray data = QByteArray::fromRawCFData(csrConfig.as()); if (data.size() != sizeof(uint32_t)) { - qWarning() << "Unexpected SIP config size" << data.size(); + qWarning("Unexpected SIP config size %td", ptrdiff_t(data.size())); return {}; } diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 3b4e0d60253..7f947234678 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -553,6 +553,7 @@ public: #endif #endif +public: // type erased converter function using ConverterFunction = std::function; @@ -2357,16 +2358,18 @@ struct QLessThanOperatorForType template && !std::is_pointer_v)> struct QDebugStreamOperatorForType +{ + static constexpr QMetaTypeInterface::DebugStreamFn debugStream = nullptr; +}; + +#ifndef QT_NO_DEBUG_STREAM +template +struct QDebugStreamOperatorForType { static void debugStream(const QMetaTypeInterface *, QDebug &dbg, const void *a) { dbg << *reinterpret_cast(a); } }; - -template -struct QDebugStreamOperatorForType -{ - static constexpr QMetaTypeInterface::DebugStreamFn debugStream = nullptr; -}; +#endif template> struct QDataStreamOperatorForType diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 99958f69821..14accbb7041 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -8822,7 +8822,7 @@ QString QString::arg_impl(qlonglong a, int fieldWidth, int base, QChar fillChar) ArgEscapeData d = findArgEscapes(*this); if (d.occurrences == 0) { - qWarning() << "QString::arg: Argument missing:" << *this << ',' << a; + qWarning("QString::arg: Argument missing: \"%ls\", %llu", qUtf16Printable(*this), a); return *this; } @@ -8854,7 +8854,7 @@ QString QString::arg_impl(qulonglong a, int fieldWidth, int base, QChar fillChar ArgEscapeData d = findArgEscapes(*this); if (d.occurrences == 0) { - qWarning() << "QString::arg: Argument missing:" << *this << ',' << a; + qWarning("QString::arg: Argument missing: \"%ls\", %lld", qUtf16Printable(*this), a); return *this; } diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp index 21de967a80d..2e8eb5665e6 100644 --- a/src/corelib/tools/qcommandlineparser.cpp +++ b/src/corelib/tools/qcommandlineparser.cpp @@ -335,7 +335,7 @@ bool QCommandLineParser::addOption(const QCommandLineOption &option) if (!optionNames.isEmpty()) { for (const QString &name : optionNames) { if (d->nameHash.contains(name)) { - qWarning() << "QCommandLineParser: already having an option named" << name; + qWarning("QCommandLineParser: option already added: \"%ls\"", qUtf16Printable(name)); return false; } } diff --git a/src/tools/bootstrap/CMakeLists.txt b/src/tools/bootstrap/CMakeLists.txt index a5045bc30f7..e00e2839f6c 100644 --- a/src/tools/bootstrap/CMakeLists.txt +++ b/src/tools/bootstrap/CMakeLists.txt @@ -21,7 +21,6 @@ qt_internal_extend_target(Bootstrap ../../corelib/global/qlogging.cpp ../../corelib/global/qtenvironmentvariables.cpp ../../corelib/io/qabstractfileengine.cpp - ../../corelib/io/qdebug.cpp ../../corelib/io/qdir.cpp ../../corelib/io/qfile.cpp ../../corelib/io/qfiledevice.cpp diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index 051161d1f92..cefe9648b04 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -6727,17 +6727,17 @@ void tst_QString::arg() QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: , foo"); QCOMPARE(QString().arg(foo), QString()); - QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"\" , 0"); + QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"\", 0"); QCOMPARE( QString().arg(0), QString() ); - QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"\" , 0"); + QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"\", 0"); QCOMPARE(QString(u""_s).arg(0), u""_s); - QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \" \" , 0"); + QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \" \", 0"); QCOMPARE(QString(u" "_s).arg(0), " "_L1); - QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"%\" , 0"); + QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"%\", 0"); QCOMPARE(QString(u"%"_s).arg(0), "%"_L1); - QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"%%\" , 0"); + QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"%%\", 0"); QCOMPARE(QString(u"%%"_s).arg(0), "%%"_L1); - QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"%%%\" , 0"); + QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: \"%%%\", 0"); QCOMPARE(QString(u"%%%"_s).arg(0), "%%%"_L1); QCOMPARE(QString(u"%%%1%%%2"_s).arg(foo).arg(bar), "%%foo%%bar"_L1); diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp index fca0435abd7..51edf7a1ea7 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp @@ -94,7 +94,7 @@ void tst_QCommandLineParser::testDuplicateOption() QCoreApplication app(empty_argc, empty_argv); QCommandLineParser parser; QVERIFY(parser.addOption(QCommandLineOption(QStringLiteral("h"), QStringLiteral("Hostname."), QStringLiteral("hostname")))); - QTest::ignoreMessage(QtWarningMsg, "QCommandLineParser: already having an option named \"h\""); + QTest::ignoreMessage(QtWarningMsg, "QCommandLineParser: option already added: \"h\""); parser.addHelpOption(); }