Remove unnecessary code in QCursor

Dont't checks before call QCursorData::initialize().
The inside of QCursorData::initialize() already checks initialized.

Change-Id: I4b34218132df9decf7d04dcc31e873daf300ffe6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
This commit is contained in:
JiDe Zhang 2023-10-10 09:36:14 +08:00
parent c94bed69b7
commit 518c98cea4

View File

@ -439,7 +439,6 @@ QCursor::QCursor()
QCursor::QCursor(Qt::CursorShape shape) QCursor::QCursor(Qt::CursorShape shape)
: d(nullptr) : d(nullptr)
{ {
if (!QCursorData::initialized)
QCursorData::initialize(); QCursorData::initialize();
setShape(shape); setShape(shape);
} }
@ -498,7 +497,6 @@ bool operator==(const QCursor &lhs, const QCursor &rhs) noexcept
*/ */
Qt::CursorShape QCursor::shape() const Qt::CursorShape QCursor::shape() const
{ {
if (!QCursorData::initialized)
QCursorData::initialize(); QCursorData::initialize();
return d->cshape; return d->cshape;
} }
@ -512,7 +510,6 @@ Qt::CursorShape QCursor::shape() const
*/ */
void QCursor::setShape(Qt::CursorShape shape) void QCursor::setShape(Qt::CursorShape shape)
{ {
if (!QCursorData::initialized)
QCursorData::initialize(); QCursorData::initialize();
QCursorData *c = uint(shape) <= Qt::LastCursor ? qt_cursorTable[shape] : nullptr; QCursorData *c = uint(shape) <= Qt::LastCursor ? qt_cursorTable[shape] : nullptr;
if (!c) if (!c)
@ -547,7 +544,6 @@ void QCursor::setShape(Qt::CursorShape shape)
*/ */
QBitmap QCursor::bitmap() const QBitmap QCursor::bitmap() const
{ {
if (!QCursorData::initialized)
QCursorData::initialize(); QCursorData::initialize();
if (d->bm) if (d->bm)
return *(d->bm); return *(d->bm);
@ -574,7 +570,6 @@ QBitmap QCursor::bitmap() const
*/ */
QBitmap QCursor::mask() const QBitmap QCursor::mask() const
{ {
if (!QCursorData::initialized)
QCursorData::initialize(); QCursorData::initialize();
if (d->bmm) if (d->bmm)
return *(d->bmm); return *(d->bmm);
@ -588,7 +583,6 @@ QBitmap QCursor::mask() const
QPixmap QCursor::pixmap() const QPixmap QCursor::pixmap() const
{ {
if (!QCursorData::initialized)
QCursorData::initialize(); QCursorData::initialize();
return d->pixmap; return d->pixmap;
} }
@ -600,7 +594,6 @@ QPixmap QCursor::pixmap() const
QPoint QCursor::hotSpot() const QPoint QCursor::hotSpot() const
{ {
if (!QCursorData::initialized)
QCursorData::initialize(); QCursorData::initialize();
return QPoint(d->hx, d->hy); return QPoint(d->hx, d->hy);
} }
@ -611,7 +604,6 @@ QPoint QCursor::hotSpot() const
QCursor::QCursor(const QCursor &c) QCursor::QCursor(const QCursor &c)
{ {
if (!QCursorData::initialized)
QCursorData::initialize(); QCursorData::initialize();
d = c.d; d = c.d;
d->ref.ref(); d->ref.ref();
@ -635,7 +627,6 @@ QCursor::~QCursor()
QCursor &QCursor::operator=(const QCursor &c) QCursor &QCursor::operator=(const QCursor &c)
{ {
if (!QCursorData::initialized)
QCursorData::initialize(); QCursorData::initialize();
if (c.d) if (c.d)
c.d->ref.ref(); c.d->ref.ref();
@ -707,7 +698,6 @@ void QCursorData::initialize()
QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY, qreal devicePixelRatio) QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY, qreal devicePixelRatio)
{ {
if (!QCursorData::initialized)
QCursorData::initialize(); QCursorData::initialize();
if (bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size()) { if (bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size()) {
qWarning("QCursor: Cannot create bitmap cursor; invalid bitmap(s)"); qWarning("QCursor: Cannot create bitmap cursor; invalid bitmap(s)");