Fix issues with text scrolling & transition effects using GetVectorXY() incorrectly 76/69776/5
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 16 May 2016 17:16:41 +0000 (18:16 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 17 May 2016 10:46:47 +0000 (03:46 -0700)
Vector3::GetVectorXY() returns a ref (or a const ref). This is problematic in the files in this
patch because they are returning a ref to a temporary variable which then goes out-of-scope later

The fix is to just create a copy of the value on the stack rather than pass a ref to the temporary
variable.

Change-Id: I2e93748943487a677d394064b70c2b6afe983dbf

dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/transition-effects/cube-transition-cross-effect-impl.cpp
dali-toolkit/internal/transition-effects/cube-transition-wave-effect-impl.cpp

index 6d46758..6a39ee7 100644 (file)
@@ -681,8 +681,8 @@ void TextLabel::RenderText()
 
 void TextLabel::SetUpAutoScrolling()
 {
-  const Size& controlSize = mController->GetView().GetControlSize();
-  const Size& offScreenSize = GetNaturalSize().GetVectorXY(); // As relayout of text may not be done at this point natural size is used to get size. Single line scrolling only.
+  const Size& controlSize = mController->GetView().GetControlSize(); // Needs to be a ref as the control-size can be changed by GetNaturalSize()
+  const Size offScreenSize = GetNaturalSize().GetVectorXY(); // As relayout of text may not be done at this point natural size is used to get size. Single line scrolling only.
   const Vector2& alignmentOffset = mController->GetAlignmentOffset();
   const Text::CharacterDirection direction = mController->GetAutoScrollDirection();
 
index 10ffbff..3026d9c 100644 (file)
@@ -105,8 +105,7 @@ void CubeTransitionCrossEffect::OnStartTransition( Vector2 panPosition, Vector2
     }
   }
 
-  const Vector2& size = Self().GetCurrentSize().GetVectorXY();
-  Vector2 halfSize = size * 0.5f;
+  const Vector2 halfSize = Self().GetCurrentSize().GetVectorXY() * 0.5f;
   //the centre to "explode" the tiles outwards from
   Vector3 centre( halfSize.x, halfSize.y, -1.0f / mDisplacementSpreadFactor );
 
@@ -130,7 +129,7 @@ void CubeTransitionCrossEffect::OnStartTransition( Vector2 panPosition, Vector2
 
 void CubeTransitionCrossEffect::SetupAnimation( unsigned int actorIndex, unsigned int x, unsigned int y, float angle, const Vector3 axis, const Vector3& displacementCentre )
 {
-  const Vector2& size = Self().GetCurrentSize().GetVectorXY();
+  const Vector2 size = Self().GetCurrentSize().GetVectorXY();
   Vector2 halfSize = size * 0.5f;
 
   //the position of the centre of the front face tile
index d4ce91d..525a61e 100644 (file)
@@ -109,7 +109,7 @@ void CubeTransitionWaveEffect::OnStartTransition( Vector2 panPosition, Vector2 p
 
 void  CubeTransitionWaveEffect::CalculateSaddleSurfaceParameters( Vector2 position, Vector2 displacement )
 {
-  const Vector2& size = Self().GetCurrentSize().GetVectorXY();
+  const Vector2 size = Self().GetCurrentSize().GetVectorXY();
   // the line passes through 'position' and has the direction of 'displacement'
   float coefA, coefB, coefC; //line equation: Ax+By+C=0;
   coefA = displacement.y;