Remove unneeded Q_DECLARE_METATYPE calls for pointers to QObject subclasses

Compare API dox of Q_DECLARE_METATYPE:
"
Some types are registered automatically and do not need this macro:
* Pointers to classes derived from QObject
* QPointer<T>, QSharedPointer<T>, QWeakPointer<T>,
  where T is a class that derives from QObject
"

This is a ABI-compatible change, as this just replaces explicitly
defined template code (by the Q_DECLARE_METATYPE macro use) with the
generic predefined one picking up pointers to QObject subclasses.

So instead of the custom explicitly template overload
    template <>
    struct QMetaTypeId< TYPE >
    { /**/ static int qt_metatype_id() {/**/} };
the predefined template overload one is picked up via
    template <typename T>
    struct QMetaTypeId : public QMetaTypeIdQObject<T>
    { /**/ };
    template <typename T, int =
        QtPrivate::IsPointerToTypeDerivedFromQObject<T>::Value ?
            QMetaType::PointerToQObject :
        /**/ 0>
    struct QMetaTypeIdQObject
    { /**/ };
    template <typename T>
    struct QMetaTypeIdQObject<T*, QMetaType::PointerToQObject>
    { /**/ static int qt_metatype_id() {/**/} };

And thus the constexpr code using QMetaTypeId<T>::qt_metatype_id(),
for which all this is done, evaluates as before.

GIT_SILENT
This commit is contained in:
Friedrich W. H. Kossebau 2020-07-01 04:02:48 +02:00
parent f125cb0233
commit eb87bd715d
6 changed files with 0 additions and 13 deletions

View File

@ -172,6 +172,4 @@ private:
K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin<classname>();) \ K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin<classname>();) \
K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
Q_DECLARE_METATYPE(Plasma::ContainmentActions *)
#endif // PLASMA_CONTAINMENTACTIONS_H #endif // PLASMA_CONTAINMENTACTIONS_H

View File

@ -487,6 +487,4 @@ private:
K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin<classname>();) \ K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin<classname>();) \
K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
Q_DECLARE_METATYPE(Plasma::DataEngine *)
#endif // multiple inclusion guard #endif // multiple inclusion guard

View File

@ -54,9 +54,6 @@ private:
}; };
//End StorageJob //End StorageJob
Q_DECLARE_METATYPE(StorageJob *)
Q_DECLARE_METATYPE(QPointer<StorageJob>)
class Storage : public Plasma::Service class Storage : public Plasma::Service
{ {
Q_OBJECT Q_OBJECT

View File

@ -223,8 +223,6 @@ private:
} // namespace Plasma } // namespace Plasma
Q_DECLARE_METATYPE(Plasma::Service *)
/** /**
* Register a service when it is contained in a loadable module * Register a service when it is contained in a loadable module
*/ */

View File

@ -122,7 +122,5 @@ private:
} // namespace Plasma } // namespace Plasma
Q_DECLARE_METATYPE(Plasma::ServiceJob *)
#endif // multiple inclusion guard #endif // multiple inclusion guard

View File

@ -44,8 +44,6 @@
#include <kdeclarative/configpropertymap.h> #include <kdeclarative/configpropertymap.h>
#include <kdeclarative/qmlobject.h> #include <kdeclarative/qmlobject.h>
Q_DECLARE_METATYPE(AppletInterface *)
AppletInterface::AppletInterface(DeclarativeAppletScript *script, const QVariantList &args, QQuickItem *parent) AppletInterface::AppletInterface(DeclarativeAppletScript *script, const QVariantList &args, QQuickItem *parent)
: AppletQuickItem(script->applet(), parent), : AppletQuickItem(script->applet(), parent),
m_configuration(nullptr), m_configuration(nullptr),