Rest of QtBase: sweep Q_DECLARE_METATYPE → QT_DECL_METATYPE_EXTERN

It's one of our best tools to improve compile times.

In some places, we can't do the change, yet, because there's no .cpp
file for the header file.

Also mark Q_DECLARE_METATYPE macros that are in the wrong place. We
shouldn't have Q_D_M markup for public classes in .cpp or _p.h files.

Fixes: QTBUG-102206
Change-Id: Iec0a39e4745571b24d07dacc87593321967c10e3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2022-04-01 09:39:11 +02:00
parent 6963190581
commit 9c21347863
15 changed files with 67 additions and 21 deletions

View File

@ -84,6 +84,13 @@ QT_WARNING_DISABLE_GCC("-Wfree-nonheap-object") // false positive tracking
QT_BEGIN_NAMESPACE
QT_IMPL_METATYPE_EXTERN(QStringView)
QT_IMPL_METATYPE_EXTERN_TAGGED(QList<Qt::DayOfWeek>, QList_Qt__DayOfWeek)
#ifndef QT_NO_SYSTEMLOCALE
QT_IMPL_METATYPE_EXTERN_TAGGED(QSystemLocale::CurrencyToStringArgument,
QSystemLocale__CurrencyToStringArgument)
#endif
using namespace Qt::StringLiterals;
#ifndef QT_NO_SYSTEMLOCALE

View File

@ -58,7 +58,7 @@
#include "QtCore/qvariant.h"
#include "QtCore/qnumeric.h"
#include <QtCore/qcalendar.h>
#include <QtCore/QList> // Q_DECLARE_METATYPE(QList<Qt::DayOfWeek>)
#include <QtCore/qcontainerfwd.h>
#include "qlocale.h"
@ -544,10 +544,13 @@ static_assert(!ascii_isspace(uchar('\377')));
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QStringView)
Q_DECLARE_METATYPE(QList<Qt::DayOfWeek>)
// ### move to qstringview.h
QT_DECL_METATYPE_EXTERN(QStringView, Q_CORE_EXPORT)
// ### move to qnamespace.h
QT_DECL_METATYPE_EXTERN_TAGGED(QList<Qt::DayOfWeek>, QList_Qt__DayOfWeek, Q_CORE_EXPORT)
#ifndef QT_NO_SYSTEMLOCALE
Q_DECLARE_METATYPE(QSystemLocale::CurrencyToStringArgument)
QT_DECL_METATYPE_EXTERN_TAGGED(QSystemLocale::CurrencyToStringArgument,
QSystemLocale__CurrencyToStringArgument, Q_CORE_EXPORT)
#endif
#endif // QLOCALE_P_H

View File

