Klockwork fixes: Distance field iteration 83/29883/1
authorKingsley Stephens <k.stephens@partner.samsung.com>
Tue, 4 Nov 2014 11:34:38 +0000 (11:34 +0000)
committerKingsley Stephens <k.stephens@partner.samsung.com>
Wed, 5 Nov 2014 13:21:30 +0000 (13:21 +0000)
                 Checking for null pointers
                 Initialising member variables

Change-Id: I9a33b28759ceea74ba90507472de54affdcb0632

19 files changed:
dali/integration-api/glyph-set.cpp
dali/internal/event/actor-attachments/light-attachment-impl.cpp
dali/internal/event/actor-attachments/mesh-attachment-impl.cpp
dali/internal/event/actor-attachments/text-attachment-impl.cpp
dali/internal/event/events/actor-observer.cpp
dali/internal/event/modeling/model-archive.cpp
dali/internal/event/text/atlas/glyph-atlas-manager.cpp
dali/internal/event/text/font-layout.cpp
dali/internal/event/text/resource/glyph-resource-request.cpp
dali/internal/event/text/resource/glyph-resource-request.h
dali/internal/event/text/text-request-helper.cpp
dali/internal/render/common/render-manager.cpp
dali/internal/render/gl-resources/context.cpp
dali/internal/update/render-tasks/scene-graph-render-task-list.cpp
dali/internal/update/resources/resource-manager.cpp
dali/public-api/common/dali-common.cpp
dali/public-api/events/key-event.cpp
dali/public-api/images/distance-field.cpp
dali/public-api/signals/callback.cpp

index 9c9b4cdda83dca2d032d8bfbe1eeeab2e464e032..33d3e47a51a92dc061e6b0209101853af45d96c6 100644 (file)
@@ -31,7 +31,8 @@ GlyphSet::GlyphSet()
   mUnitsPerEM(0.0f),
   mUnderlinePosition(0.0f),
   mUnderlineThickness(0.0f),
-  mPadAdjust(0.0f)
+  mPadAdjust(0.0f),
+  mAtlasId( 0 )
 {
 }
 
index 5b44c03810c8e52b982e2c3cc4ef72450a51bef5..6f6f87b5026e075b7c8d40ccb094bc447275cd5a 100644 (file)
@@ -47,7 +47,8 @@ LightAttachmentPtr LightAttachment::New( const SceneGraph::Node& parentNode )
 }
 
 LightAttachment::LightAttachment( Stage& stage )
-: ActorAttachment( stage )
+: ActorAttachment( stage ),
+  mSceneObject( NULL )
 {
   mCachedLight = new Internal::Light( "Unnamed" );
 }
index f2a81d6cf3410a803af3af7031cae645b6ad7418..90ac633e9e9a516071f5929d7babd1ff0172d4de 100644 (file)
@@ -54,6 +54,7 @@ MeshAttachmentPtr MeshAttachment::New( const SceneGraph::Node& parentNode )
 
 MeshAttachment::MeshAttachment( Stage& stage )
 : RenderableAttachment( stage ),
+  mSceneObject( NULL ),
   mAffectedByLighting( true )
 {
 }
