Q_DECLARE_INTERFACE: add missing const to const qobject_cast
[ChangeLog][Potantially Source-Incompatible Changes] The macro Q_DECLARE_INTERFACE used to cast away the constness of the QObject parameter. That is now fixed in this release, but may cause failure to build source code that depended on this incorrect behavior. If fixing the const correctness in your code is not an option, insert an explicit const_cast<IFace *> of the object prior to the qobject_cast call. Change-Id: Ie72b0dd0fbe84d2caae0fffd16a246a36f0c088f Reviewed-by: Rui Oliveira Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
0108275b0c
commit
da2fd6a903
@ -501,7 +501,7 @@ inline QBindingStorage *qGetBindingStorage(QObject *o)
|
||||
{ return IId; } \
|
||||
template <> inline IFace *qobject_cast<IFace *>(QObject *object) \
|
||||
{ return reinterpret_cast<IFace *>((object ? object->qt_metacast(IId) : nullptr)); } \
|
||||
template <> inline IFace *qobject_cast<IFace *>(const QObject *object) \
|
||||
template <> inline const IFace *qobject_cast<const IFace *>(const QObject *object) \
|
||||
{ return reinterpret_cast<IFace *>((object ? const_cast<QObject *>(object)->qt_metacast(IId) : nullptr)); }
|
||||
#endif // Q_MOC_RUN
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user