From 7d98d6005be837e30dfab2e922173031d1bf9611 Mon Sep 17 00:00:00 2001
From: Paul Wisbey
Date: Tue, 8 Sep 2015 11:12:28 +0100
Subject: [PATCH] Fixed Helgrind issue with SceneGraph::Animator creation
Change-Id: Ieabaf8f2c7a607cdbfeea448d03ef690174642ad
---
.../update/animation/scene-graph-animation.cpp | 2 ++
.../update/animation/scene-graph-animator.h | 23 +++++++++++++++++++---
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/dali/internal/update/animation/scene-graph-animation.cpp b/dali/internal/update/animation/scene-graph-animation.cpp
index de9c793..a2538d1 100644
--- a/dali/internal/update/animation/scene-graph-animation.cpp
+++ b/dali/internal/update/animation/scene-graph-animation.cpp
@@ -194,7 +194,9 @@ void Animation::OnDestroy(BufferIndex bufferIndex)
void Animation::AddAnimator( AnimatorBase* animator )
{
+ animator->ConnectToSceneGraph();
animator->SetDisconnectAction( mDisconnectAction );
+
mAnimators.PushBack( animator );
}
diff --git a/dali/internal/update/animation/scene-graph-animator.h b/dali/internal/update/animation/scene-graph-animator.h
index e96d389..e153b86 100644
--- a/dali/internal/update/animation/scene-graph-animator.h
+++ b/dali/internal/update/animation/scene-graph-animator.h
@@ -71,7 +71,8 @@ public:
mAlphaFunction(AlphaFunction::DEFAULT),
mDisconnectAction(Dali::Animation::BakeFinal),
mActive(false),
- mEnabled(true)
+ mEnabled(true),
+ mConnectedToSceneGraph(false)
{
}
@@ -83,6 +84,11 @@ public:
}
/**
+ * Called when Animator is added to the scene-graph in update-thread.
+ */
+ virtual void ConnectToSceneGraph() = 0;
+
+ /**
* Set the duration of the animator.
* @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
* @param [in] seconds Duration in seconds.
@@ -356,6 +362,7 @@ protected:
Dali::Animation::EndAction mDisconnectAction; ///< EndAction to apply when target object gets disconnected from the stage.
bool mActive:1; ///< Animator is "active" while it's running.
bool mEnabled:1; ///< Animator is "enabled" while its target object is valid and on the stage.
+ bool mConnectedToSceneGraph:1; ///< True if ConnectToSceneGraph() has been called in update-thread.
};
/**
@@ -399,7 +406,7 @@ public:
*/
virtual ~Animator()
{
- if (mPropertyOwner)
+ if (mPropertyOwner && mConnectedToSceneGraph)
{
mPropertyOwner->RemoveObserver(*this);
}
@@ -411,6 +418,15 @@ public:
}
/**
+ * Called when Animator is added to the scene-graph in update-thread.
+ */
+ virtual void ConnectToSceneGraph()
+ {
+ mConnectedToSceneGraph = true;
+ mPropertyOwner->AddObserver(*this);
+ }
+
+ /**
* Called when mPropertyOwner is connected to the scene graph.
*/
virtual void PropertyOwnerConnected( PropertyOwner& owner )
@@ -487,7 +503,8 @@ private:
mAnimatorFunction( animatorFunction ),
mCurrentProgress( 0.0f )
{
- mPropertyOwner->AddObserver(*this);
+ // WARNING - this object is created in the event-thread
+ // The scene-graph mPropertyOwner object cannot be observed here
}
// Undefined
--
2.7.4