index 454bfee64b2114f0753af3f8f8005972a6964f04..97ee7ad68065e8656062f981c16ff751aad8dd1c 100644 (file)
@@ -57,6 +57,7 @@ TextAttachmentPtr TextAttachment::New( const SceneGraph::Node& parentNode, const
 
 TextAttachment::TextAttachment( Stage& stage )
 : RenderableAttachment( stage ),
+  mSceneObject( NULL ),
   mTextRequestHelper( *this ),
   mTextColor( NULL ),
   mTextChanged( true ),
@@ -599,25 +600,28 @@ const SceneGraph::RenderableAttachment& TextAttachment::GetSceneObject() const
 
 void TextAttachment::SetTextChanges()
 {
-  // record the natural size of the text
-  mTextSize = mVertexBuffer->mVertexMax;
+  if( mVertexBuffer )
+  {
+    // record the natural size of the text
+    mTextSize = mVertexBuffer->mVertexMax;
 
-  // remember the texture id, so we can detect atlas resizes / splits
-  mTextureId = mVertexBuffer->mTextureId;
+    // remember the texture id, so we can detect atlas resizes / splits
+    mTextureId = mVertexBuffer->mTextureId;
 
-  EventToUpdate& eventToUpdate(  mStage->GetUpdateInterface() );
-  const SceneGraph::TextAttachment& attachment( *mSceneObject );
+    EventToUpdate& eventToUpdate(  mStage->GetUpdateInterface() );
+    const SceneGraph::TextAttachment& attachment( *mSceneObject );
 
-  if( mTextChanged  || mFontChanged )
-  {
-    DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "TextAttachment::SetTextChanges() Sending VertexBuffer to attachment:%p  textureId:%d\n", &attachment, mVertexBuffer->mTextureId);
+    if( mTextChanged  || mFontChanged )
+    {
+      DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "TextAttachment::SetTextChanges() Sending VertexBuffer to attachment:%p  textureId:%d\n", &attachment, mVertexBuffer->mTextureId);
 
-    // release the vertex buffer to pass  ownership to the scene-graph-text-attachment
-    SetTextVertexBufferMessage( eventToUpdate, attachment, *mVertexBuffer.Release() );
+      // release the vertex buffer to pass  ownership to the scene-graph-text-attachment
+      SetTextVertexBufferMessage( eventToUpdate, attachment, *mVertexBuffer.Release() );
 
-    if( mFontChanged )
-    {
-      SetTextFontSizeMessage( eventToUpdate, attachment, mFont->GetPixelSize() );
+      if( mFontChanged )
+      {
+        SetTextFontSizeMessage( eventToUpdate, attachment, mFont->GetPixelSize() );
+      }
     }
   }
 }
index 51c33a009fbecc8e010f28081d9744cfbd4aa771..ff1ce2ddd428009b693b0f858cb5af8e3d0def19 100644 (file)
@@ -16,9 +16,9 @@
  */
 
 // CLASS HEADER
+#include <dali/internal/event/events/actor-observer.h>
 #include <dali/integration-api/debug.h>
 #include <dali/internal/event/actors/actor-impl.h>
-#include <dali/internal/event/events/actor-observer.h>
 
 namespace Dali
 {
@@ -33,25 +33,25 @@ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ACT
 #endif // defined(DEBUG_ENABLED)
 }
 
-ActorObserver::ActorObserver::ActorObserver()
+ActorObserver::ActorObserver()
 : mActor ( NULL ),
   mActorDisconnected(false)
 {
   DALI_LOG_TRACE_METHOD( gLogFilter );
 }
 
-ActorObserver::ActorObserver::~ActorObserver()
+ActorObserver::~ActorObserver()
 {
   DALI_LOG_TRACE_METHOD( gLogFilter );
   SetActor( NULL );
 }
 
-Actor* ActorObserver::ActorObserver::GetActor()
+Actor* ActorObserver::GetActor()
 {
   return mActorDisconnected ? NULL : mActor;
 }
 
-void ActorObserver::ActorObserver::SetActor( Actor* actor )
+void ActorObserver::SetActor( Actor* actor )
 {
   DALI_LOG_TRACE_METHOD( gLogFilter );
 
@@ -72,7 +72,7 @@ void ActorObserver::ActorObserver::SetActor( Actor* actor )
   mActorDisconnected = false;
 }
 
-void ActorObserver::ActorObserver::ResetActor()
+void ActorObserver::ResetActor()
 {
   if ( mActor )
   {
@@ -83,7 +83,7 @@ void ActorObserver::ActorObserver::ResetActor()
   }
 }
 
-void ActorObserver::ActorObserver::SceneObjectRemoved( ProxyObject& proxy )
+void ActorObserver::SceneObjectRemoved( ProxyObject& proxy )
 {
   DALI_LOG_TRACE_METHOD( gLogFilter );
 
@@ -94,7 +94,7 @@ void ActorObserver::ActorObserver::SceneObjectRemoved( ProxyObject& proxy )
   }
 }
 
