Bootstrap: remove the QDebug streaming class

And fix some compilation bugs if QT_NO_DEBUG_STREAM is defined.

Drive-by fix the grammar in the qcommandlineparser.cpp qWarning().

Change-Id: Ia9287ea189ae4a4b7545fffdbff7dbb9196de519
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
This commit is contained in:
Thiago Macieira 2024-12-29 15:17:37 -03:00
parent 2d40e30e34
commit 24b5cea95c
9 changed files with 27 additions and 19 deletions

View File

@ -29,6 +29,8 @@
#define QT_NO_EXCEPTIONS #define QT_NO_EXCEPTIONS
#endif #endif
#define QT_NO_DEBUG_STREAM
#define QT_NO_USING_NAMESPACE #define QT_NO_USING_NAMESPACE
#define QT_NO_DEPRECATED #define QT_NO_DEPRECATED

View File

@ -47,7 +47,7 @@ static void debugBinaryString(const char *input, qint64 maxlen)
Q_DECL_COLD_FUNCTION Q_DECL_COLD_FUNCTION
static void checkWarnMessage(const QIODevice *device, const char *function, const char *what) 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(); QDebug d = qWarning();
d.noquote(); d.noquote();
d.nospace(); d.nospace();

View File

@ -174,6 +174,7 @@ os_log_type_t AppleUnifiedLogger::logTypeForMessageType(QtMsgType msgType)
#endif // QT_USE_APPLE_UNIFIED_LOGGING #endif // QT_USE_APPLE_UNIFIED_LOGGING
#ifndef QT_NO_DEBUG_STREAM
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
QDebug operator<<(QDebug dbg, id obj) 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_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_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); 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<uint32_t> qt_mac_sipConfiguration()
return {}; // SIP config is not available return {}; // SIP config is not available
if (auto type = CFGetTypeID(csrConfig); type != CFDataGetTypeID()) { if (auto type = CFGetTypeID(csrConfig); type != CFDataGetTypeID()) {
#ifndef QT_NO_DEBUG_STREAM
qWarning() << "Unexpected SIP config type" << CFCopyTypeIDDescription(type); qWarning() << "Unexpected SIP config type" << CFCopyTypeIDDescription(type);
#endif
return {}; return {};
} }
QByteArray data = QByteArray::fromRawCFData(csrConfig.as<CFDataRef>()); QByteArray data = QByteArray::fromRawCFData(csrConfig.as<CFDataRef>());
if (data.size() != sizeof(uint32_t)) { if (data.size() != sizeof(uint32_t)) {
qWarning() << "Unexpected SIP config size" << data.size(); qWarning("Unexpected SIP config size %td", ptrdiff_t(data.size()));
return {}; return {};
} }

View File

@ -553,6 +553,7 @@ public:
#endif #endif
#endif #endif
public:
// type erased converter function // type erased converter function
using ConverterFunction = std::function<bool(const void *src, void *target)>; using ConverterFunction = std::function<bool(const void *src, void *target)>;
@ -2357,16 +2358,18 @@ struct QLessThanOperatorForType <T, false>
template<typename T, bool = (QTypeTraits::has_ostream_operator_v<QDebug, T> && !std::is_pointer_v<T>)> template<typename T, bool = (QTypeTraits::has_ostream_operator_v<QDebug, T> && !std::is_pointer_v<T>)>
struct QDebugStreamOperatorForType struct QDebugStreamOperatorForType
{
static constexpr QMetaTypeInterface::DebugStreamFn debugStream = nullptr;
};
#ifndef QT_NO_DEBUG_STREAM
template<typename T>
struct QDebugStreamOperatorForType <T, true>
{ {
static void debugStream(const QMetaTypeInterface *, QDebug &dbg, const void *a) static void debugStream(const QMetaTypeInterface *, QDebug &dbg, const void *a)
{ dbg << *reinterpret_cast<const T *>(a); } { dbg << *reinterpret_cast<const T *>(a); }
}; };
#endif
template<typename T>
struct QDebugStreamOperatorForType <T, false>
{
static constexpr QMetaTypeInterface::DebugStreamFn debugStream = nullptr;
};
template<typename T, bool = QTypeTraits::has_stream_operator_v<QDataStream, T>> template<typename T, bool = QTypeTraits::has_stream_operator_v<QDataStream, T>>
struct QDataStreamOperatorForType struct QDataStreamOperatorForType

