Remove current and future memory leaks with messages by forcing the use of OwnerPoint...
[platform/core/uifw/dali-core.git] / dali / internal / update / animation / scene-graph-constraint-base.cpp
index 5c0f481..9a692dd 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.
@@ -18,9 +18,6 @@
 // CLASS HEADER
 #include <dali/internal/update/animation/scene-graph-constraint.h>
 
-// INTERNAL INCLUDES
-#include <dali/public-api/animation/active-constraint.h>
-
 namespace Dali
 {
 
@@ -30,13 +27,21 @@ namespace Internal
 namespace SceneGraph
 {
 
-ConstraintBase::ConstraintBase( PropertyOwnerSet& ownerSet )
-: mWeight( Dali::ActiveConstraint::DEFAULT_WEIGHT ),
-  mRemoveAction( Dali::Constraint::DEFAULT_REMOVE_ACTION ),
+#ifdef DEBUG_ENABLED
+  unsigned int ConstraintBase::mCurrentInstanceCount = 0;
+  unsigned int ConstraintBase::mTotalInstanceCount   = 0;
+#endif
+
+ConstraintBase::ConstraintBase( PropertyOwnerContainer& ownerSet, RemoveAction removeAction )
+: mRemoveAction( removeAction ),
   mFirstApply( true ),
   mDisconnected( true ),
   mObservedOwners( ownerSet )
 {
+#ifdef DEBUG_ENABLED
+  ++mCurrentInstanceCount;
+  ++mTotalInstanceCount;
+#endif
 }
 
 ConstraintBase::~ConstraintBase()
@@ -46,19 +51,34 @@ ConstraintBase::~ConstraintBase()
     StopObservation();
   }
 
-// TODO - Override new & delete to provide this for everything
 #ifdef DEBUG_ENABLED
-  // Fill with garbage pattern to help detect invalid memory access
-  memset ( &mWeight, 0xFA, sizeof(mWeight) );
+  --mCurrentInstanceCount;
 #endif
 }
 
 void ConstraintBase::ResetDefaultProperties( BufferIndex updateBufferIndex )
 {
-  // Not used, since the weight property is reset by PropertyOwner
   DALI_ASSERT_DEBUG( false );
 }
 
+unsigned int ConstraintBase::GetCurrentInstanceCount()
+{
+#ifdef DEBUG_ENABLED
+  return mCurrentInstanceCount;
+#else
+  return 0u;
+#endif
+}
+
+unsigned int ConstraintBase::GetTotalInstanceCount()
+{
+#ifdef DEBUG_ENABLED
+  return mTotalInstanceCount;
+#else
+  return 0u;
+#endif
+}
+
 } // namespace SceneGraph
 
 } // namespace Internal