Use Q_DECLARE_TYPEINFO() with all value-classes
Open, Needs TriagePublic

Description

Classes which are used as value types (so not only passed around via pointer to instance) should be checked if they can be marked with Q_DECLARE_TYPEINFO(Q_RELOCATABLE_TYPE).

That can improve performance when those classes are used with Qt containers (QList etc).

Candidate classes:

  • using QSharedDataPointer or QExplicitlySharedDataPointer for shared data
  • have only member variables which also satisfy the relocatable requirement

See https://doc.qt.io/qt-6/qtglobal.html#Q_DECLARE_TYPEINFO

The type info specified this way can have an effect on the data layout (and method implementation) of Qt container classes, so can break the ABI. Thus needs to be done between KF5 & KF6.

kossebau created this task.Jan 25 2021, 7:42 PM

Is this still relevant given that the Qt5-QList behavior doesn't exist any more in Qt6?

The QList issue is gone indeed, and that was probably the most pressing one, but QTypeInfo is still used in various places in Qt's container and threading code. So I think the basic reasoning still applies.