Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
6.9
-
None
-
185cba6e9 (dev), 11f94598d (6.9)
Description
qdebug.h includes a ton of headers from Qt and the C++ standard library. That cost is basically imposed on anything that includes qdebug.h. Although Qt includes a lot of the standard library on its own (just QList/QString/QVariant alone will end up including <functional>, <algorithm>, <string>, <string_view>, <memory>, <type_traits>, <vector>, <variant>...), qdebug.h goes maybe a bit overboard:
#include <array> #include <chrono> #include <list> #include <map> #include <memory> #include <optional> #include <set> #include <string> #include <string_view> #include <set> #include <tuple> #include <QtCore/q20type_traits.h> #include <unordered_map> #include <unordered_set> #include <utility> #include <unordered_map> #include <unordered_set> #include <vector>
We don't have a good solution for this, such as isolate the streaming operators of C++ types in another header. (A very similar issue exists with qhash.h and the hashers for standard library types.)
However, we have some public headers that include qdebug.h. That means that now including those headers will pull in half of the STL. The heaviest offender is qvariant.h, but a quick search reveals more:
corelib/kernel/qcoreapplication.h 19:#include <QtCore/qdebug.h> network/socket/qlocalsocket.h 12:#include <QtCore/qdebug.h> network/socket/qabstractsocket.h 17:#include <QtCore/qdebug.h> gui/math3d/qgenericmatrix.h 9:#include <QtCore/qdebug.h> corelib/kernel/qvariant.h 12:#include <QtCore/qdebug.h>
Should we try and avoid including qdebug.h from any public header?
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-132439 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
616393,4 | QDebug: split STL includes to a separate header | dev | qt/qtbase | Status: ABANDONED | 0 | 0 |
616434,3 | QDebugStl: add qdebugstl.qdoc and move existing docs to it | dev | qt/qtbase | Status: ABANDONED | -1 | 0 |
616435,14 | Replace qdebug.h includes in public headers with forward-declarations | dev | qt/qtbase | Status: MERGED | +2 | 0 |
616614,1 | QDebug: put STL header includes behind QT_LEAN_HEADERS | dev | qt/qtbase | Status: ABANDONED | -1 | 0 |
617197,2 | Replace qdebug.h includes in public headers with forward-declarations | 6.9 | qt/qtbase | Status: MERGED | +2 | 0 |