diff options
| author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2022-02-24 01:10:43 +0100 |
|---|---|---|
| committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2022-02-24 22:41:59 +0100 |
| commit | b20cf7feee6413a40a69c9e41544d44c53ee6877 (patch) | |
| tree | a56e316c940dac558eafad7795f2a345cffd4cc9 /src/network/kernel/qnetworkinterface_unix.cpp | |
| parent | 96a025c28bf793f0519737c5d61bd77728b14ddf (diff) | |
QLabel::setPixmap(): remove the no-op self-masking
When calling QLabel::setPixmap() with a 1bpp pixmap (i.e. a bitmap), and
that pixmap didn't have a mask set, QLabel would then set the pixmap as
its own mask.
This seems to be a no-op due to how QPixmap::setMask is coded:
void QPixmap::setMask(const QBitmap &mask) {
// ...
if (static_cast<const QPixmap &>(mask).data == data) // trying to selfmask
return;
}
Moreover, in order to convert the pixmap to a QBitmap, the code would just
straight downcast it, triggering UB (if the input to setPixmap wasn't a
QBitmap to begin with).
I *guess* this was done this way to avoid a QBitmap::fromPixmap call,
which however is not expensive at all if the pixmap is already 1bpp,
which QLabel::setPixmap checks explicitly (before attempting to mask the
pixmap). I don't know the historical reasons for the code to have the
shape it had (and the code history is from before open governance).
So get two birds with one stone: remove the no-op and also the UB.
Change-Id: Ibab20492c2945bd1d01f98a18b168fabc56292b0
Pick-to: 6.3 6.2 5.15
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/network/kernel/qnetworkinterface_unix.cpp')
0 files changed, 0 insertions, 0 deletions
