From 3eae9cf0f68c03e0d49ddeff67fa9e3166007cc5 Mon Sep 17 00:00:00 2001 From: RH Date: Wed, 22 Mar 2023 00:22:02 +1100 Subject: [PATCH] Fix return reference to local temporary value (#1127) * Fix invalid return type for temporary variable --- core/2d/CCAnchoredSprite.cpp | 2 +- core/2d/CCAnchoredSprite.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/2d/CCAnchoredSprite.cpp b/core/2d/CCAnchoredSprite.cpp index fa640e2806..1c93e96bb9 100644 --- a/core/2d/CCAnchoredSprite.cpp +++ b/core/2d/CCAnchoredSprite.cpp @@ -200,7 +200,7 @@ void AnchoredSprite::setAnchorPoint(const Vec2& anchor) updatePoly(); } -const Rect& AnchoredSprite::getTouchRect() +Rect AnchoredSprite::getTouchRect() { Size s = getContentSize(); Size a = _spriteVertexAnchor * s; diff --git a/core/2d/CCAnchoredSprite.h b/core/2d/CCAnchoredSprite.h index 249f2305f1..07b1d345ab 100644 --- a/core/2d/CCAnchoredSprite.h +++ b/core/2d/CCAnchoredSprite.h @@ -140,7 +140,7 @@ public: /* This function will reposition the sprite's vertices itself instead of the node */ virtual void setAnchorPoint(const Vec2& anchor) override; /* Gets the hit area of the anchored sprite, this requires special calculations for shifted vertices and should be used with touch event listeners */ - virtual const Rect& getTouchRect(); + virtual Rect getTouchRect(); protected: virtual void setVertexCoords(const Rect& rect, V3F_C4B_T2F_Quad* outQuad) override;