Replace qdebug.h includes in public headers with forward-declarations

qdebug.h includes many Qt and STL headers, so if you include a Qt header
you get all those transitive includes, which may affect build time.

- Where appropriate use the printf-like syntax of qDebug() and co.,
  these don't need the QDebug streaming operators
- qfloat16 is used in an inline member function, so include it
  explicitly

[ChangeLog][Potentially Source Incompatible Changes] Various Qt public
headers don't include QDebug any more; if you need QDebug's streaming
you'll have to include it in your code.

Task-number: QTBUG-132439
Change-Id: I750587e17a3b38fa226cd3af8eaccc8da580f436
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 185cba6e95a006d2548f20599f84390e5a3ad653)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Ahmad Samir 2025-01-01 17:03:54 +02:00 committed by Qt Cherry-pick Bot
parent 1a98e24d0c
commit 11f94598da
26 changed files with 34 additions and 23 deletions

View File

@ -7,6 +7,7 @@
#include <QCalendar> #include <QCalendar>
#include <QCalendarWidget> #include <QCalendarWidget>
#include <QCommandLineParser> #include <QCommandLineParser>
#include <QDebug>
#include <QPluginLoader> #include <QPluginLoader>
int main(int argc, char *argv[]) int main(int argc, char *argv[])

View File

@ -3,9 +3,11 @@
#include <QtWidgets/qfiledialog.h> #include <QtWidgets/qfiledialog.h>
#include <QtWidgets/qapplication.h> #include <QtWidgets/qapplication.h>
#include <QtCore/qdebug.h>
#include <QtCore/qmimedatabase.h> #include <QtCore/qmimedatabase.h>
#include <QtCore/qelapsedtimer.h> #include <QtCore/qelapsedtimer.h>
#include <QtConcurrent/qtconcurrentmap.h> #include <QtConcurrent/qtconcurrentmap.h>
#include <QtCore/qtextstream.h>
typedef QMap<QString, int> WordCount; typedef QMap<QString, int> WordCount;

View File

@ -4,6 +4,7 @@
#include "browser.h" #include "browser.h"
#include <QApplication> #include <QApplication>
#include <QDebug>
#include <QMainWindow> #include <QMainWindow>
#include <QMenu> #include <QMenu>
#include <QMenuBar> #include <QMenuBar>

View File

