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
#endif
#define QT_NO_DEBUG_STREAM
#define QT_NO_USING_NAMESPACE
#define QT_NO_DEPRECATED

View File

@ -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();

View File

@ -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<uint32_t> 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<CFDataRef>());
if (data.size() != sizeof(uint32_t)) {
qWarning() << "Unexpected SIP config size" << data.size();
qWarning("Unexpected SIP config size %td", ptrdiff_t(data.size()));
return {};
}

View File

@ -553,6 +553,7 @@ public:
#endif
#endif
public:
// type erased converter function
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>)>
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)
{ dbg << *reinterpret_cast<const T *>(a); }
};
template<typename T>
struct QDebugStreamOperatorForType <T, false>
{
static constexpr QMetaTypeInterface::DebugStreamFn debugStream = nullptr;
};
#endif
template<typename T, bool = QTypeTraits::has_stream_operator_v<QDataStream, T>>
struct QDataStreamOperatorForType

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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

View File

@ -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);

View File

@ -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();
}