Removed invalid handle assignments from Builder/TextInput 99/25699/2
authorPaul Wisbey <p.wisbey@samsung.com>
Fri, 8 Aug 2014 12:09:52 +0000 (13:09 +0100)
committerPaul Wisbey <p.wisbey@samsung.com>
Mon, 11 Aug 2014 16:28:34 +0000 (17:28 +0100)
[problem] Unsafe handle assignments.
[solution] Removed the code assigning a shader to actor handle etc.

Change-Id: I70c85135693751840e429fdffa17d6a90a2b27d2

base/dali-toolkit/internal/builder/builder-animations.cpp
base/dali-toolkit/internal/builder/builder-impl.cpp
base/dali-toolkit/internal/controls/text-input/text-input-handles-impl.cpp

index 9f8bc47..b3a4bb4 100644 (file)
@@ -216,27 +216,33 @@ Animation CreateAnimation( const TreeNode& child, const Replacement& constant, D
       DALI_ASSERT_ALWAYS( actorName && "Animation must specify actor name" );
       DALI_ASSERT_ALWAYS( property  && "Animation must specify a property name" );
 
-      Actor targetActor = searchActor.FindChildByName( *actorName );
-      DALI_ASSERT_ALWAYS( targetActor && "Actor must exist for property" );
+      Handle targetHandle = searchActor.FindChildByName( *actorName );
+      DALI_ASSERT_ALWAYS( targetHandle && "Actor must exist for property" );
 
-      Property::Index idx( targetActor.GetPropertyIndex( *property ) );
+      Property::Index idx( targetHandle.GetPropertyIndex( *property ) );
 
-      // A limitation here is that its possible that between binding to the signal and
-      // the signal call that the ShaderEffect of the targetActor has been changed.
-      // However this is a unlikely use case especially when using scripts.
+      // if the property is not found from the (actor) handle, try to downcast it to renderable actor
+      // to allow animating shader uniforms
       if( idx == Property::INVALID_INDEX )
       {
-        if( ShaderEffect effect = targetActor.GetShaderEffect() )
+        RenderableActor renderable = RenderableActor::DownCast( targetHandle );
+        if( renderable )
         {
-          idx = effect.GetPropertyIndex( *property );
-          if(idx != Property::INVALID_INDEX)
+          // A limitation here is that its possible that between creation of animation
+          // and running it the ShaderEffect of the actor has been changed.
+          // However this is a unlikely use case especially when using scripts.
+          if( ShaderEffect effect = renderable.GetShaderEffect() )
           {
-            targetActor = effect;
-          }
-          else
-          {
-            DALI_SCRIPT_WARNING( "Cannot find property on object or ShaderEffect\n" );
-            continue;
+            idx = effect.GetPropertyIndex( *property );
+            if(idx != Property::INVALID_INDEX)
+            {
+              targetHandle = effect;
+            }
+            else
+            {
+              DALI_SCRIPT_WARNING( "Cannot find property on object or ShaderEffect\n" );
+              continue;
+            }
           }
         }
         else
@@ -252,7 +258,7 @@ Animation CreateAnimation( const TreeNode& child, const Replacement& constant, D
         continue;
       }
 
-      Property prop( Property( targetActor, idx ) );
+      Property prop( Property( targetHandle, idx ) );
       Property::Value propValue;
 
       // these are the defaults
index dc59a7e..5c6b2a3 100644 (file)
@@ -725,7 +725,7 @@ FrameBufferImage Builder::GetFrameBufferImage( const std::string &name, const Re
         if( SetPropertyFromNode( *image, Property::MAP, propertyMap, constant ) )
         {
           propertyMap.SetValue(KEYNAME_TYPE, Property::Value(std::string("FrameBufferImage")));
-          ret = Dali::Scripting::NewImage( propertyMap );
+          ret = FrameBufferImage::DownCast( Dali::Scripting::NewImage( propertyMap ) );
           mFrameBufferImageLut[ name ] = ret;
         }
       }
index 9743198..32a4b8e 100644 (file)
@@ -68,7 +68,7 @@ Actor CreateGrabArea( const std::string& name, const Vector3& relativeScale )
   return handleGrabArea;
 }
 
-Actor CreateHandle( const Vector3& anchorPoint, const Image& handleImage, const std::string& name )
+ImageActor CreateHandle( const Vector3& anchorPoint, const Image& handleImage, const std::string& name )
 {
   DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputHandles: CreateSelectionHandle\n" );