Fix prevent issues 29/46829/4
authortaeyoon <taeyoon0.lee@samsung.com>
Tue, 25 Aug 2015 09:51:02 +0000 (18:51 +0900)
committertaeyoon <taeyoon0.lee@samsung.com>
Wed, 26 Aug 2015 13:30:19 +0000 (22:30 +0900)
 - Handling NULL by if()
 - Remove ( startOfSelectedText >= 0 )

Change-Id: I3364302388695648a341358de499d58a655fae24

dali-toolkit/internal/atlas-manager/atlas-manager-impl.cpp
dali-toolkit/internal/builder/builder-impl.cpp
dali-toolkit/internal/builder/builder-set-property.cpp
dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp
dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-page-path-effect-impl.cpp
dali-toolkit/internal/text/text-controller-impl.cpp

index 9a2289a..832e5d9 100644 (file)
@@ -132,11 +132,31 @@ Toolkit::AtlasManager::AtlasId AtlasManager::CreateAtlas( const Toolkit::AtlasMa
   atlasDescriptor.mHorizontalStrip = BufferImage::New( blockWidth, SINGLE_PIXEL_PADDING, pixelformat );
   atlasDescriptor.mVerticalStrip = BufferImage::New( SINGLE_PIXEL_PADDING, blockHeight - DOUBLE_PIXEL_PADDING, pixelformat );
 
   atlasDescriptor.mHorizontalStrip = BufferImage::New( blockWidth, SINGLE_PIXEL_PADDING, pixelformat );
   atlasDescriptor.mVerticalStrip = BufferImage::New( SINGLE_PIXEL_PADDING, blockHeight - DOUBLE_PIXEL_PADDING, pixelformat );
 
-  memset( atlasDescriptor.mHorizontalStrip.GetBuffer(), 0, atlasDescriptor.mHorizontalStrip.GetBufferSize() );
-  memset( atlasDescriptor.mVerticalStrip.GetBuffer(), 0, atlasDescriptor.mVerticalStrip.GetBufferSize() );
+  PixelBuffer* buffer = atlasDescriptor.mHorizontalStrip.GetBuffer();
+  if( buffer == NULL )
+  {
+    DALI_LOG_ERROR("atlasDescriptor.mHorizontalStrip.GetBuffer() returns NULL\n");
+    return 0;
+  }
+  memset( buffer, 0, atlasDescriptor.mHorizontalStrip.GetBufferSize() );
+
+  buffer = atlasDescriptor.mVerticalStrip.GetBuffer();
+  if( buffer == NULL )
+  {
+    DALI_LOG_ERROR("atlasDescriptor.mVerticalStrip.GetBuffer() returns NULL\n");
+    return 0;
+  }
+  memset( buffer, 0, atlasDescriptor.mVerticalStrip.GetBufferSize() );
 
   BufferImage filledPixelImage = BufferImage::New( 1u, 1u, pixelformat );
 
   BufferImage filledPixelImage = BufferImage::New( 1u, 1u, pixelformat );
-  memset( filledPixelImage.GetBuffer(), 0xFF, filledPixelImage.GetBufferSize() );
+  buffer = filledPixelImage.GetBuffer();
+  if( buffer == NULL)
+  {
+    DALI_LOG_ERROR("filledPixelImage.GetBuffer() returns NULL\n");
+    return 0;
+  }
+
+  memset( buffer, 0xFF, filledPixelImage.GetBufferSize() );
   atlas.Upload( filledPixelImage, 0, 0 );
 
   Sampler sampler = Sampler::New( atlas, "sTexture" );
   atlas.Upload( filledPixelImage, 0, 0 );
 
   Sampler sampler = Sampler::New( atlas, "sTexture" );
index 07ca895..4ea4aee 100644 (file)
@@ -717,9 +717,13 @@ FrameBufferImage Builder::GetFrameBufferImage( const std::string &name, const Re
         if( SetPropertyFromNode( *image, Property::MAP, property, constant ) )
         {
           Property::Map* map = property.GetMap();
         if( SetPropertyFromNode( *image, Property::MAP, property, constant ) )
         {
           Property::Map* map = property.GetMap();
-          (*map)[ KEYNAME_TYPE ] = Property::Value(std::string("FrameBufferImage") );
-          ret = FrameBufferImage::DownCast( Dali::Scripting::NewImage( property ) );
-          mFrameBufferImageLut[ name ] = ret;
+
+          if( map )
+          {
+            (*map)[ KEYNAME_TYPE ] = Property::Value(std::string("FrameBufferImage") );
+            ret = FrameBufferImage::DownCast( Dali::Scripting::NewImage( property ) );
+            mFrameBufferImageLut[ name ] = ret;
+          }
         }
       }
     }
         }
       }
     }
