From ec44c15833a21e23261a5ae9b37282a6fa9c22cc Mon Sep 17 00:00:00 2001 From: Kingsley Stephens Date: Tue, 4 Nov 2014 11:34:38 +0000 Subject: [PATCH] Klockwork fixes: Distance field iteration Checking for null pointers Initialising member variables Change-Id: I9a33b28759ceea74ba90507472de54affdcb0632 --- dali/integration-api/glyph-set.cpp | 3 +- .../actor-attachments/light-attachment-impl.cpp | 3 +- .../actor-attachments/mesh-attachment-impl.cpp | 1 + .../actor-attachments/text-attachment-impl.cpp | 32 +++++----- dali/internal/event/events/actor-observer.cpp | 16 ++--- dali/internal/event/modeling/model-archive.cpp | 71 ++++++++++++++-------- .../event/text/atlas/glyph-atlas-manager.cpp | 18 ++++-- dali/internal/event/text/font-layout.cpp | 1 + .../event/text/resource/glyph-resource-request.cpp | 6 ++ .../event/text/resource/glyph-resource-request.h | 4 +- dali/internal/event/text/text-request-helper.cpp | 10 +-- dali/internal/render/common/render-manager.cpp | 2 + dali/internal/render/gl-resources/context.cpp | 5 +- .../render-tasks/scene-graph-render-task-list.cpp | 3 +- .../internal/update/resources/resource-manager.cpp | 3 +- dali/public-api/common/dali-common.cpp | 33 +++++----- dali/public-api/events/key-event.cpp | 1 + dali/public-api/images/distance-field.cpp | 2 +- dali/public-api/signals/callback.cpp | 3 +- 19 files changed, 136 insertions(+), 81 deletions(-) diff --git a/dali/integration-api/glyph-set.cpp b/dali/integration-api/glyph-set.cpp index 9c9b4cd..33d3e47 100644 --- a/dali/integration-api/glyph-set.cpp +++ b/dali/integration-api/glyph-set.cpp @@ -31,7 +31,8 @@ GlyphSet::GlyphSet() mUnitsPerEM(0.0f), mUnderlinePosition(0.0f), mUnderlineThickness(0.0f), - mPadAdjust(0.0f) + mPadAdjust(0.0f), + mAtlasId( 0 ) { } diff --git a/dali/internal/event/actor-attachments/light-attachment-impl.cpp b/dali/internal/event/actor-attachments/light-attachment-impl.cpp index 5b44c03..6f6f87b 100644 --- a/dali/internal/event/actor-attachments/light-attachment-impl.cpp +++ b/dali/internal/event/actor-attachments/light-attachment-impl.cpp @@ -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" ); } diff --git a/dali/internal/event/actor-attachments/mesh-attachment-impl.cpp b/dali/internal/event/actor-attachments/mesh-attachment-impl.cpp index f2a81d6..90ac633 100644 --- a/dali/internal/event/actor-attachments/mesh-attachment-impl.cpp +++ b/dali/internal/event/actor-attachments/mesh-attachment-impl.cpp @@ -54,6 +54,7 @@ MeshAttachmentPtr MeshAttachment::New( const SceneGraph::Node& parentNode ) MeshAttachment::MeshAttachment( Stage& stage ) : RenderableAttachment( stage ), + mSceneObject( NULL ), mAffectedByLighting( true ) { } diff --git a/dali/internal/event/actor-attachments/text-attachment-impl.cpp b/dali/internal/event/actor-attachments/text-attachment-impl.cpp index 454bfee..97ee7ad 100644 --- a/dali/internal/event/actor-attachments/text-attachment-impl.cpp +++ b/dali/internal/event/actor-attachments/text-attachment-impl.cpp @@ -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() ); + } } } } diff --git a/dali/internal/event/events/actor-observer.cpp b/dali/internal/event/events/actor-observer.cpp index 51c33a0..ff1ce2d 100644 --- a/dali/internal/event/events/actor-observer.cpp +++ b/dali/internal/event/events/actor-observer.cpp @@ -16,9 +16,9 @@ */ // CLASS HEADER +#include #include #include -#include 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 ); diff --git a/dali/internal/event/modeling/model-archive.cpp b/dali/internal/event/modeling/model-archive.cpp index 86a3f80..e630764 100644 --- a/dali/internal/event/modeling/model-archive.cpp +++ b/dali/internal/event/modeling/model-archive.cpp @@ -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; diff --git a/dali/internal/event/text/atlas/glyph-atlas-manager.cpp b/dali/internal/event/text/atlas/glyph-atlas-manager.cpp index eabda31..f7011e9 100644 --- a/dali/internal/event/text/atlas/glyph-atlas-manager.cpp +++ b/dali/internal/event/text/atlas/glyph-atlas-manager.cpp @@ -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, diff --git a/dali/internal/event/text/font-layout.cpp b/dali/internal/event/text/font-layout.cpp index 4af96fd..14aed15 100644 --- a/dali/internal/event/text/font-layout.cpp +++ b/dali/internal/event/text/font-layout.cpp @@ -35,6 +35,7 @@ const float POINT_TO_INCHES( 1.f / INCH_TO_POINTS ); } FontLayout::FontLayout() + :mUnitsPerEM(0.0f) { } diff --git a/dali/internal/event/text/resource/glyph-resource-request.cpp b/dali/internal/event/text/resource/glyph-resource-request.cpp index 5c98e29..ea8c65e 100644 --- a/dali/internal/event/text/resource/glyph-resource-request.cpp +++ b/dali/internal/event/text/resource/glyph-resource-request.cpp @@ -26,6 +26,12 @@ namespace Internal using Integration::TextResourceType; +GlyphResourceRequest::GlyphResourceRequest() +:mFontId( 0 ), + mQuality( LOW_QUALITY ) +{ + +} GlyphResourceRequest::GlyphResourceRequest( FontId fontId, GlyphQuality quality ) :mFontId( fontId ), diff --git a/dali/internal/event/text/resource/glyph-resource-request.h b/dali/internal/event/text/resource/glyph-resource-request.h index a0d0c10..3b01f7c 100644 --- a/dali/internal/event/text/resource/glyph-resource-request.h +++ b/dali/internal/event/text/resource/glyph-resource-request.h @@ -102,9 +102,7 @@ private: /** * constructor */ - GlyphResourceRequest() - { - } + GlyphResourceRequest(); FontId mFontId; ///< font id GlyphQuality mQuality; ///< quality diff --git a/dali/internal/event/text/text-request-helper.cpp b/dali/internal/event/text/text-request-helper.cpp index e0de39d..692a102 100644 --- a/dali/internal/event/text/text-request-helper.cpp +++ b/dali/internal/event/text/text-request-helper.cpp @@ -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() ) { diff --git a/dali/internal/render/common/render-manager.cpp b/dali/internal/render/common/render-manager.cpp index 641441f..eb84e29 100644 --- a/dali/internal/render/common/render-manager.cpp +++ b/dali/internal/render/common/render-manager.cpp @@ -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(), diff --git a/dali/internal/render/gl-resources/context.cpp b/dali/internal/render/gl-resources/context.cpp index f664268..8aaa865 100644 --- a/dali/internal/render/gl-resources/context.cpp +++ b/dali/internal/render/gl-resources/context.cpp @@ -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 ) { } diff --git a/dali/internal/update/render-tasks/scene-graph-render-task-list.cpp b/dali/internal/update/render-tasks/scene-graph-render-task-list.cpp index ba1a682..618c01e 100644 --- a/dali/internal/update/render-tasks/scene-graph-render-task-list.cpp +++ b/dali/internal/update/render-tasks/scene-graph-render-task-list.cpp @@ -32,7 +32,8 @@ namespace SceneGraph { RenderTaskList::RenderTaskList(CompleteStatusManager& completeStatusManager) -: mCompleteStatusManager( completeStatusManager ) +: mNotificationObject( NULL ), + mCompleteStatusManager( completeStatusManager ) { } diff --git a/dali/internal/update/resources/resource-manager.cpp b/dali/internal/update/resources/resource-manager.cpp index c56833a..65e4f8c 100644 --- a/dali/internal/update/resources/resource-manager.cpp +++ b/dali/internal/update/resources/resource-manager.cpp @@ -105,7 +105,8 @@ struct ResourceManager::ResourceManagerImpl mPostProcessResourceDispatcher(postProcessResourceDispatcher), mDiscardQueue(discardQueue), mRenderQueue(renderQueue), - mNotificationCount(0) + mNotificationCount(0), + cacheUpdated(false) { } diff --git a/dali/public-api/common/dali-common.cpp b/dali/public-api/common/dali-common.cpp index 88109f2..b080a33 100644 --- a/dali/public-api/common/dali-common.cpp +++ b/dali/public-api/common/dali-common.cpp @@ -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); } } diff --git a/dali/public-api/events/key-event.cpp b/dali/public-api/events/key-event.cpp index f88946e..1919e79 100644 --- a/dali/public-api/events/key-event.cpp +++ b/dali/public-api/events/key-event.cpp @@ -35,6 +35,7 @@ KeyEvent::KeyEvent() keyPressed(""), keyCode(KEY_INVALID_CODE), keyModifier(0), + time(0), state(KeyEvent::Down) { } diff --git a/dali/public-api/images/distance-field.cpp b/dali/public-api/images/distance-field.cpp index fc89a4a..d9fc27c 100644 --- a/dali/public-api/images/distance-field.cpp +++ b/dali/public-api/images/distance-field.cpp @@ -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]; diff --git a/dali/public-api/signals/callback.cpp b/dali/public-api/signals/callback.cpp index 6965864..ca9044d 100644 --- a/dali/public-api/signals/callback.cpp +++ b/dali/public-api/signals/callback.cpp @@ -82,7 +82,8 @@ void CallbackBase::Reset() CallbackBase::Impl::Impl() : mObjectPointer( NULL ), - mMemberFunctionDispatcher( NULL ) + mMemberFunctionDispatcher( NULL ), + mDestructorDispatcher( NULL ) { } -- 2.7.4