QImage: add a qMove()
The color table is passed by value (good for C++11), so when the argument is assigned to the member variable, that's a good spot for a move assignment. However, the argument is also declared const. The standard says that top-level const is ignored, but some compilers (I know about SunCC) think differently, so we cannot remove it. Instead, we do a const_cast. It is well-defined: Even though apparently the argument was declared as const, the standard says the const is not there, and no sane compiler would put the argument copy into read-only memory. Add a reminder to remove the top-level const from the signature come Qt 6. Change-Id: Iac18846ba669de0a30da620685ad1438c267e193 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>bb10
parent
b04c144297
commit
5b9e566b4d
|
|
@ -1368,7 +1368,7 @@ void QImage::setColorTable(const QVector<QRgb> colors)
|
|||
if (!d)
|
||||
return;
|
||||
|
||||
d->colortable = colors;
|
||||
d->colortable = qMove(const_cast<QVector<QRgb>&>(colors));
|
||||
d->has_alpha_clut = false;
|
||||
for (int i = 0; i < d->colortable.size(); ++i) {
|
||||
if (qAlpha(d->colortable.at(i)) != 255) {
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ public:
|
|||
void setPixel(const QPoint &pt, uint index_or_rgb);
|
||||
|
||||
QVector<QRgb> colorTable() const;
|
||||
void setColorTable(const QVector<QRgb> colors);
|
||||
void setColorTable(const QVector<QRgb> colors); // ### Qt 6: remove const
|
||||
|
||||
qreal devicePixelRatio() const;
|
||||
void setDevicePixelRatio(qreal scaleFactor);
|
||||
|
|
|
|||
Loading…
Reference in New Issue