Fix deprecation warnings in QCocoaCursor

Explicitly use the Qt APIs that return QPixmap and QBitmap by value, and
fix the API taking those to use const references rather than pointers
or const values.

Change-Id: I2bb7ad1edb3b65f806f0475fca383e5b9bdb61f3
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Volker Hilsheimer 2020-03-26 13:48:27 +01:00
parent 5a0d4f3313
commit b61ea367a5
2 changed files with 9 additions and 9 deletions

View File

@ -63,8 +63,8 @@ private:
QHash<Qt::CursorShape, NSCursor *> m_cursors; QHash<Qt::CursorShape, NSCursor *> m_cursors;
NSCursor *convertCursor(QCursor *cursor); NSCursor *convertCursor(QCursor *cursor);
NSCursor *createCursorData(QCursor * cursor); NSCursor *createCursorData(QCursor * cursor);
NSCursor *createCursorFromBitmap(const QBitmap *bitmap, const QBitmap *mask, const QPoint hotspot = QPoint()); NSCursor *createCursorFromBitmap(const QBitmap &bitmap, const QBitmap &mask, const QPoint hotspot = QPoint());
NSCursor *createCursorFromPixmap(const QPixmap pixmap, const QPoint hotspot = QPoint()); NSCursor *createCursorFromPixmap(const QPixmap &pixmap, const QPoint hotspot = QPoint());
}; };
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -243,7 +243,7 @@ NSCursor *QCocoaCursor::createCursorData(QCursor *cursor)
switch (cursor->shape()) { switch (cursor->shape()) {
case Qt::BitmapCursor: { case Qt::BitmapCursor: {
if (cursor->pixmap().isNull()) if (cursor->pixmap().isNull())
return createCursorFromBitmap(cursor->bitmap(), cursor->mask(), hotspot); return createCursorFromBitmap(cursor->bitmap(Qt::ReturnByValue), cursor->mask(Qt::ReturnByValue), hotspot);
else else
return createCursorFromPixmap(cursor->pixmap(), hotspot); return createCursorFromPixmap(cursor->pixmap(), hotspot);
break; } break; }
@ -301,17 +301,17 @@ NSCursor *QCocoaCursor::createCursorData(QCursor *cursor)
if (cursorData) { if (cursorData) {
QBitmap bitmap(QBitmap::fromData(QSize(16, 16), cursorData, QImage::Format_Mono)); QBitmap bitmap(QBitmap::fromData(QSize(16, 16), cursorData, QImage::Format_Mono));
QBitmap mask(QBitmap::fromData(QSize(16, 16), cursorMaskData, QImage::Format_Mono)); QBitmap mask(QBitmap::fromData(QSize(16, 16), cursorMaskData, QImage::Format_Mono));
return (createCursorFromBitmap(&bitmap, &mask, hotspot)); return (createCursorFromBitmap(bitmap, mask, hotspot));
} }
return nil; // should not happen, all cases covered above return nil; // should not happen, all cases covered above
} }
NSCursor *QCocoaCursor::createCursorFromBitmap(const QBitmap *bitmap, const QBitmap *mask, const QPoint hotspot) NSCursor *QCocoaCursor::createCursorFromBitmap(const QBitmap &bitmap, const QBitmap &mask, const QPoint hotspot)
{ {
QImage finalCursor(bitmap->size(), QImage::Format_ARGB32); QImage finalCursor(bitmap.size(), QImage::Format_ARGB32);
QImage bmi = bitmap->toImage().convertToFormat(QImage::Format_RGB32); QImage bmi = bitmap.toImage().convertToFormat(QImage::Format_RGB32);
QImage bmmi = mask->toImage().convertToFormat(QImage::Format_RGB32); QImage bmmi = mask.toImage().convertToFormat(QImage::Format_RGB32);
for (int row = 0; row < finalCursor.height(); ++row) { for (int row = 0; row < finalCursor.height(); ++row) {
QRgb *bmData = reinterpret_cast<QRgb *>(bmi.scanLine(row)); QRgb *bmData = reinterpret_cast<QRgb *>(bmi.scanLine(row));
QRgb *bmmData = reinterpret_cast<QRgb *>(bmmi.scanLine(row)); QRgb *bmmData = reinterpret_cast<QRgb *>(bmmi.scanLine(row));
@ -332,7 +332,7 @@ NSCursor *QCocoaCursor::createCursorFromBitmap(const QBitmap *bitmap, const QBit
return createCursorFromPixmap(QPixmap::fromImage(finalCursor), hotspot); return createCursorFromPixmap(QPixmap::fromImage(finalCursor), hotspot);
} }
NSCursor *QCocoaCursor::createCursorFromPixmap(const QPixmap pixmap, const QPoint hotspot) NSCursor *QCocoaCursor::createCursorFromPixmap(const QPixmap &pixmap, const QPoint hotspot)
{ {
NSPoint hotSpot = NSMakePoint(hotspot.x(), hotspot.y()); NSPoint hotSpot = NSMakePoint(hotspot.x(), hotspot.y());
auto *image = [NSImage imageFromQImage:pixmap.toImage()]; auto *image = [NSImage imageFromQImage:pixmap.toImage()];