@ -6,6 +6,7 @@
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
#include <QPainter> #include <QPainter>
#include <QStyleOptionGraphicsItem> #include <QStyleOptionGraphicsItem>
#include <QVarLengthArray>
Chip::Chip(const QColor &color, int x, int y) Chip::Chip(const QColor &color, int x, int y)
{ {

View File

@ -4,6 +4,7 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "treemodel.h" #include "treemodel.h"
#include <QDebug>
#include <QFile> #include <QFile>
using namespace Qt::StringLiterals; using namespace Qt::StringLiterals;

View File

@ -14,6 +14,7 @@
# include <QContextMenuEvent> # include <QContextMenuEvent>
#endif #endif
#include <QTextStream>
#include <QUrl> #include <QUrl>
using namespace Qt::StringLiterals; using namespace Qt::StringLiterals;

View File

@ -11,6 +11,7 @@
#include <QtCore/qcompare.h> #include <QtCore/qcompare.h>
#include <QtCore/qcontainerfwd.h> #include <QtCore/qcontainerfwd.h>
#include <QtCore/qfloat16.h>
#include <QtCore/qtextstream.h> #include <QtCore/qtextstream.h>
#include <QtCore/qttypetraits.h> #include <QtCore/qttypetraits.h>
#include <QtCore/qtypes.h> #include <QtCore/qtypes.h>

View File

@ -15,9 +15,6 @@
#include <QtCore/qscopedpointer.h> #include <QtCore/qscopedpointer.h>
#endif #endif
#include <QtCore/qnativeinterface.h> #include <QtCore/qnativeinterface.h>
#ifndef QT_NO_DEBUGSTREAM
#include <QtCore/qdebug.h>
#endif
#ifndef QT_NO_QOBJECT #ifndef QT_NO_QOBJECT
#if defined(Q_OS_WIN) && !defined(tagMSG) #if defined(Q_OS_WIN) && !defined(tagMSG)
@ -29,6 +26,7 @@ QT_BEGIN_NAMESPACE
class QCoreApplicationPrivate; class QCoreApplicationPrivate;
class QDebug;
class QTranslator; class QTranslator;
class QPostEventList; class QPostEventList;
class QAbstractEventDispatcher; class QAbstractEventDispatcher;

View File

@ -6,7 +6,6 @@
#include <QtCore/qobjectdefs.h> #include <QtCore/qobjectdefs.h>
#include <QtCore/qmetatype.h> #include <QtCore/qmetatype.h>
#include <QtCore/qdebug.h>
#if 0 #if 0
#pragma qt_class(QtCborCommon) #pragma qt_class(QtCborCommon)
@ -20,6 +19,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QDebug;
enum class QCborSimpleType : quint8 { enum class QCborSimpleType : quint8 {
False = 20, False = 20,
True = 21, True = 21,

View File

@ -15,6 +15,7 @@
#include "qcborstreamwriter.h" #include "qcborstreamwriter.h"
#endif #endif
#include <QtCore/qdebug.h>
#include <qendian.h> #include <qendian.h>
#include <qlocale.h> #include <qlocale.h>
#include <qdatetime.h> #include <qdatetime.h>

View File

@ -897,8 +897,8 @@ void QFutureInterfaceBase::setContinuation(std::function<void(const QFutureInter
// future's data stays alive. // future's data stays alive.
if (d->continuationState != QFutureInterfaceBasePrivate::Cleaned) { if (d->continuationState != QFutureInterfaceBasePrivate::Cleaned) {
if (d->continuation) { if (d->continuation) {
qWarning() << "Adding a continuation to a future which already has a continuation. " qWarning("Adding a continuation to a future which already has a continuation. "
"The existing continuation is overwritten."; "The existing continuation is overwritten.");
} }
d->continuation = std::move(func); d->continuation = std::move(func);
d->continuationData = continuationFutureData; d->continuationData = continuationFutureData;

View File

@ -245,8 +245,9 @@ const MetaZoneData *metaZoneDataFor(const MetaZoneData *from, QLocale::Territory
// Fall back to World (if territory itself isn't World). // Fall back to World (if territory itself isn't World).
} while (std::exchange(land, QLocale::World) != QLocale::World); } while (std::exchange(land, QLocale::World) != QLocale::World);
qWarning() << "Metazone" << from->metaZoneId() << "lacks World data for" qWarning("Metazone %s lacks World data for %ls",
<< QLocale::territoryToString(territory); from->metaZoneId().constData(),
qUtf16Printable(QLocale::territoryToString(territory)));
return nullptr; return nullptr;
} }

View File

@ -15,7 +15,6 @@
#if QT_CONFIG(accessibility) #if QT_CONFIG(accessibility)
#include <QtCore/qcoreapplication.h> #include <QtCore/qcoreapplication.h>
#include <QtCore/qdebug.h>
#include <QtCore/qglobal.h> #include <QtCore/qglobal.h>
#include <QtCore/qlist.h> #include <QtCore/qlist.h>
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
@ -28,6 +27,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QDebug;
class QAccessibleInterface; class QAccessibleInterface;
class QAccessibleEvent; class QAccessibleEvent;
class QWindow; class QWindow;

View File

@ -48,7 +48,6 @@ typedef int VkDebugReportObjectTypeEXT;
#if __has_include(<vulkan/vulkan.h>) || defined(Q_QDOC) #if __has_include(<vulkan/vulkan.h>) || defined(Q_QDOC)
#include <QtCore/qbytearraylist.h> #include <QtCore/qbytearraylist.h>
#include <QtCore/qdebug.h>
#include <QtCore/qhashfunctions.h> #include <QtCore/qhashfunctions.h>
#include <QtCore/qlist.h> #include <QtCore/qlist.h>
#include <QtCore/qscopedpointer.h> #include <QtCore/qscopedpointer.h>
@ -56,6 +55,8 @@ typedef int VkDebugReportObjectTypeEXT;
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QDebug;
class QVulkanInstancePrivate; class QVulkanInstancePrivate;
class QPlatformVulkanInstance; class QPlatformVulkanInstance;
class QVulkanFunctions; class QVulkanFunctions;

View File

@ -4,6 +4,7 @@
#include "qhttpmultipart.h" #include "qhttpmultipart.h"
#include "qhttpmultipart_p.h" #include "qhttpmultipart_p.h"
#include "QtCore/qdatetime.h" // for initializing the random number generator with QTime #include "QtCore/qdatetime.h" // for initializing the random number generator with QTime
#include <QtCore/qdebug.h>
#include "QtCore/qmutex.h" #include "QtCore/qmutex.h"
#include "QtCore/qrandom.h" #include "QtCore/qrandom.h"

View File

@ -13,6 +13,8 @@
#include <QtCore/q26numeric.h> #include <QtCore/q26numeric.h>
#include <chrono>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QSslConfiguration; class QSslConfiguration;

View File

@ -435,6 +435,7 @@
#include "private/qhostinfo_p.h" #include "private/qhostinfo_p.h"
#include <qabstracteventdispatcher.h> #include <qabstracteventdispatcher.h>
#include <QtCore/qdebug.h>
#include <qhostaddress.h> #include <qhostaddress.h>
#include <qhostinfo.h> #include <qhostinfo.h>
#include <qmetaobject.h> #include <qmetaobject.h>

View File

@ -13,12 +13,10 @@
#endif #endif
#include <QtCore/qiodevice.h> #include <QtCore/qiodevice.h>
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#ifndef QT_NO_DEBUG_STREAM
#include <QtCore/qdebug.h>
#endif
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QDebug;
class QHostAddress; class QHostAddress;
#ifndef QT_NO_NETWORKPROXY #ifndef QT_NO_NETWORKPROXY

View File

@ -6,6 +6,8 @@
#include "qlocalsocket.h" #include "qlocalsocket.h"
#include "qlocalsocket_p.h" #include "qlocalsocket_p.h"
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
/*! /*!

View File

@ -8,14 +8,11 @@
#include <QtCore/qiodevice.h> #include <QtCore/qiodevice.h>
#include <QtNetwork/qabstractsocket.h> #include <QtNetwork/qabstractsocket.h>
#ifndef QT_NO_DEBUG_STREAM
#include <QtCore/qdebug.h>
#endif
QT_REQUIRE_CONFIG(localserver); QT_REQUIRE_CONFIG(localserver);
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QDebug;
class QLocalSocketPrivate; class QLocalSocketPrivate;
class Q_NETWORK_EXPORT QLocalSocket : public QIODevice class Q_NETWORK_EXPORT QLocalSocket : public QIODevice

View File

@ -6,6 +6,7 @@
#define QSSLERROR_H #define QSSLERROR_H
#include <QtNetwork/qtnetworkglobal.h> #include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qdebug.h>
#include <QtCore/qvariant.h> #include <QtCore/qvariant.h>
#include <QtNetwork/qsslcertificate.h> #include <QtNetwork/qsslcertificate.h>

View File

@ -12,7 +12,6 @@
#include <QtCore/qflags.h> #include <QtCore/qflags.h>
#include <QtCore/qlist.h> #include <QtCore/qlist.h>
#include <QtCore/qmetatype.h> #include <QtCore/qmetatype.h>
#include <QtCore/qdebug.h>
#include <QtGui/qopenglcontext.h> #include <QtGui/qopenglcontext.h>
#if defined(Q_QDOC) #if defined(Q_QDOC)
@ -22,6 +21,7 @@ typedef unsigned int GLuint;
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QDebug;
class QOpenGLDebugLogger; class QOpenGLDebugLogger;
class QOpenGLDebugLoggerPrivate; class QOpenGLDebugLoggerPrivate;
class QOpenGLDebugMessagePrivate; class QOpenGLDebugMessagePrivate;

View File

@ -6,10 +6,6 @@
#include <sys/keycodes.h> #include <sys/keycodes.h>
#if defined(QQNXEVENTTHREAD_DEBUG)
#include <QtCore/QDebug>
#endif
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
int qtKeyForPrivateUseQnxKey( int key ) int qtKeyForPrivateUseQnxKey( int key )
@ -79,7 +75,7 @@ int qtKeyForPrivateUseQnxKey( int key )
default: default:
#if defined(QQNXEVENTTHREAD_DEBUG) #if defined(QQNXEVENTTHREAD_DEBUG)
qDebug() << "QQNX: unknown key for translation:" << key; qDebug("QQNX: unknown key for translation: %d", key);
#endif #endif
break; break;
} }

View File

@ -3,6 +3,7 @@
#include "qwasmdom.h" #include "qwasmdom.h"
#include <QtCore/qdebug.h>
#include <QtCore/qdir.h> #include <QtCore/qdir.h>
#include <QtCore/qfile.h> #include <QtCore/qfile.h>
#include <QtCore/qpoint.h> #include <QtCore/qpoint.h>

View File

@ -18,6 +18,7 @@
#include <QtCore/qcborcommon.h> #include <QtCore/qcborcommon.h>
#include <QtCore/qcbormap.h> #include <QtCore/qcbormap.h>
#include <QtCore/qcborvalue.h> #include <QtCore/qcborvalue.h>
#include <QtCore/qdebug.h>
#include <QtCore/qdatetime.h> #include <QtCore/qdatetime.h>
#include <QtCore/qmetaobject.h> #include <QtCore/qmetaobject.h>
#include <QtCore/qmetatype.h> #include <QtCore/qmetatype.h>

View File

@ -4,6 +4,7 @@
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QtCore/QDeadlineTimer> #include <QtCore/QDeadlineTimer>
#include <QtCore/qdebug.h>
#include <QtCore/QDir> #include <QtCore/QDir>
#include <QtCore/QHash> #include <QtCore/QHash>
#include <QtCore/QProcess> #include <QtCore/QProcess>