diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-08-13 12:31:00 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-08-17 15:08:39 +0200 |
commit | b39685d4c26009d6f85cbbee287d5647a7bd6fe4 (patch) | |
tree | 55908fad446fe2207284846fccc6695a2e348327 /src/gui/image/qpixmap.h | |
parent | 90436e54cc32e3fd32f7298c65ac236eaff01bba (diff) |
Make QCursor constructor explicit to prevent comparison of QPixmap
QPixmap doesn't implement operator==, but QCursor had a non-explicit
constructor from a QPixmap, which the compiler would use if two pixmaps
get compared.
Making that QCursor constructor explicit prevents that implicit
conversion, at the cost of potential (but trivially resolved) source
incompatibility.
Also, make QCursor's comparison operators into hidden friends to avoid
any other implicit conversions, and allow only QCursor object to be
compared.
In addition, delete operator== and operator!= in QPixmap so that the
compiler generates a useful error message, rather than a screen full
of global operator== candidates.
Delete these operators in QIcon as well for consistency.
Change-Id: I9b3f770da5718360ecc41c35cf327ef4f60d169b
Fixes: QTBUG-85993
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/gui/image/qpixmap.h')
-rw-r--r-- | src/gui/image/qpixmap.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 568ed6ecb5..19881bda2c 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -77,6 +77,8 @@ public: { qSwap(data, other.data); return *this; } inline void swap(QPixmap &other) noexcept { qSwap(data, other.data); } + bool operator==(const QPixmap &) const = delete; + bool operator!=(const QPixmap &) const = delete; operator QVariant() const; |