QVariant: disable building from arbitrary pointers
The QVariant(bool) is an extremely dangerous catch-all for all sorts of things that may convert to bool, including arbitrary pointers. Delete the corresponding constructor, in order to force users to use the (correct) construction using fromValue, and/or to prevent bugs altogether. This is technically speaking a SiC, but one of type A -- if pointer to bool was intented, just do the conversion explicitly. [ChangeLog][QtCore][QVariant] QVariant used to be constructible by raw pointers through a conversion towards bool. This is now illegal. If such a conversion is needed, users are advised to insert manual casts to bool. Change-Id: I1b1f81962259514e57d841246740e0f7050104e0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
7dd454e1b9
commit
7d8150da4c
|
|
@ -228,6 +228,14 @@ class Q_CORE_EXPORT QVariant
|
|||
QVariant(const QModelIndex &modelIndex);
|
||||
QVariant(const QPersistentModelIndex &modelIndex);
|
||||
#endif
|
||||
#if !defined(Q_CC_GHS)
|
||||
// GHS has an ICE with this code; use the simplified version below
|
||||
template <typename T,
|
||||
std::enable_if_t<std::disjunction_v<std::is_pointer<T>, std::is_member_pointer<T>>, bool> = false>
|
||||
QVariant(T) = delete;
|
||||
#else
|
||||
QVariant(const volatile void *) = delete;
|
||||
#endif
|
||||
|
||||
QVariant& operator=(const QVariant &other);
|
||||
inline QVariant(QVariant &&other) noexcept : d(other.d)
|
||||
|
|
|
|||
Loading…
Reference in New Issue