-void ActorObserver::ActorObserver::ProxyDestroyed(ProxyObject& proxy)
+void ActorObserver::ProxyDestroyed(ProxyObject& proxy)
 {
   DALI_LOG_TRACE_METHOD( gLogFilter );
 
index 86a3f80f1bd7eabcda7c450f220b8d271fd826cf..e630764fa3ca64dd08940127775c68c1b6224539 100644 (file)
@@ -450,53 +450,76 @@ Archive& operator<< (Archive& ar, const Dali::EntityAnimatorMap& t)
   ar << t.GetEntityName();
   ar << t.GetDuration();
 
+  unsigned int count = 0;
+
   const KeyFrameVector3* positionKeyFrames = NULL;
   GetSpecialization(GetImplementation(t.GetPositionKeyFrames()), positionKeyFrames);
-  unsigned int count = positionKeyFrames->GetNumberOfKeyFrames();
-  ar << count;
-  if( count )
+  if( positionKeyFrames )
   {
-    for( unsigned int i = 0; i < count; ++i)
+    count = positionKeyFrames->GetNumberOfKeyFrames();
+    ar << count;
+    if( count )
     {
-      float progress;
-      Vector3 position;
-      positionKeyFrames->GetKeyFrame(i, progress, position);
+      for( unsigned int i = 0; i < count; ++i)
+      {
+        float progress;
+        Vector3 position;
+        positionKeyFrames->GetKeyFrame(i, progress, position);
 
-      ar << progress << position;
+        ar << progress << position;
+      }
     }
   }
+  else
+  {
+    ar << 0;
+  }
 
   const KeyFrameVector3* scaleKeyFrames = NULL;
   GetSpecialization(GetImplementation(t.GetScaleKeyFrames()), scaleKeyFrames);
-  count = scaleKeyFrames->GetNumberOfKeyFrames();
-  ar << count;
-  if( count )
+  if( scaleKeyFrames )
   {
-    for( unsigned int i = 0; i < count; ++i)
+    count = scaleKeyFrames->GetNumberOfKeyFrames();
+    ar << count;
+    if( count )
     {
-      float progress;
-      Vector3 scale;
-      scaleKeyFrames->GetKeyFrame(i, progress, scale);
+      for( unsigned int i = 0; i < count; ++i)
+      {
+        float progress;
+        Vector3 scale;
+        scaleKeyFrames->GetKeyFrame(i, progress, scale);
 
-      ar << progress << scale;
+        ar << progress << scale;
+      }
     }
   }
+  else
+  {
+    ar << 0;
+  }
 
   const KeyFrameQuaternion* rotationKeyFrames = NULL;
   GetSpecialization(GetImplementation(t.GetRotationKeyFrames()), rotationKeyFrames);
-  count = rotationKeyFrames->GetNumberOfKeyFrames();
-  ar << count;
-  if( count )
+  if( rotationKeyFrames )
   {
-    for( unsigned int i = 0; i < count; ++i)
+    count = rotationKeyFrames->GetNumberOfKeyFrames();
+    ar << count;
+    if( count )
     {
-      float progress;
-      Quaternion rotation;
-      rotationKeyFrames->GetKeyFrame(i, progress, rotation);
+      for( unsigned int i = 0; i < count; ++i)
+      {
+        float progress;
+        Quaternion rotation;
+        rotationKeyFrames->GetKeyFrame(i, progress, rotation);
 
-      ar << progress << rotation;
+        ar << progress << rotation;
+      }
     }
   }
+  else
+  {
+    ar << 0;
+  }
 
   ar.CloseChunk(); // EANI
   return ar;
index eabda3141a18b35593a6b5e0f86c37195848cec5..f7011e9cc0abefdaa0496b38606bf2857386c9b3 100644 (file)
@@ -55,15 +55,21 @@ TextVertexBuffer* GlyphAtlasManager::TextRequired( const Integration::TextArray&
   GlyphAtlas* atlas  = FindAtlas( text, format, fontId, bestRank);
 
   DALI_ASSERT_DEBUG( atlas && "Find atlas should always return a valid atlas." );
+  if( atlas )
+  {
+    // if the atlas is full, create a new larger one
+    if( bestRank.GetSpaceStatus() == AtlasRanking::FULL_CAN_BE_RESIZED )
+    {
+      atlas = CreateLargerAtlas( atlas );
+    }
 
-  // if the atlas is full, create a new larger one
-  if( bestRank.GetSpaceStatus() == AtlasRanking::FULL_CAN_BE_RESIZED )
+    // assign the text to it
+    return atlas->AssignText( text, format, fontId, metrics );
+  }
+  else
   {
-    atlas = CreateLargerAtlas( atlas );
+    return NULL;
   }
-
-  // assign the text to it
-  return atlas->AssignText( text, format, fontId, metrics );
 }
 
 void GlyphAtlasManager::TextNotRequired( const Integration::TextArray& text,
index 4af96fd7a64893c8f806964d8fa9f18eef02cb28..14aed155ba337c93e564c8a6c8d4d545e9cc75e4 100644 (file)
@@ -35,6 +35,7 @@ const float POINT_TO_INCHES( 1.f / INCH_TO_POINTS );
 }
 
 FontLayout::FontLayout()
+  :mUnitsPerEM(0.0f)
 {
 }
 
index 5c98e299b8db90fb643c6259adaf76db40cd6162..ea8c65e452743b1d52441313d143c90b04d85048 100644 (file)
@@ -26,6 +26,12 @@ namespace Internal
 
 using Integration::TextResourceType;
 
+GlyphResourceRequest::GlyphResourceRequest()
+:mFontId( 0 ),
+ mQuality( LOW_QUALITY )
+{
+
+}
 
 GlyphResourceRequest::GlyphResourceRequest( FontId fontId, GlyphQuality quality )
 :mFontId( fontId ),
index a0d0c10e770acc6d03562e2fc8369bebc4ae78f9..3b01f7cc97d7ca370477406a3dcd0a53bbcbb7cb 100644 (file)
@@ -102,9 +102,7 @@ private:
   /**
    * constructor
    */
-  GlyphResourceRequest()
-  {
-  }
+  GlyphResourceRequest();
 
   FontId mFontId;                  ///< font id
   GlyphQuality mQuality;           ///< quality
index e0de39d1d3f5533e36f4960816d81fc5da484a5e..692a1022d27c938c644369acac735e8e2dbd1111 100644 (file)
@@ -99,11 +99,13 @@ TextVertexBuffer* TextRequestHelper::TextRequired( const TextFormat& format )
 
     // get the vertex buffer required to display the text
     TextVertexBuffer* buffer =  mFont->TextRequired( mText, format );
+    if( buffer )
+    {
+      // keep track of the texture id, ( texture id == atlas id)
+      mTextureId = buffer->mTextureId;
 
-    // keep track of the texture id, ( texture id == atlas id)
-    mTextureId = buffer->mTextureId;
-
-    return buffer;
+      return buffer;
+    }
   }
   else if( 0u == mText.Count()  )
   {
index 641441f2b03e2003c79cc5d1d3a89b2fb1622675..eb84e29da0fec260a05a7246f715e0e1a80440b5 100644 (file)
@@ -93,6 +93,8 @@ struct RenderManager::Impl
     resourcePostProcessQueue( resourcePostProcessQ ),
     instructions(),
     backgroundColor( Dali::Stage::DEFAULT_BACKGROUND_COLOR ),
+    frameTime( 0.0f ),
+    lastFrameTime( 0.0f ),
     frameCount( 0 ),
     renderBufferIndex( SceneGraphBuffers::INITIAL_UPDATE_BUFFER_INDEX ),
     defaultSurfaceRect(),
index f66426818192e8d63729cfb32b7e9d2679502afb..8aaa8654489145a1d42f47213ec1590e46ba822b 100644 (file)
@@ -105,7 +105,10 @@ Context::Context(Integration::GlAbstraction& glAbstraction)
   mClearColor(Color::WHITE),    // initial color, never used until it's been set by the user
   mCullFaceMode(CullNone),
   mViewPort( 0, 0, 0, 0 ),
-  mCurrentProgram( NULL )
+  mCurrentProgram( NULL ),
+  mFrameCount( 0 ),
+  mCulledCount( 0 ),
+  mRendererCount( 0 )
 {
 }
 
index ba1a6827f329def70838b3e8fbb807e479eb4d33..618c01e48eecc89b5bc21e4f0346a1fe6ca5cbae 100644 (file)
@@ -32,7 +32,8 @@ namespace SceneGraph
 {
 
 RenderTaskList::RenderTaskList(CompleteStatusManager& completeStatusManager)
-: mCompleteStatusManager( completeStatusManager )
+: mNotificationObject( NULL ),
+  mCompleteStatusManager( completeStatusManager )
 {
 }
 
index c56833a7207d23cbf165af08b4513256a69df9c0..65e4f8c5b0fb68a1d10ec44b6e2c07900e96da7e 100644 (file)
@@ -105,7 +105,8 @@ struct ResourceManager::ResourceManagerImpl
     mPostProcessResourceDispatcher(postProcessResourceDispatcher),
     mDiscardQueue(discardQueue),
     mRenderQueue(renderQueue),
-    mNotificationCount(0)
+    mNotificationCount(0),
+    cacheUpdated(false)
   {
   }
 
index 88109f2a78543f39935d8d52c9a954ec4e4241fd..b080a3387a80448fb9e9be75a8e35381c7f4815d 100644 (file)
@@ -71,23 +71,26 @@ std::string Demangle(const char* symbol)
 
       // Allocate space for symbol
       char *mangledSymbol = (char*)malloc(tokenLength+1u);
-      strncpy(mangledSymbol, startOfToken, tokenLength);
-      mangledSymbol[tokenLength] = '\0';
-
-      size_t size;
-      int    status;
-      char*  demangled=NULL;
-      demangled = abi::__cxa_demangle( mangledSymbol, NULL, &size, &status );
-      if( demangled != NULL )
+      if(mangledSymbol != NULL)
       {
-        result = demangled;
-        free(demangled); // demangle() allocates returned string, so free it
+        strncpy(mangledSymbol, startOfToken, tokenLength);
+        mangledSymbol[tokenLength] = '\0';
+
+        size_t size;
+        int    status;
+        char*  demangled=NULL;
+        demangled = abi::__cxa_demangle( mangledSymbol, NULL, &size, &status );
+        if( demangled != NULL )
+        {
+          result = demangled;
+          free(demangled); // demangle() allocates returned string, so free it
+        }
+        else
+        {
+          result = symbol;
+        }
+        free(mangledSymbol);
       }
-      else
-      {
-        result = symbol;
-      }
-      free(mangledSymbol);
     }
   }
 
