summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qcursor.cpp
diff options
context:
space:
mode:
authorSze Howe Koh <szehowe.koh@gmail.com>2019-09-14 18:47:13 +0800
committerSze Howe Koh <szehowe.koh@gmail.com>2020-01-26 01:19:55 +0800
commite79a6253813cd67954e371805da547c48ea32d3d (patch)
treea2533ec61c10c74dfab49af6fff0121af98f6ebb /src/gui/kernel/qcursor.cpp
parent114ff44f3c42e2575c60e6b5c8459acfea2dc60d (diff)
QCursor: Allow bitmap() and mask() to return by-value
The previous versions of these functions that returned by-pointer are held over from Qt 1 times. They are inconsistent with the rest of the Qt API. [ChangeLog][QtGui][QCursor] QCursor::bitmap() and QCursor::mask() can now return by-value instead of by-pointer. Task-number: QTBUG-48701 Change-Id: I3ca4f0c28d5c831727a60309facfb49c74673bb7 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/gui/kernel/qcursor.cpp')
-rw-r--r--src/gui/kernel/qcursor.cpp76
1 files changed, 75 insertions, 1 deletions
diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp
index 339284aa30..2018d28d92 100644
--- a/src/gui/kernel/qcursor.cpp
+++ b/src/gui/kernel/qcursor.cpp
@@ -325,7 +325,7 @@ QDataStream &operator<<(QDataStream &s, const QCursor &c)
if (isPixmap)
s << c.pixmap();
else
- s << *c.bitmap() << *c.mask();
+ s << c.bitmap(Qt::ReturnByValue) << c.mask(Qt::ReturnByValue);
s << c.hotSpot();
}
return s;
@@ -565,7 +565,12 @@ void QCursor::setShape(Qt::CursorShape shape)
}
}
+#if QT_DEPRECATED_SINCE(5, 15)
/*!
+ \deprecated
+
+ New code should use the other overload which returns QBitmap by-value.
+
Returns the cursor bitmap, or \nullptr if it is one of the
standard cursors.
*/
@@ -577,6 +582,10 @@ const QBitmap *QCursor::bitmap() const
}
/*!
+ \deprecated
+
+ New code should use the other overload which returns QBitmap by-value.
+
Returns the cursor bitmap mask, or \nullptr if it is one of the
standard cursors.
*/
@@ -587,6 +596,71 @@ const QBitmap *QCursor::mask() const
QCursorData::initialize();
return d->bmm;
}
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
+/*!
+ \since 5.15
+
+ Returns the cursor bitmap, or a null bitmap if it is one of the
+ standard cursors.
+
+ Previously, Qt provided a version of \c bitmap() which returned the bitmap
+ by-pointer. That version is now deprecated. To maintain compatibility
+ with old code, you can explicitly differentiate between the by-pointer
+ function and the by-value function:
+
+ \code
+ const QBitmap *bmpPtr = cursor->bitmap();
+ QBitmap bmpVal = cursor->bitmap(Qt::ReturnByValue);
+ \endcode
+
+ If you disable the deprecated version, then you can omit \c Qt::ReturnByValue
+ as shown below:
+
+ \code
+ QBitmap bmpVal = cursor->bitmap();
+ \endcode
+*/
+QBitmap QCursor::bitmap(Qt::ReturnByValue_t) const
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ if (d->bm)
+ return *(d->bm);
+ return QBitmap();
+}
+
+/*!
+ \since 5.15
+
+ Returns the cursor bitmap mask, or a null bitmap if it is one of the
+ standard cursors.
+
+ Previously, Qt provided a version of \c mask() which returned the bitmap
+ by-pointer. That version is now deprecated. To maintain compatibility
+ with old code, you can explicitly differentiate between the by-pointer
+ function and the by-value function:
+
+ \code
+ const QBitmap *bmpPtr = cursor->mask();
+ QBitmap bmpVal = cursor->mask(Qt::ReturnByValue);
+ \endcode
+
+ If you disable the deprecated version, then you can omit \c Qt::ReturnByValue
+ as shown below:
+
+ \code
+ QBitmap bmpVal = cursor->mask();
+ \endcode
+*/
+QBitmap QCursor::mask(Qt::ReturnByValue_t) const
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ if (d->bmm)
+ return *(d->bmm);
+ return QBitmap();
+}
/*!
Returns the cursor pixmap. This is only valid if the cursor is a