summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-01-18 17:38:48 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-01-21 11:22:35 +0000
commitf29566c5a41c127eacaf13f3dbfe4624e55bc83f (patch)
tree65af6e3512b5f3cad8f9839dad98d284e1620a5c /src
parent4440387b85bbed53f4b118b8098cc616b4e6c92a (diff)
Prevent repeated instantiations of some qRegisterNormalizedMetaType<>s [1/N] (QtGui)
Create macros that wrap the magic developed in 7d63efc16f65f98c657caa90e0d7e9b72a879ade and apply it to all Q_DECLARE_METATYPE invocations that show up in Clang -ftime-trace for a PCH'ed QtGui build. Effects on compile times: Clang 10 -ftme-trace: $ ClangBuildAnalyzer --analyze qtgui-before.trace | head -n6 Analyzing build trace from 'qtgui-before.trace'... **** Time summary: Compilation (523 times): Parsing (frontend): 628.3 s Codegen & opts (backend): 304.5 s $ ClangBuildAnalyzer --analyze qtgui-after.trace | head -n6 Analyzing build trace from 'qtgui-after.trace'... **** Time summary: Compilation (523 times): Parsing (frontend): 546.0 s Codegen & opts (backend): 304.4 s GCC 11 time (bash builtin): before: $ time for ((i=0; i < 3; ++i)) do touch src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done real 4m13,539s user 49m24,416s sys 3m18,177s after: $ time for ((i=0; i < 3; ++i)) do touch src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done real 3m55,697s user 45m19,941s sys 3m7,370s Task-number: QTBUG-97601 Pick-to: 6.3 Change-Id: Ia8e37a58937568a7ed21cfeb4b27274deca4d53b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/global/qfloat16.cpp2
-rw-r--r--src/corelib/global/qfloat16.h2
-rw-r--r--src/corelib/io/qfileinfo.cpp2
-rw-r--r--src/corelib/io/qfileinfo.h2
-rw-r--r--src/corelib/io/qstorageinfo.cpp2
-rw-r--r--src/corelib/io/qstorageinfo.h2
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp3
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.h6
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.cpp3
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.h4
-rw-r--r--src/corelib/kernel/qdeadlinetimer.cpp2
-rw-r--r--src/corelib/kernel/qdeadlinetimer.h2
-rw-r--r--src/corelib/kernel/qmetatype.cpp1
-rw-r--r--src/corelib/kernel/qmetatype.h32
-rw-r--r--src/corelib/kernel/qsocketnotifier.cpp3
-rw-r--r--src/corelib/kernel/qsocketnotifier.h5
-rw-r--r--src/corelib/serialization/qcborcommon.cpp2
-rw-r--r--src/corelib/serialization/qcborcommon.h2
-rw-r--r--src/corelib/tools/qversionnumber.cpp3
-rw-r--r--src/corelib/tools/qversionnumber.h4
-rw-r--r--src/dbus/qdbuserror.cpp2
-rw-r--r--src/dbus/qdbuserror.h2
-rw-r--r--src/dbus/qdbusextratypes.cpp4
-rw-r--r--src/dbus/qdbusextratypes.h6
-rw-r--r--src/dbus/qdbusmessage.cpp2
-rw-r--r--src/dbus/qdbusmessage.h2
-rw-r--r--src/dbus/qdbusunixfiledescriptor.cpp2
-rw-r--r--src/dbus/qdbusunixfiledescriptor.h2
-rw-r--r--src/gui/kernel/qsurface.cpp1
-rw-r--r--src/gui/kernel/qsurface.h2
-rw-r--r--src/gui/text/qtextoption.cpp2
-rw-r--r--src/gui/text/qtextoption.h2
32 files changed, 80 insertions, 33 deletions
diff --git a/src/corelib/global/qfloat16.cpp b/src/corelib/global/qfloat16.cpp
index 834d82e0ea..9646943620 100644
--- a/src/corelib/global/qfloat16.cpp
+++ b/src/corelib/global/qfloat16.cpp
@@ -44,6 +44,8 @@
QT_BEGIN_NAMESPACE
+QT_IMPL_METATYPE_EXTERN(qfloat16)
+
/*!
\class qfloat16
\keyword 16-bit Floating Point Support
diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h
index 59739fdcc1..a178563889 100644
--- a/src/corelib/global/qfloat16.h
+++ b/src/corelib/global/qfloat16.h
@@ -367,7 +367,7 @@ inline auto qHypot(qfloat16 x, qfloat16 y, qfloat16 z)
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(qfloat16)
+QT_DECL_METATYPE_EXTERN(qfloat16, Q_CORE_EXPORT)
namespace std {
template<>
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index da19ba625c..dcbfae0d3f 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -46,6 +46,8 @@
QT_BEGIN_NAMESPACE
+QT_IMPL_METATYPE_EXTERN(QFileInfo)
+
QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const
{
if (cache_enabled && !fileNames[(int)name].isNull())
diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h
index b54a24e563..f2260db410 100644
--- a/src/corelib/io/qfileinfo.h
+++ b/src/corelib/io/qfileinfo.h
@@ -212,6 +212,6 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QFileInfo &);
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QFileInfo)
+QT_DECL_METATYPE_EXTERN(QFileInfo, Q_CORE_EXPORT)
#endif // QFILEINFO_H
diff --git a/src/corelib/io/qstorageinfo.cpp b/src/corelib/io/qstorageinfo.cpp
index 86b8ae0ac3..41abce8d84 100644
--- a/src/corelib/io/qstorageinfo.cpp
+++ b/src/corelib/io/qstorageinfo.cpp
@@ -44,6 +44,8 @@
QT_BEGIN_NAMESPACE
+QT_IMPL_METATYPE_EXTERN(QStorageInfo)
+
/*!
\class QStorageInfo
\inmodule QtCore
diff --git a/src/corelib/io/qstorageinfo.h b/src/corelib/io/qstorageinfo.h
index fc440fa05e..251635efa6 100644
--- a/src/corelib/io/qstorageinfo.h
+++ b/src/corelib/io/qstorageinfo.h
@@ -120,6 +120,6 @@ Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QStorageInfo &);
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QStorageInfo)
+QT_DECL_METATYPE_EXTERN(QStorageInfo, Q_CORE_EXPORT)
#endif // QSTORAGEINFO_H
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp
index 2907cb66ae..c716648427 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -60,8 +60,7 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcCheckIndex, "qt.core.qabstractitemmodel.checkindex")
-int qRegisterNormalizedMetaType_QList_QModelIndex(const QByteArray &name)
-{ return qRegisterNormalizedMetaTypeImplementation<QList<QModelIndex>>(name); }
+QT_IMPL_METATYPE_EXTERN(QModelIndexList)
QPersistentModelIndexData *QPersistentModelIndexData::create(const QModelIndex &index)
{
diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h
index 439e63a362..f86a945c52 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.h
+++ b/src/corelib/itemmodels/qabstractitemmodel.h
@@ -537,12 +537,8 @@ inline Qt::ItemFlags QModelIndex::flags() const
inline size_t qHash(const QModelIndex &index, size_t seed = 0) noexcept
{ return size_t((size_t(index.row()) << 4) + size_t(index.column()) + index.internalId()) ^ seed; }
-Q_CORE_EXPORT int qRegisterNormalizedMetaType_QList_QModelIndex(const QByteArray &name);
-template <> inline int qRegisterNormalizedMetaType<QList<QModelIndex>>(const QByteArray &name)
-{ return qRegisterNormalizedMetaType_QList_QModelIndex(name); }
-
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QModelIndexList)
+QT_DECL_METATYPE_EXTERN(QModelIndexList, Q_CORE_EXPORT)
#endif // QABSTRACTITEMMODEL_H
diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp
index f144bf9357..286a57eb3e 100644
--- a/src/corelib/itemmodels/qitemselectionmodel.cpp
+++ b/src/corelib/itemmodels/qitemselectionmodel.cpp
@@ -50,6 +50,9 @@
QT_BEGIN_NAMESPACE
+QT_IMPL_METATYPE_EXTERN(QItemSelectionRange)
+QT_IMPL_METATYPE_EXTERN(QItemSelection)
+
/*!
\class QItemSelectionRange
\inmodule QtCore
diff --git a/src/corelib/itemmodels/qitemselectionmodel.h b/src/corelib/itemmodels/qitemselectionmodel.h
index 1d3fb0ec2a..423d6cc057 100644
--- a/src/corelib/itemmodels/qitemselectionmodel.h
+++ b/src/corelib/itemmodels/qitemselectionmodel.h
@@ -238,7 +238,7 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QItemSelectionRange &);
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QItemSelectionRange)
-Q_DECLARE_METATYPE(QItemSelection)
+QT_DECL_METATYPE_EXTERN(QItemSelectionRange, Q_CORE_EXPORT)
+QT_DECL_METATYPE_EXTERN(QItemSelection, Q_CORE_EXPORT)
#endif // QITEMSELECTIONMODEL_H
diff --git a/src/corelib/kernel/qdeadlinetimer.cpp b/src/corelib/kernel/qdeadlinetimer.cpp
index 20b2107d55..1aca02f600 100644
--- a/src/corelib/kernel/qdeadlinetimer.cpp
+++ b/src/corelib/kernel/qdeadlinetimer.cpp
@@ -43,6 +43,8 @@
QT_BEGIN_NAMESPACE
+QT_IMPL_METATYPE_EXTERN(QDeadlineTimer)
+
namespace {
class TimeReference
{
diff --git a/src/corelib/kernel/qdeadlinetimer.h b/src/corelib/kernel/qdeadlinetimer.h
index 0720a32b56..32e7d2cde3 100644
--- a/src/corelib/kernel/qdeadlinetimer.h
+++ b/src/corelib/kernel/qdeadlinetimer.h
@@ -224,6 +224,6 @@ Q_DECLARE_SHARED(QDeadlineTimer)
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QDeadlineTimer)
+QT_DECL_METATYPE_EXTERN(QDeadlineTimer, Q_CORE_EXPORT)
#endif // QDEADLINETIMER_H
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 59b1f23d21..954878f6db 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -97,6 +97,7 @@ QT_BEGIN_NAMESPACE
#define NS(x) QT_PREPEND_NAMESPACE(x)
+QT_IMPL_METATYPE_EXTERN_TAGGED(QtMetaTypePrivate::QPairVariantInterfaceImpl, QPairVariantInterfaceImpl)
namespace {
struct DefinedTypesFilter {
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index cff94d3324..62798f4cc8 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -1257,19 +1257,36 @@ int qRegisterNormalizedMetaTypeImplementation(const QT_PREPEND_NAMESPACE(QByteAr
// This primary template calls the -Implementation, like all other specialisations should.
// But the split allows to
// - in a header:
-// - declare, but not define, a specialization of this template
-// - add an explicit instantiation declaration (extern template ...)
+// - define a specialization of this template calling an out-of-line function
+// (QT_DECL_METATYPE_EXTERN{,_TAGGED})
// - in the .cpp file:
-// - define the specialization to call the -Implementation
-// - add an explicit instantiation definition
-// This prevents the compiler from taking the leeway for inline functions in
-// [temp.explicit]/13 Note 4
+// - define the out-of-line wrapper to call the -Implementation
+// (QT_IMPL_METATYPE_EXTERN{,_TAGGED})
+// The _TAGGED variants let you choose a tag (must be a C identifier) to disambiguate
+// the out-of-line function; the non-_TAGGED variants use the passed class name as tag.
template <typename T>
int qRegisterNormalizedMetaType(const QT_PREPEND_NAMESPACE(QByteArray) &normalizedTypeName)
{
return qRegisterNormalizedMetaTypeImplementation<T>(normalizedTypeName);
}
+#define QT_DECL_METATYPE_EXTERN_TAGGED(TYPE, TAG, EXPORT) \
+ QT_BEGIN_NAMESPACE \
+ EXPORT int qRegisterNormalizedMetaType_ ## TAG (const QByteArray &); \
+ template <> inline int qRegisterNormalizedMetaType< TYPE >(const QByteArray &name) \
+ { return qRegisterNormalizedMetaType_ ## TAG (name); } \
+ QT_END_NAMESPACE \
+ Q_DECLARE_METATYPE(TYPE) \
+ /* end */
+#define QT_IMPL_METATYPE_EXTERN_TAGGED(TYPE, TAG) \
+ int qRegisterNormalizedMetaType_ ## TAG (const QByteArray &name) \
+ { return qRegisterNormalizedMetaTypeImplementation< TYPE >(name); } \
+ /* end */
+#define QT_DECL_METATYPE_EXTERN(TYPE, EXPORT) \
+ QT_DECL_METATYPE_EXTERN_TAGGED(TYPE, TYPE, EXPORT)
+#define QT_IMPL_METATYPE_EXTERN(TYPE) \
+ QT_IMPL_METATYPE_EXTERN_TAGGED(TYPE, TYPE)
+
template <typename T>
int qRegisterMetaType(const char *typeName)
{
@@ -2521,6 +2538,7 @@ constexpr const QtPrivate::QMetaTypeInterface *const qt_incomplete_metaTypeArray
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QtMetaTypePrivate::QPairVariantInterfaceImpl)
+QT_DECL_METATYPE_EXTERN_TAGGED(QtMetaTypePrivate::QPairVariantInterfaceImpl,
+ QPairVariantInterfaceImpl, Q_CORE_EXPORT)
#endif // QMETATYPE_H
diff --git a/src/corelib/kernel/qsocketnotifier.cpp b/src/corelib/kernel/qsocketnotifier.cpp
index 8d4052b8f9..668eb207db 100644
--- a/src/corelib/kernel/qsocketnotifier.cpp
+++ b/src/corelib/kernel/qsocketnotifier.cpp
@@ -58,6 +58,9 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcSocketNotifierDeprecation)
Q_LOGGING_CATEGORY(lcSocketNotifierDeprecation, "qt.core.socketnotifier_deprecation");
+QT_IMPL_METATYPE_EXTERN_TAGGED(QSocketNotifier::Type, QSocketNotifier_Type)
+QT_IMPL_METATYPE_EXTERN(QSocketDescriptor)
+
class QSocketNotifierPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QSocketNotifier)
diff --git a/src/corelib/kernel/qsocketnotifier.h b/src/corelib/kernel/qsocketnotifier.h
index 9c806235fc..2014145d21 100644
--- a/src/corelib/kernel/qsocketnotifier.h
+++ b/src/corelib/kernel/qsocketnotifier.h
@@ -137,7 +137,8 @@ private:
};
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QSocketNotifier::Type)
-Q_DECLARE_METATYPE(QSocketDescriptor)
+
+QT_DECL_METATYPE_EXTERN_TAGGED(QSocketNotifier::Type, QSocketNotifier_Type, Q_CORE_EXPORT)
+QT_DECL_METATYPE_EXTERN(QSocketDescriptor, Q_CORE_EXPORT)
#endif // QSOCKETNOTIFIER_H
diff --git a/src/corelib/serialization/qcborcommon.cpp b/src/corelib/serialization/qcborcommon.cpp
index 27ab67d355..b39bb37edb 100644
--- a/src/corelib/serialization/qcborcommon.cpp
+++ b/src/corelib/serialization/qcborcommon.cpp
@@ -46,6 +46,8 @@
QT_BEGIN_NAMESPACE
+QT_IMPL_METATYPE_EXTERN(QCborTag)
+
#include <cborerrorstrings.c>
/*!
diff --git a/src/corelib/serialization/qcborcommon.h b/src/corelib/serialization/qcborcommon.h
index 2ea0cec44c..b862d1aafb 100644
--- a/src/corelib/serialization/qcborcommon.h
+++ b/src/corelib/serialization/qcborcommon.h
@@ -151,7 +151,7 @@ enum class QCborNegativeInteger : quint64 {};
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QCborTag)
+QT_DECL_METATYPE_EXTERN(QCborTag, Q_CORE_EXPORT)
// To avoid changing namespace we need to reinstate defines, even though our .cpp
// will then have to remove them again.
diff --git a/src/corelib/tools/qversionnumber.cpp b/src/corelib/tools/qversionnumber.cpp
index 38977c3db8..1d05fdd89c 100644
--- a/src/corelib/tools/qversionnumber.cpp
+++ b/src/corelib/tools/qversionnumber.cpp
@@ -57,6 +57,9 @@
QT_BEGIN_NAMESPACE
+QT_IMPL_METATYPE_EXTERN(QVersionNumber)
+QT_IMPL_METATYPE_EXTERN(QTypeRevision)
+
/*!
\class QVersionNumber
\inmodule QtCore
diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber.h
index 8efdde3391..e72e4efc23 100644
--- a/src/corelib/tools/qversionnumber.h
+++ b/src/corelib/tools/qversionnumber.h
@@ -494,7 +494,7 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QTypeRevision &revision);
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QVersionNumber)
-Q_DECLARE_METATYPE(QTypeRevision)
+QT_DECL_METATYPE_EXTERN(QVersionNumber, Q_CORE_EXPORT)
+QT_DECL_METATYPE_EXTERN(QTypeRevision, Q_CORE_EXPORT)
#endif // QVERSIONNUMBER_H
diff --git a/src/dbus/qdbuserror.cpp b/src/dbus/qdbuserror.cpp
index 969af2fd2f..c0ae97fd27 100644
--- a/src/dbus/qdbuserror.cpp
+++ b/src/dbus/qdbuserror.cpp
@@ -53,6 +53,8 @@
QT_BEGIN_NAMESPACE
+QT_IMPL_METATYPE_EXTERN(QDBusError)
+
static constexpr const auto errorMessages = qOffsetStringArray(
"NoError",
"other",
diff --git a/src/dbus/qdbuserror.h b/src/dbus/qdbuserror.h
index 7fe5b45f8e..65baaa9562 100644
--- a/src/dbus/qdbuserror.h
+++ b/src/dbus/qdbuserror.h
@@ -140,7 +140,7 @@ Q_DBUS_EXPORT QDebug operator<<(QDebug, const QDBusError &);
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QDBusError)
+QT_DECL_METATYPE_EXTERN(QDBusError, Q_DBUS_EXPORT)
#else
QT_BEGIN_NAMESPACE
class Q_DBUS_EXPORT QDBusError {}; // dummy class for moc
diff --git a/src/dbus/qdbusextratypes.cpp b/src/dbus/qdbusextratypes.cpp
index 06fbd6062e..be55509821 100644
--- a/src/dbus/qdbusextratypes.cpp
+++ b/src/dbus/qdbusextratypes.cpp
@@ -44,6 +44,10 @@
QT_BEGIN_NAMESPACE
+QT_IMPL_METATYPE_EXTERN(QDBusVariant)
+QT_IMPL_METATYPE_EXTERN(QDBusObjectPath)
+QT_IMPL_METATYPE_EXTERN(QDBusSignature)
+
void QDBusObjectPath::doCheck()
{
if (!QDBusUtil::isValidObjectPath(m_path)) {
diff --git a/src/dbus/qdbusextratypes.h b/src/dbus/qdbusextratypes.h
index c4e05062c3..59ab248dfa 100644
--- a/src/dbus/qdbusextratypes.h
+++ b/src/dbus/qdbusextratypes.h
@@ -189,9 +189,9 @@ inline bool operator==(const QDBusVariant &v1, const QDBusVariant &v2)
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QDBusVariant)
-Q_DECLARE_METATYPE(QDBusObjectPath)
-Q_DECLARE_METATYPE(QDBusSignature)
+QT_DECL_METATYPE_EXTERN(QDBusVariant, Q_DBUS_EXPORT)
+QT_DECL_METATYPE_EXTERN(QDBusObjectPath, Q_DBUS_EXPORT)
+QT_DECL_METATYPE_EXTERN(QDBusSignature, Q_DBUS_EXPORT)
#endif // QT_NO_DBUS
#endif
diff --git a/src/dbus/qdbusmessage.cpp b/src/dbus/qdbusmessage.cpp
index b619e00c62..62a6cea92f 100644
--- a/src/dbus/qdbusmessage.cpp
+++ b/src/dbus/qdbusmessage.cpp
@@ -56,6 +56,8 @@
QT_BEGIN_NAMESPACE
+QT_IMPL_METATYPE_EXTERN(QDBusMessage)
+
static_assert(QDBusMessage::InvalidMessage == DBUS_MESSAGE_TYPE_INVALID);
static_assert(QDBusMessage::MethodCallMessage == DBUS_MESSAGE_TYPE_METHOD_CALL);
static_assert(QDBusMessage::ReplyMessage == DBUS_MESSAGE_TYPE_METHOD_RETURN);
diff --git a/src/dbus/qdbusmessage.h b/src/dbus/qdbusmessage.h
index be483b67af..e820b2427b 100644
--- a/src/dbus/qdbusmessage.h
+++ b/src/dbus/qdbusmessage.h
@@ -131,7 +131,7 @@ Q_DBUS_EXPORT QDebug operator<<(QDebug, const QDBusMessage &);
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QDBusMessage)
+QT_DECL_METATYPE_EXTERN(QDBusMessage, Q_DBUS_EXPORT)
#else
class Q_DBUS_EXPORT QDBusMessage {}; // dummy class for moc
diff --git a/src/dbus/qdbusunixfiledescriptor.cpp b/src/dbus/qdbusunixfiledescriptor.cpp
index 87cabb93f6..29729001cc 100644
--- a/src/dbus/qdbusunixfiledescriptor.cpp
+++ b/src/dbus/qdbusunixfiledescriptor.cpp
@@ -48,6 +48,8 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_DBUS
+QT_IMPL_METATYPE_EXTERN(QDBusUnixFileDescriptor)
+
/*!
\class QDBusUnixFileDescriptor
\inmodule QtDBus
diff --git a/src/dbus/qdbusunixfiledescriptor.h b/src/dbus/qdbusunixfiledescriptor.h
index fcd73b2ec5..a2da2c52da 100644
--- a/src/dbus/qdbusunixfiledescriptor.h
+++ b/src/dbus/qdbusunixfiledescriptor.h
@@ -85,7 +85,7 @@ Q_DECLARE_SHARED(QDBusUnixFileDescriptor)
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QDBusUnixFileDescriptor)
+QT_DECL_METATYPE_EXTERN(QDBusUnixFileDescriptor, Q_DBUS_EXPORT)
#endif // QT_NO_DBUS
#endif // QDBUSUNIXFILEDESCRIPTOR_H
diff --git a/src/gui/kernel/qsurface.cpp b/src/gui/kernel/qsurface.cpp
index 5a293e4250..647210a76a 100644
--- a/src/gui/kernel/qsurface.cpp
+++ b/src/gui/kernel/qsurface.cpp
@@ -44,6 +44,7 @@
QT_BEGIN_NAMESPACE
+QT_IMPL_METATYPE_EXTERN_TAGGED(QSurface*, QSurface_ptr)
/*!
\class QSurface
diff --git a/src/gui/kernel/qsurface.h b/src/gui/kernel/qsurface.h
index 4ba1d4b589..8b989df4f5 100644
--- a/src/gui/kernel/qsurface.h
+++ b/src/gui/kernel/qsurface.h
@@ -96,6 +96,6 @@ protected:
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QSurface*)
+QT_DECL_METATYPE_EXTERN_TAGGED(QSurface*, QSurface_ptr, Q_GUI_EXPORT)
#endif //QSURFACE_H
diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp
index 102bce696b..566e65e896 100644
--- a/src/gui/text/qtextoption.cpp
+++ b/src/gui/text/qtextoption.cpp
@@ -43,6 +43,8 @@
QT_BEGIN_NAMESPACE
+QT_IMPL_METATYPE_EXTERN_TAGGED(QTextOption::Tab, QTextOption_Tab)
+
struct QTextOptionPrivate
{
QList<QTextOption::Tab> tabStops;
diff --git a/src/gui/text/qtextoption.h b/src/gui/text/qtextoption.h
index 629c1d48da..2955fe8dcc 100644
--- a/src/gui/text/qtextoption.h
+++ b/src/gui/text/qtextoption.h
@@ -151,6 +151,6 @@ inline void QTextOption::setTabStopDistance(qreal atabStop)
QT_END_NAMESPACE
-Q_DECLARE_METATYPE( QTextOption::Tab )
+QT_DECL_METATYPE_EXTERN_TAGGED(QTextOption::Tab, QTextOption_Tab, Q_GUI_EXPORT)
#endif // QTEXTOPTION_H