(Properties) OnPropertySet is called when any property is set 82/38682/4
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 24 Apr 2015 10:33:48 +0000 (11:33 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 24 Apr 2015 11:02:32 +0000 (12:02 +0100)
Change-Id: I075dca41b6bd975cd0a682ef62f4296d094334ab

dali/internal/event/actors/actor-impl.cpp
dali/internal/event/common/object-impl.cpp
dali/internal/event/common/object-impl.h

index 5d99b15..6cf14fc 100644 (file)
@@ -2930,8 +2930,6 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr
 // TODO: This method needs to be removed
 void Actor::SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value )
 {
-  OnPropertySet( index, value );
-
   switch( entry.type )
   {
     case Property::BOOLEAN:
index 34bd166..fb689da 100644 (file)
@@ -355,6 +355,8 @@ void Object::SetProperty( Property::Index index, const Property::Value& property
 {
   DALI_ASSERT_ALWAYS(index > Property::INVALID_INDEX && "Property index is out of bounds" );
 
+  bool propertySet( true );
+
   if ( index < DEFAULT_PROPERTY_MAX_COUNT )
   {
     SetDefaultProperty( index, propertyValue );
@@ -362,14 +364,7 @@ void Object::SetProperty( Property::Index index, const Property::Value& property
   else if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
   {
     const TypeInfo* typeInfo( GetTypeInfo() );
-    if ( typeInfo )
-    {
-      typeInfo->SetProperty( this, index, propertyValue );
-    }
-    else
-    {
-      DALI_LOG_ERROR("Cannot find property index\n");
-    }
+    typeInfo->SetProperty( this, index, propertyValue );
   }
   else if ( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
   {
@@ -378,13 +373,10 @@ void Object::SetProperty( Property::Index index, const Property::Value& property
     if(!animatableProperty)
     {
       const TypeInfo* typeInfo( GetTypeInfo() );
-      if (!typeInfo)
-      {
-        DALI_LOG_ERROR("Cannot find property index\n");
-      }
-      else if ( Property::INVALID_INDEX == RegisterSceneGraphProperty( typeInfo->GetPropertyName( index ), index, propertyValue ) )
+      if ( Property::INVALID_INDEX == RegisterSceneGraphProperty( typeInfo->GetPropertyName( index ), index, propertyValue ) )
       {
         DALI_LOG_ERROR("Cannot register property\n");
+        propertySet = false;
       }
     }
     else
@@ -406,15 +398,26 @@ void Object::SetProperty( Property::Index index, const Property::Value& property
       else if( custom->IsWritable() )
       {
         custom->value = propertyValue;
-        OnPropertySet(index, propertyValue);
       }
-      // trying to set value on read only property is no-op
+      else
+      {
+        // trying to set value on read only property is no-op
+        propertySet = false;
+      }
     }
     else
     {
       DALI_LOG_ERROR("Invalid property index\n");
+      propertySet = false;
     }
   }
+
+  // Let derived classes know that a property has been set
+  // TODO: We should not call this for read-only properties, SetDefaultProperty() && TypeInfo::SetProperty() should return a bool, which would be true if the property is set
+  if ( propertySet )
+  {
+    OnPropertySet(index, propertyValue);
+  }
 }
 
 Property::Value Object::GetProperty(Property::Index index) const
index be66703..9f34aed 100644 (file)
@@ -300,7 +300,7 @@ protected:
 
   /**
    * For use in derived classes.
-   * This is called after a non animatable custom property is set.
+   * This is called after a property is set.
    * @param [in] index The index of the property.
    * @param [in] propertyValue The value of the property.
    */