summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2021-09-06 08:54:42 -0700
committerThiago Macieira <thiago.macieira@intel.com>2021-09-07 12:09:49 -0700
commitda2fd6a9038b1130a2ae411546216d8874ffa4f7 (patch)
treebfab01a15abd0a9eee5653f97b4f631d81110897 /src/corelib/kernel/qobject.h
parent0108275b0c6a38ac73014c8e135b9be9fe75c8b2 (diff)
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>
Diffstat (limited to 'src/corelib/kernel/qobject.h')
-rw-r--r--src/corelib/kernel/qobject.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index c2fc2910f0..f1e0662461 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -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