index f88946e538cc81ea84b82921ad0488a824faea67..1919e7911cde9100346c43a416a1a1ccd42a8ba7 100644 (file)
@@ -35,6 +35,7 @@ KeyEvent::KeyEvent()
   keyPressed(""),
   keyCode(KEY_INVALID_CODE),
   keyModifier(0),
+  time(0),
   state(KeyEvent::Down)
 {
 }
index fc89a4a2ec6831f1e806b3d392bb19dff319071a..d9fc27cabd2835cb3525a42752cf9dfa0ab904b7 100644 (file)
@@ -96,7 +96,7 @@ void DistanceTransform( float *source, float* dest, unsigned int length )
     const float initialDistance( source[i] + SQUARE( i ) );
     int parabola = parabolas[rightmost];
     float newDistance( (initialDistance - (source[parabola] + SQUARE( parabola ))) / (2 * i - 2 * parabola) );
-    while( newDistance <= edge[rightmost] )
+    while( rightmost > 0 && newDistance <= edge[rightmost] )
     {
       rightmost--;
       parabola = parabolas[rightmost];
index 6965864f8c60f61c19d5603e66ad37f7dd4c1e33..ca9044d00fbaf368dbb0f39130c096ce21839c3b 100644 (file)
@@ -82,7 +82,8 @@ void CallbackBase::Reset()
 
 CallbackBase::Impl::Impl()
 : mObjectPointer( NULL ),
-  mMemberFunctionDispatcher( NULL )
+  mMemberFunctionDispatcher( NULL ),
+  mDestructorDispatcher( NULL )
 {
 }