int UtcDaliFrameCallbackActorDestroyed(void)
{
+ // Test to ensure that the frame-callback behaves gracefully if the connected root-actor is destroyed
+
TestApplication application;
Stage stage = Stage::GetCurrent();
END_TEST;
}
+
+int UtcDaliFrameCallbackDestroyedBeforeRemoving(void)
+{
+ // Ensure there's no segmentation fault if the callback is deleted without being removed
+
+ TestApplication application;
+ Stage stage = Stage::GetCurrent();
+
+ Actor actor = Actor::New();
+ stage.Add( actor );
+
+ {
+ FrameCallbackBasic frameCallback;
+ DevelStage::AddFrameCallback( stage, frameCallback, actor );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( frameCallback.mCalled, true, TEST_LOCATION );
+ frameCallback.Reset();
+ }
+
+ // frameCallback has now been destroyed but not removed
+
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK( true ); // If it runs to here then there's no segmentation fault
+
+ END_TEST;
+}
${CMAKE_CURRENT_SOURCE_DIR}/threading/conditional-wait.cpp
${CMAKE_CURRENT_SOURCE_DIR}/threading/mutex.cpp
${CMAKE_CURRENT_SOURCE_DIR}/threading/thread.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/update/frame-callback-interface.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/update/update-proxy.cpp
PARENT_SCOPE )
${CMAKE_CURRENT_SOURCE_DIR}/threading/mutex.h
${CMAKE_CURRENT_SOURCE_DIR}/threading/thread.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/update/frame-callback-interface.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/update/update-proxy.h
+
PARENT_SCOPE )
*
* @param[in] stage The stage to clear the FrameCallbackInterface on
* @param[in] frameCallback The FrameCallbackInterface implementation to remove
+ *
+ * @note If the callback implementation has already been removed, then this is a no-op.
*/
DALI_IMPORT_API void RemoveFrameCallback( Dali::Stage stage, FrameCallbackInterface& frameCallback );
$(devel_api_src_dir)/threading/conditional-wait.cpp \
$(devel_api_src_dir)/threading/mutex.cpp \
$(devel_api_src_dir)/threading/thread.cpp \
+ $(devel_api_src_dir)/update/frame-callback-interface.cpp \
$(devel_api_src_dir)/update/update-proxy.cpp
# Add devel header files here DALi internal developer files used by Adaptor & Toolkit
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/devel-api/update/frame-callback-interface.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/update/update-proxy.h>
+#include <dali/internal/event/common/stage-impl.h>
+
+namespace Dali
+{
+
+FrameCallbackInterface::~FrameCallbackInterface()
+{
+ if( Internal::Stage::IsInstalled() )
+ {
+ Internal::StagePtr stage = Internal::Stage::GetCurrent();
+ if( stage )
+ {
+ // This will be a no-op if the callback has already been removed
+ stage->RemoveFrameCallback( *this );
+ }
+ }
+}
+
+} // namespace Dali
/**
* @brief Protected virtual destructor.
*/
- virtual ~FrameCallbackInterface() {}
+ virtual ~FrameCallbackInterface();
};
} // namespace Dali
} // unnamed namespace
-FrameCallbackProcessor::FrameCallbackProcessor( TransformManager& transformManager, Node& rootNode )
+FrameCallbackProcessor::FrameCallbackProcessor( TransformManager& transformManager )
: mFrameCallbacks(),
mTransformManager( transformManager ),
- mRootNode( rootNode ),
mNodeHierarchyChanged( true )
{
}
/**
* Construct a new FrameCallbackProcessor.
*/
- FrameCallbackProcessor( TransformManager& transformManager, Node& rootNode );
+ FrameCallbackProcessor( TransformManager& transformManager );
/**
* Non-virtual Destructor.
std::vector< FrameCallbackInfo > mFrameCallbacks; ///< A container of all the frame-callbacks & accompanying update-proxies.
TransformManager& mTransformManager;
- Node& mRootNode;
bool mNodeHierarchyChanged; ///< Set to true if the node hierarchy changes
};
{
if( ! frameCallbackProcessor )
{
- frameCallbackProcessor = new FrameCallbackProcessor( transformManager, *root );
+ frameCallbackProcessor = new FrameCallbackProcessor( transformManager );
}
return *frameCallbackProcessor;
}