View File

@ -8822,7 +8822,7 @@ QString QString::arg_impl(qlonglong a, int fieldWidth, int base, QChar fillChar)
ArgEscapeData d = findArgEscapes(*this); ArgEscapeData d = findArgEscapes(*this);
if (d.occurrences == 0) { if (d.occurrences == 0) {
qWarning() << "QString::arg: Argument missing:" << *this << ',' << a; qWarning("QString::arg: Argument missing: \"%ls\", %llu", qUtf16Printable(*this), a);
return *this; return *this;
} }
@ -8854,7 +8854,7 @@ QString QString::arg_impl(qulonglong a, int fieldWidth, int base, QChar fillChar
ArgEscapeData d = findArgEscapes(*this); ArgEscapeData d = findArgEscapes(*this);
if (d.occurrences == 0) { if (d.occurrences == 0) {
qWarning() << "QString::arg: Argument missing:" << *this << ',' << a; qWarning("QString::arg: Argument missing: \"%ls\", %lld", qUtf16Printable(*this), a);
return *this; return *this;
} }

View File

@ -335,7 +335,7 @@ bool QCommandLineParser::addOption(const QCommandLineOption &option)
if (!optionNames.isEmpty()) { if (!optionNames.isEmpty()) {
for (const QString &name : optionNames) { for (const QString &name : optionNames) {
if (d->nameHash.contains(name)) { if (d->nameHash.contains(name)) {
qWarning() << "QCommandLineParser: already having an option named" << name; qWarning("QCommandLineParser: option already added: \"%ls\"", qUtf16Printable(name));
return false; return false;
} }
} }

View File

@ -21,7 +21,6 @@ qt_internal_extend_target(Bootstrap
../../corelib/global/qlogging.cpp ../../corelib/global/qlogging.cpp
../../corelib/global/qtenvironmentvariables.cpp ../../corelib/global/qtenvironmentvariables.cpp
../../corelib/io/qabstractfileengine.cpp ../../corelib/io/qabstractfileengine.cpp
../../corelib/io/qdebug.cpp
../../corelib/io/qdir.cpp ../../corelib/io/qdir.cpp
../../corelib/io/qfile.cpp ../../corelib/io/qfile.cpp
../../corelib/io/qfiledevice.cpp ../../corelib/io/qfiledevice.cpp

View File

@ -6727,17 +6727,17 @@ void tst_QString::arg()
QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: , foo"); QTest::ignoreMessage(QtWarningMsg, "QString::arg: Argument missing: , foo");
QCOMPARE(QString().arg(foo), QString()); 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() ); 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); 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); 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"%"_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"%%"_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"%%%"_s).arg(0), "%%%"_L1);
QCOMPARE(QString(u"%%%1%%%2"_s).arg(foo).arg(bar), "%%foo%%bar"_L1); QCOMPARE(QString(u"%%%1%%%2"_s).arg(foo).arg(bar), "%%foo%%bar"_L1);

View File

@ -94,7 +94,7 @@ void tst_QCommandLineParser::testDuplicateOption()
QCoreApplication app(empty_argc, empty_argv); QCoreApplication app(empty_argc, empty_argv);
QCommandLineParser parser; QCommandLineParser parser;
QVERIFY(parser.addOption(QCommandLineOption(QStringLiteral("h"), QStringLiteral("Hostname."), QStringLiteral("hostname")))); 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(); parser.addHelpOption();
} }