@ -48,6 +48,8 @@
QT_BEGIN_NAMESPACE
QT_IMPL_METATYPE_EXTERN(QOpenGLDebugMessage)
/*!
\class QOpenGLDebugMessage
\brief The QOpenGLDebugMessage class wraps an OpenGL debug message.

View File

@ -213,7 +213,7 @@ private:
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QOpenGLDebugMessage)
QT_DECL_METATYPE_EXTERN(QOpenGLDebugMessage, Q_OPENGL_EXPORT)
#endif // QT_NO_OPENGL

View File

@ -44,6 +44,16 @@
QT_BEGIN_NAMESPACE
QT_IMPL_METATYPE_EXTERN_TAGGED(QCUPSSupport::JobHoldUntil,
QCUPSSupport__JobHoldUntil)
QT_IMPL_METATYPE_EXTERN_TAGGED(QCUPSSupport::BannerPage,
QCUPSSupport__BannerPage)
QT_IMPL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PageSet, QCUPSSupport__PageSet)
QT_IMPL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PagesPerSheetLayout,
QCUPSSupport__PagesPerSheetLayout)
QT_IMPL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PagesPerSheet,
QCUPSSupport__PagesPerSheet)
static QStringList cupsOptionsList(QPrinter *printer) noexcept
{
return printer->printEngine()->property(PPK_CupsOptions).toStringList();

View File

@ -177,10 +177,14 @@ Q_DECLARE_TYPEINFO(QCUPSSupport::PagesPerSheet, Q_PRIMITIVE_TYPE);
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QCUPSSupport::JobHoldUntil)
Q_DECLARE_METATYPE(QCUPSSupport::BannerPage)
Q_DECLARE_METATYPE(QCUPSSupport::PageSet)
Q_DECLARE_METATYPE(QCUPSSupport::PagesPerSheetLayout)
Q_DECLARE_METATYPE(QCUPSSupport::PagesPerSheet)
QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::JobHoldUntil,
QCUPSSupport__JobHoldUntil, Q_PRINTSUPPORT_EXPORT)
QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::BannerPage,
QCUPSSupport__BannerPage, Q_PRINTSUPPORT_EXPORT)
QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PageSet, QCUPSSupport__PageSet, Q_PRINTSUPPORT_EXPORT)
QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PagesPerSheetLayout,
QCUPSSupport__PagesPerSheetLayout, Q_PRINTSUPPORT_EXPORT)
QT_DECL_METATYPE_EXTERN_TAGGED(QCUPSSupport::PagesPerSheet,
QCUPSSupport__PagesPerSheet, Q_PRINTSUPPORT_EXPORT)
#endif

View File

@ -59,6 +59,7 @@
#if (defined Q_OS_MACOS) || (defined Q_OS_UNIX && QT_CONFIG(cups))
#include <cups/ppd.h> // Use for type defs only, don't want to actually link in main module
// ### QT_DECL_METATYPE_EXTERN_TAGGED once there's a qprint.cpp TU
Q_DECLARE_METATYPE(ppd_file_t *)
#endif

View File

@ -44,6 +44,7 @@
#include <QtCore/qvariant.h>
#include <QtPrintSupport/qprinter.h>
// ### move to qmargins.h
Q_DECLARE_METATYPE(QMarginsF)
QT_BEGIN_NAMESPACE

View File

@ -60,6 +60,7 @@
#include <vssym32.h>
#include <dwmapi.h>
// ### move to qmargins.h
Q_DECLARE_METATYPE(QMargins)
#ifndef WM_DWMCOMPOSITIONCHANGED

View File

@ -829,6 +829,8 @@
QT_BEGIN_NAMESPACE
QT_IMPL_METATYPE_EXTERN_TAGGED(QGraphicsItem*, QGraphicsItem_ptr)
static inline void _q_adjustRect(QRect *rect)
{
Q_ASSERT(rect);

View File

@ -1032,10 +1032,6 @@ Q_WIDGETS_EXPORT QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QGraphicsItem *)
QT_BEGIN_NAMESPACE
QT_END_NAMESPACE
QT_DECL_METATYPE_EXTERN_TAGGED(QGraphicsItem*, QGraphicsItem_ptr, Q_WIDGETS_EXPORT)
#endif // QGRAPHICSITEM_H

View File

@ -49,6 +49,13 @@
QT_BEGIN_NAMESPACE
QT_IMPL_METATYPE_EXTERN_TAGGED(Qt::GestureState, Qt__GestureState)
QT_IMPL_METATYPE_EXTERN_TAGGED(Qt::GestureType, Qt__GestureType)
QT_IMPL_METATYPE_EXTERN_TAGGED(QPinchGesture::ChangeFlags,
QPinchGesture__ChangeFlags)
QT_IMPL_METATYPE_EXTERN_TAGGED(QGesture::GestureCancelPolicy,
QGesture__GestureCancelPolicy)
/*!
\class QGesture
\since 4.6

View File

@ -52,8 +52,10 @@
#ifndef QT_NO_GESTURES
Q_DECLARE_METATYPE(Qt::GestureState)
Q_DECLARE_METATYPE(Qt::GestureType)
// ### move to qnamespace.h
QT_DECL_METATYPE_EXTERN_TAGGED(Qt::GestureState, Qt__GestureState, Q_WIDGETS_EXPORT)
// ### move to qnamespace.h
QT_DECL_METATYPE_EXTERN_TAGGED(Qt::GestureType, Qt__GestureType, Q_WIDGETS_EXPORT)
QT_BEGIN_NAMESPACE
@ -201,7 +203,8 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QPinchGesture::ChangeFlags)
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QPinchGesture::ChangeFlags)
QT_DECL_METATYPE_EXTERN_TAGGED(QPinchGesture::ChangeFlags,
QPinchGesture__ChangeFlags, Q_WIDGETS_EXPORT)
QT_BEGIN_NAMESPACE
@ -324,7 +327,9 @@ Q_WIDGETS_EXPORT QDebug operator<<(QDebug, const QGestureEvent *);
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QGesture::GestureCancelPolicy)
QT_DECL_METATYPE_EXTERN_TAGGED(QGesture::GestureCancelPolicy,
QGesture__GestureCancelPolicy, Q_WIDGETS_EXPORT)
#endif // QT_NO_GESTURES
#endif // QGESTURE_H

View File

@ -46,6 +46,11 @@
QT_BEGIN_NAMESPACE
QT_IMPL_METATYPE_EXTERN_TAGGED(QScrollerProperties::OvershootPolicy,
QScrollerProperties__OvershootPolicy)
QT_IMPL_METATYPE_EXTERN_TAGGED(QScrollerProperties::FrameRates,
QScrollerProperties__FrameRates)
static QScrollerPropertiesPrivate *userDefaults = nullptr;
static QScrollerPropertiesPrivate *systemDefaults = nullptr;

View File

@ -130,7 +130,9 @@ private:
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QScrollerProperties::OvershootPolicy)
Q_DECLARE_METATYPE(QScrollerProperties::FrameRates)
QT_DECL_METATYPE_EXTERN_TAGGED(QScrollerProperties::OvershootPolicy,
QScrollerProperties__OvershootPolicy, Q_WIDGETS_EXPORT)
QT_DECL_METATYPE_EXTERN_TAGGED(QScrollerProperties::FrameRates,
QScrollerProperties__FrameRates, Q_WIDGETS_EXPORT)
#endif // QSCROLLERPROPERTIES_H