Remove UNSIGNED_INTEGER property type as it does not fully work and causes headache
[platform/core/uifw/dali-core.git] / dali / internal / event / common / property-buffer-impl.cpp
index 5fbae8c..7fa13f7 100644 (file)
@@ -22,7 +22,9 @@
 #include <algorithm> // std::sort
 
 // INTERNAL INCLUDES
-#include <dali/public-api/object/property-buffer.h> // Dali::Internal::PropertyBuffer
+#include <dali/public-api/object/type-registry.h>
+#include <dali/devel-api/object/property-buffer.h> // Dali::Internal::PropertyBuffer
+
 #include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
 #include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
 #include <dali/internal/update/common/scene-graph-property-buffer.h>
@@ -43,12 +45,19 @@ namespace
  *            |name    |type             |writable|animatable|constraint-input|enum for index-checking|
  */
 DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "size",          UNSIGNED_INTEGER, true, false,  true,   Dali::PropertyBuffer::Property::SIZE )
-DALI_PROPERTY( "buffer-format", MAP,              false, false, false,  Dali::PropertyBuffer::Property::BUFFER_FORMAT )
+DALI_PROPERTY( "size",          INTEGER, true,  false, true,   Dali::PropertyBuffer::Property::SIZE )
+DALI_PROPERTY( "buffer-format", MAP,     false, false, false,  Dali::PropertyBuffer::Property::BUFFER_FORMAT )
 DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX )
 
 const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> PROPERTY_BUFFER_IMPL = { DEFAULT_PROPERTY_DETAILS };
 
+BaseHandle Create()
+{
+  return Dali::BaseHandle();
+}
+
+TypeRegistration mType( typeid( Dali::PropertyBuffer ), typeid( Dali::Handle ), Create );
+
 /**
  * Calculate the alignment requirements of a type
  *
@@ -75,7 +84,6 @@ unsigned int GetPropertyImplementationAlignment( Property::Type& propertyType )
   switch( propertyType )
   {
     case Property::NONE:
-    case Property::TYPE_COUNT:
     case Property::STRING:
     case Property::ARRAY:
     case Property::MAP:
@@ -93,11 +101,6 @@ unsigned int GetPropertyImplementationAlignment( Property::Type& propertyType )
       alignment = PropertyImplementationTypeAlignment< Property::INTEGER >::VALUE;
       break;
     }
-    case Property::UNSIGNED_INTEGER:
-    {
-      alignment = PropertyImplementationTypeAlignment< Property::UNSIGNED_INTEGER >::VALUE;
-      break;
-    }
     case Property::FLOAT:
     {
       alignment = PropertyImplementationTypeAlignment< Property::FLOAT >::VALUE;
@@ -272,7 +275,7 @@ Property::Value PropertyBuffer::GetDefaultProperty( Property::Index index ) cons
   {
     case Dali::PropertyBuffer::Property::SIZE:
     {
-      value = static_cast<int>( GetSize() ); // @todo MESH_REWORK Add a size_t type to PropertyValue
+      value = static_cast<int>( GetSize() );
       break;
     }
     case Dali::PropertyBuffer::Property::BUFFER_FORMAT:
@@ -364,6 +367,14 @@ void PropertyBuffer::Disconnect()
 
 PropertyBuffer::~PropertyBuffer()
 {
+  if( EventThreadServices::IsCoreRunning() )
+  {
+    EventThreadServices& eventThreadServices = GetEventThreadServices();
+    SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
+    RemoveMessage( updateManager, updateManager.GetPropertyBufferOwner(), *mSceneObject );
+
+    eventThreadServices.UnregisterObject( this );
+  }
 }
 
 PropertyBuffer::PropertyBuffer()
@@ -379,10 +390,10 @@ void PropertyBuffer::Initialize()
   EventThreadServices& eventThreadServices = GetEventThreadServices();
   SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
 
-  DALI_ASSERT_ALWAYS( EventThreadServices::IsCoreRunning() && "Core is not running" );
-
   mSceneObject = new SceneGraph::PropertyBuffer();
   AddMessage( updateManager, updateManager.GetPropertyBufferOwner(), *mSceneObject );
+
+  eventThreadServices.RegisterObject( this );
 }
 
 void PropertyBuffer::FormatChanged()
@@ -473,7 +484,6 @@ unsigned int GetPropertyImplementationSize( Property::Type& propertyType )
   switch( propertyType )
   {
     case Property::NONE:
-    case Property::TYPE_COUNT:
     case Property::STRING:
     case Property::ARRAY:
     case Property::MAP:
@@ -491,11 +501,6 @@ unsigned int GetPropertyImplementationSize( Property::Type& propertyType )
       size = sizeof( PropertyImplementationType< Property::INTEGER >::Type );
       break;
     }
-    case Property::UNSIGNED_INTEGER:
-    {
-      size = sizeof( PropertyImplementationType< Property::UNSIGNED_INTEGER >::Type );
-      break;
-    }
     case Property::FLOAT:
     {
       size = sizeof( PropertyImplementationType< Property::FLOAT >::Type );