QCursor: add missing QT_DEPRECATED_VERSION_X_6_0 for deprecated methods

When the method is wrapped into
 if QT_DEPRECATED_SINCE(MAJ, MIN)
we also need to add QT_DEPRECATED_VERSION_[X_]_MAJ_MIN macro right in
front of the method declaraion, to actually trigger a deprecation
warning.

This patch does that for QCursor's deprecated methods, and fixes all
related compilation warnings in QtBase.

Task-number: QTBUG-104857
Change-Id: Ic8d059e8c852d4b2dee55e7ea94f4fc7a402cdf4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 24de000a9cb0b2dc2f959fa65502ef805a4fc544)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Ivan Solovev 2022-07-11 11:32:49 +02:00 committed by Qt Cherry-pick Bot
parent 8826fb80f0
commit cf4df23f6d
6 changed files with 23 additions and 21 deletions

View File

@ -290,7 +290,7 @@ QDataStream &operator<<(QDataStream &s, const QCursor &c)
if (isPixmap)
s << c.pixmap();
else
s << c.bitmap(Qt::ReturnByValue) << c.mask(Qt::ReturnByValue);
s << c.bitmap() << c.mask();
s << c.hotSpot();
}
return s;

View File

@ -62,7 +62,9 @@ public:
void setShape(Qt::CursorShape newShape);
#if QT_DEPRECATED_SINCE(6, 0)
QT_DEPRECATED_VERSION_X_6_0("Use the overload without argument instead.")
QBitmap bitmap(Qt::ReturnByValueConstant) const { return bitmap(); }
QT_DEPRECATED_VERSION_X_6_0("Use the overload without argument instead.")
QBitmap mask(Qt::ReturnByValueConstant) const { return mask(); }
#endif // QT_DEPRECATED_SINCE(6, 0)
QBitmap bitmap() const;

View File

@ -240,7 +240,7 @@ NSCursor *QCocoaCursor::createCursorData(QCursor *cursor)
switch (cursor->shape()) {
case Qt::BitmapCursor: {
if (cursor->pixmap().isNull())
return createCursorFromBitmap(cursor->bitmap(Qt::ReturnByValue), cursor->mask(Qt::ReturnByValue), hotspot);
return createCursorFromBitmap(cursor->bitmap(), cursor->mask(), hotspot);
else
return createCursorFromPixmap(cursor->pixmap(), hotspot);
break; }

View File

@ -43,10 +43,10 @@ QWindowsPixmapCursorCacheKey::QWindowsPixmapCursorCacheKey(const QCursor &c)
: bitmapCacheKey(c.pixmap().cacheKey()), maskCacheKey(0)
{
if (!bitmapCacheKey) {
Q_ASSERT(!c.bitmap(Qt::ReturnByValue).isNull());
Q_ASSERT(!c.mask(Qt::ReturnByValue).isNull());
bitmapCacheKey = c.bitmap(Qt::ReturnByValue).cacheKey();
maskCacheKey = c.mask(Qt::ReturnByValue).cacheKey();
Q_ASSERT(!c.bitmap().isNull());
Q_ASSERT(!c.mask().isNull());
bitmapCacheKey = c.bitmap().cacheKey();
maskCacheKey = c.mask().cacheKey();
}
}
@ -131,9 +131,9 @@ static HCURSOR createBitmapCursor(const QImage &bbits, const QImage &mbits,
// Create a cursor from image and mask of the format QImage::Format_Mono.
static HCURSOR createBitmapCursor(const QCursor &cursor, qreal scaleFactor = 1)
{
Q_ASSERT(cursor.shape() == Qt::BitmapCursor && !cursor.bitmap(Qt::ReturnByValue).isNull());
QImage bbits = cursor.bitmap(Qt::ReturnByValue).toImage();
QImage mbits = cursor.mask(Qt::ReturnByValue).toImage();
Q_ASSERT(cursor.shape() == Qt::BitmapCursor && !cursor.bitmap().isNull());
QImage bbits = cursor.bitmap().toImage();
QImage mbits = cursor.mask().toImage();
scaleFactor /= bbits.devicePixelRatio();
if (!qFuzzyCompare(scaleFactor, 1)) {
const QSize scaledSize = (QSizeF(bbits.size()) * scaleFactor).toSize();

View File

@ -255,10 +255,10 @@ QXcbCursorCacheKey::QXcbCursorCacheKey(const QCursor &c)
if (pixmapCacheKey) {
bitmapCacheKey = pixmapCacheKey;
} else {
Q_ASSERT(!c.bitmap(Qt::ReturnByValue).isNull());
Q_ASSERT(!c.mask(Qt::ReturnByValue).isNull());
bitmapCacheKey = c.bitmap(Qt::ReturnByValue).cacheKey();
maskCacheKey = c.mask(Qt::ReturnByValue).cacheKey();
Q_ASSERT(!c.bitmap().isNull());
Q_ASSERT(!c.mask().isNull());
bitmapCacheKey = c.bitmap().cacheKey();
maskCacheKey = c.mask().cacheKey();
}
}
}
@ -583,8 +583,8 @@ xcb_cursor_t QXcbCursor::createBitmapCursor(QCursor *cursor)
qCWarning(lcQpaXcb, "xrender >= 0.5 required to create pixmap cursors");
} else {
xcb_connection_t *conn = xcb_connection();
xcb_pixmap_t cp = qt_xcb_XPixmapFromBitmap(m_screen, cursor->bitmap(Qt::ReturnByValue).toImage());
xcb_pixmap_t mp = qt_xcb_XPixmapFromBitmap(m_screen, cursor->mask(Qt::ReturnByValue).toImage());
xcb_pixmap_t cp = qt_xcb_XPixmapFromBitmap(m_screen, cursor->bitmap().toImage());
xcb_pixmap_t mp = qt_xcb_XPixmapFromBitmap(m_screen, cursor->mask().toImage());
c = xcb_generate_id(conn);
xcb_create_cursor(conn, c, cp, mp, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF,
spot.x(), spot.y());

View File

@ -1205,15 +1205,15 @@ void tst_QDataStream::readQCursor(QDataStream *s)
QCOMPARE(d5.hotSpot(), test.hotSpot());
// Comparing non-null QBitmaps will fail. Upcast them first to pass.
QCOMPARE(d5.bitmap(Qt::ReturnByValue).isNull(), test.bitmap(Qt::ReturnByValue).isNull());
QCOMPARE(d5.bitmap().isNull(), test.bitmap().isNull());
QCOMPARE(
static_cast<QPixmap>(d5.bitmap(Qt::ReturnByValue)),
static_cast<QPixmap>(test.bitmap(Qt::ReturnByValue))
static_cast<QPixmap>(d5.bitmap()),
static_cast<QPixmap>(test.bitmap())
);
QCOMPARE(d5.mask(Qt::ReturnByValue).isNull(), test.mask(Qt::ReturnByValue).isNull());
QCOMPARE(d5.mask().isNull(), test.mask().isNull());
QCOMPARE(
static_cast<QPixmap>(d5.mask(Qt::ReturnByValue)),
static_cast<QPixmap>(test.mask(Qt::ReturnByValue))
static_cast<QPixmap>(d5.mask()),
static_cast<QPixmap>(test.mask())
);
}
#endif