Remove current and future memory leaks with messages by forcing the use of OwnerPoint...
[platform/core/uifw/dali-core.git] / dali / internal / update / common / property-owner.cpp
index e6cfa77..aa666ef 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -110,11 +110,9 @@ void PropertyOwner::DisconnectFromSceneGraph( BufferIndex updateBufferIndex )
   mConstraints.Clear();
 }
 
-void PropertyOwner::InstallCustomProperty(PropertyBase* property)
+void PropertyOwner::InstallCustomProperty( OwnerPointer<PropertyBase>& property )
 {
-  DALI_ASSERT_DEBUG( NULL != property );
-
-  mCustomProperties.PushBack( property );
+  mCustomProperties.PushBack( property.Release() );
 }
 
 void PropertyOwner::ResetToBaseValues( BufferIndex updateBufferIndex )
@@ -126,13 +124,6 @@ void PropertyOwner::ResetToBaseValues( BufferIndex updateBufferIndex )
     (*iter)->ResetToBaseValue( updateBufferIndex );
   }
 
-  // Reset constraint weights
-  const ConstraintIter constraintEndIter = mConstraints.End();
-  for( ConstraintIter iter = mConstraints.Begin(); constraintEndIter != iter; ++iter )
-  {
-    (*iter)->mWeight.ResetToBaseValue( updateBufferIndex );
-  }
-
   // Notification for derived classes, to reset default properties
   ResetDefaultProperties( updateBufferIndex );
 }
@@ -142,16 +133,14 @@ ConstraintOwnerContainer& PropertyOwner::GetConstraints()
   return mConstraints;
 }
 
-void PropertyOwner::ApplyConstraint( ConstraintBase* constraint )
+void PropertyOwner::ApplyConstraint( OwnerPointer<ConstraintBase>& constraint )
 {
-  mConstraints.PushBack( constraint );
-
   constraint->OnConnect();
+  mConstraints.PushBack( constraint.Release() );
 }
 
 void PropertyOwner::RemoveConstraint( ConstraintBase* constraint )
 {
-  // Reset constraint weights
   const ConstraintIter constraintEndIter = mConstraints.End();
   for( ConstraintIter iter = mConstraints.Begin(); constraintEndIter != iter; ++iter )
   {
@@ -162,14 +151,40 @@ void PropertyOwner::RemoveConstraint( ConstraintBase* constraint )
     }
   }
 
-  // Should not come here
-  DALI_ASSERT_DEBUG( false && "Constraint missing in RemoveConstraint" );
+  //it may be that the constraint has already been removed e.g. from disconnection from scene graph, so nothing needs to be done
 }
 
 PropertyOwner::PropertyOwner()
 {
 }
 
+void PropertyOwner::AddUniformMapping( OwnerPointer< UniformPropertyMapping >& map )
+{
+  mUniformMaps.Add( map.Release() );
+}
+
+void PropertyOwner::RemoveUniformMapping( const std::string& uniformName )
+{
+  mUniformMaps.Remove( uniformName );
+}
+
+const UniformMap& PropertyOwner::GetUniformMap() const
+{
+  return mUniformMaps;
+}
+
+void PropertyOwner::AddUniformMapObserver( UniformMap::Observer& observer )
+{
+  mUniformMaps.AddObserver( observer );
+}
+
+void PropertyOwner::RemoveUniformMapObserver( UniformMap::Observer& observer )
+{
+  mUniformMaps.RemoveObserver( observer );
+}
+
+
+
 } // namespace SceneGraph
 
 } // namespace Internal