index 12f602c..c78e19c 100644 (file)
@@ -343,24 +343,29 @@ bool SetPropertyFromNode( const TreeNode& node, Property::Type type, Property::V
       {
         value = Property::Value(Property::ARRAY);
         Property::Array* array = value.GetArray();
       {
         value = Property::Value(Property::ARRAY);
         Property::Array* array = value.GetArray();
+
         unsigned int i = 0;
         TreeNode::ConstIterator iter(node.CBegin());
         unsigned int i = 0;
         TreeNode::ConstIterator iter(node.CBegin());
-        for( ; i < node.Size(); ++i, ++iter)
+
+        if( array )
         {
         {
-          Property::Value childValue;
-          if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
+          for( ; i < node.Size(); ++i, ++iter)
           {
           {
-            array->PushBack( childValue );
+            Property::Value childValue;
+            if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
+            {
+              array->PushBack( childValue );
+            }
           }
           }
-        }
 
 
-        if( array->Count() == node.Size() )
-        {
-          done = true;
-        }
-        else
-        {
-          done = false;
+          if( array->Count() == node.Size() )
+          {
+            done = true;
+          }
+          else
+          {
+            done = false;
+          }
         }
       }
       break;
         }
       }
       break;
@@ -375,24 +380,29 @@ bool SetPropertyFromNode( const TreeNode& node, Property::Type type, Property::V
       {
         value = Property::Value(Property::MAP);
         Property::Map* map = value.GetMap();
       {
         value = Property::Value(Property::MAP);
         Property::Map* map = value.GetMap();
+
         unsigned int i = 0;
         TreeNode::ConstIterator iter(node.CBegin());
         unsigned int i = 0;
         TreeNode::ConstIterator iter(node.CBegin());
-        for( ; i < node.Size(); ++i, ++iter)
+
+        if( map )
         {
         {
-          Property::Value childValue;
-          if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
+          for( ; i < node.Size(); ++i, ++iter)
           {
           {
-            map->Insert( (*iter).first, childValue );
+            Property::Value childValue;
+            if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
+            {
+              map->Insert( (*iter).first, childValue );
+            }
           }
           }
-        }
 
 
-        if( map->Count() == node.Size() )
-        {
-          done = true;
-        }
-        else
-        {
-          done = false;
+          if( map->Count() == node.Size() )
+          {
+            done = true;
+          }
+          else
+          {
+            done = false;
+          }
         }
       }
       break;
         }
       }
       break;
@@ -483,13 +493,16 @@ bool SetPropertyFromNode( const TreeNode& node, Property::Value& value,
           value = Property::Value(Property::ARRAY);
           Property::Array* array = value.GetArray();
 
           value = Property::Value(Property::ARRAY);
           Property::Array* array = value.GetArray();
 
-          for(TreeConstIter iter = node.CBegin(); iter != node.CEnd(); ++iter)
+          if( array )
           {
           {
-            Property::Value childValue;
-            if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
+            for(TreeConstIter iter = node.CBegin(); iter != node.CEnd(); ++iter)
             {
             {
-              array->PushBack( childValue );
-              done = true;
+              Property::Value childValue;
+              if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
+              {
+                array->PushBack( childValue );
+                done = true;
+              }
             }
           }
         }
             }
           }
         }
@@ -507,13 +520,17 @@ bool SetPropertyFromNode( const TreeNode& node, Property::Value& value,
         {
           value = Property::Value(Property::ARRAY);
           Property::Array* array = value.GetArray();
         {
           value = Property::Value(Property::ARRAY);
           Property::Array* array = value.GetArray();
-          for(unsigned int i = 0; i < node.Size(); ++i, ++iter)
+
+          if( array )
           {
           {
-            Property::Value childValue;
-            if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
+            for(unsigned int i = 0; i < node.Size(); ++i, ++iter)
             {
             {
-              array->PushBack( childValue );
-              done = true;
+              Property::Value childValue;
+              if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
+              {
+                array->PushBack( childValue );
+                done = true;
+              }
             }
           }
         }
             }
           }
         }
@@ -521,13 +538,17 @@ bool SetPropertyFromNode( const TreeNode& node, Property::Value& value,
         {
           value = Property::Value(Property::MAP);
           Property::Map* map = value.GetMap();
         {
           value = Property::Value(Property::MAP);
           Property::Map* map = value.GetMap();
-          for(unsigned int i = 0; i < node.Size(); ++i, ++iter)
+
+          if( map )
           {
           {
-            Property::Value childValue;
-            if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
+            for(unsigned int i = 0; i < node.Size(); ++i, ++iter)
             {
             {
-              map->Insert( (*iter).first, childValue );
-              done = true;
+              Property::Value childValue;
+              if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
+              {
+                map->Insert( (*iter).first, childValue );
+                done = true;
+              }
             }
           }
         }
             }
           }
         }
index 74450ae..d2b699b 100755 (executable)
@@ -664,11 +664,15 @@ Property::Value ScrollBar::GetProperty( BaseObject* object, Property::Index inde
       {
         Property::Value value( Property::ARRAY );
         Property::Array* array = value.GetArray();
       {
         Property::Value value( Property::ARRAY );
         Property::Array* array = value.GetArray();
-        Dali::Vector<float> positions = scrollBarImpl.GetScrollPositionIntervals();
-        size_t positionCount( array->Count() );
-        for( size_t i( 0 ); i != positionCount; ++i )
+
+        if( array )
         {
         {
-          array->PushBack( positions[i] );
+          Dali::Vector<float> positions = scrollBarImpl.GetScrollPositionIntervals();
+          size_t positionCount( array->Count() );
+          for( size_t i( 0 ); i != positionCount; ++i )
+          {
+            array->PushBack( positions[i] );
+          }
         }
         break;
       }
         }
         break;
       }
index f12b873..89268b3 100644 (file)
@@ -51,9 +51,13 @@ ScrollViewPagePathEffect::ScrollViewPagePathEffect(Path path, const Vector3& for
   //Create linear constrainer
   pointsProperty = Property::Value(Property::ARRAY);
   Property::Array* array = pointsProperty.GetArray();
   //Create linear constrainer
   pointsProperty = Property::Value(Property::ARRAY);
   Property::Array* array = pointsProperty.GetArray();
-  array->PushBack(0.0f);
-  array->PushBack(1.0f);
-  array->PushBack(0.0f);
+
+  if( array )
+  {
+    array->PushBack(0.0f);
+    array->PushBack(1.0f);
+    array->PushBack(0.0f);
+  }
   mLinearConstrainer = Dali::LinearConstrainer::New();
   mLinearConstrainer.SetProperty( LinearConstrainer::Property::VALUE, pointsProperty );
 }
   mLinearConstrainer = Dali::LinearConstrainer::New();
   mLinearConstrainer.SetProperty( LinearConstrainer::Property::VALUE, pointsProperty );
 }
index 5e64f87..0bbe637 100644 (file)
@@ -881,7 +881,7 @@ void Controller::Impl::RetrieveSelection( std::string& selectedText, bool delete
   uint32_t lengthOfSelectedText =  mEventData->mRightSelectionPosition - startOfSelectedText;
 
   // Validate the start and end selection points
   uint32_t lengthOfSelectedText =  mEventData->mRightSelectionPosition - startOfSelectedText;
 
   // Validate the start and end selection points
-  if( ( startOfSelectedText >= 0 ) && (  ( startOfSelectedText + lengthOfSelectedText ) <=  mLogicalModel->mText.Count() ) )
+  if(  ( startOfSelectedText + lengthOfSelectedText ) <=  mLogicalModel->mText.Count() )
   {
     //Get text as a UTF8 string
     Vector<Character>& utf32Characters = mLogicalModel->mText;
   {
     //Get text as a UTF8 string
     Vector<Character>& utf32Characters = mLogicalModel->mText;