[3.0] Ensured consistency of scene graph and render items
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / update-manager.cpp
index 951c4c5..0c6f697 100644 (file)
@@ -191,7 +191,7 @@ struct UpdateManager::Impl
     for(;iter!=endIter;++iter)
     {
       (*iter)->OnDestroy();
-      delete(*iter);
+      Node::Delete(*iter);
     }
 
     // If there is root, reset it, otherwise do nothing as rendering was never started
@@ -199,7 +199,7 @@ struct UpdateManager::Impl
     {
       root->OnDestroy();
 
-      delete root;
+      Node::Delete( root );
       root = NULL;
     }
 
@@ -207,7 +207,7 @@ struct UpdateManager::Impl
     {
       systemLevelRoot->OnDestroy();
 
-      delete systemLevelRoot;
+      Node::Delete( systemLevelRoot );
       systemLevelRoot = NULL;
     }
 
@@ -638,6 +638,9 @@ void UpdateManager::RemoveTextureSet( TextureSet* textureSet )
     if( textureSet == mImpl->textureSets[i] )
     {
       mImpl->textureSets.Remove( mImpl->textureSets.Begin() + i );
+
+      // Update manager has ownership of the TextureSet
+      delete textureSet;
       return;
     }
   }
@@ -914,7 +917,7 @@ unsigned int UpdateManager::Update( float elapsedSeconds,
   //Process Touches & Gestures
   const bool gestureUpdated = ProcessGestures( bufferIndex, lastVSyncTimeMilliseconds, nextVSyncTimeMilliseconds );
 
-  const bool updateScene =                                  // The scene-graph requires an update if..
+  bool updateScene = // The scene-graph requires an update if..
       (mImpl->nodeDirtyFlags & RenderableUpdateFlags) ||    // ..nodes were dirty in previous frame OR
       IsAnimationRunning()                            ||    // ..at least one animation is running OR
       mImpl->messageQueue.IsSceneUpdateRequired()     ||    // ..a message that modifies the scene graph node tree is queued OR
@@ -931,8 +934,10 @@ unsigned int UpdateManager::Update( float elapsedSeconds,
     mImpl->transformManager.ResetToBaseValue();
   }
 
-  //Process the queued scene messages
-  mImpl->messageQueue.ProcessMessages( bufferIndex );
+  // Process the queued scene messages. Note, MessageQueue::FlushQueue may be called
+  // between calling IsSceneUpdateRequired() above and here, so updateScene should
+  // be set again
+  updateScene |= mImpl->messageQueue.ProcessMessages( bufferIndex );
 
   //Post Process Ids of resources updated by renderer
   mImpl->resourceManager.PostProcessResources( bufferIndex );