(demo) fix klocwork issues 47/30347/3
authorXiangyin Ma <x1.ma@samsung.com>
Fri, 14 Nov 2014 18:05:41 +0000 (18:05 +0000)
committerXiangyin Ma <x1.ma@samsung.com>
Mon, 17 Nov 2014 11:33:04 +0000 (11:33 +0000)
Change-Id: I9db6f14c19c657aee1e149187ed9f14dbf8a28b6

demo/dali-table-view.cpp
examples/builder/dali-builder.cpp
examples/cluster/cluster-example.cpp
examples/image/image-scaling-irregular-grid/grid-flags.h
examples/image/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp
examples/radial-menu/radial-sweep-view-impl.cpp

index fae3df1..4f7176b 100644 (file)
@@ -874,8 +874,12 @@ void DaliTableView::CreateShapeImage( ShapeType shapeType, const Size& size, Bit
       break;
   }
 
-  GenerateDistanceFieldMap( &imageDataA8[ 0 ], size, distanceFieldOut.GetBuffer(), size, 8.0f, size );
-  distanceFieldOut.Update();
+  PixelBuffer* buffer = distanceFieldOut.GetBuffer();
+  if( buffer )
+  {
+    GenerateDistanceFieldMap( &imageDataA8[ 0 ], size, buffer, size, 8.0f, size );
+    distanceFieldOut.Update();
+  }
 }
 
 void DaliTableView::GenerateSquare( const Size& size, std::vector< unsigned char >& distanceFieldOut )
index 2fad6f1..9c97fec 100644 (file)
@@ -87,7 +87,7 @@ class FileWatcher
 public:
   FileWatcher(void);
   ~FileWatcher(void);
-  explicit FileWatcher(const std::string &fn) { SetFilename(fn) ; };
+  explicit FileWatcher(const std::string &fn): mLastTime(0) { SetFilename(fn) ; };
 
   void SetFilename(const std::string &fn);
   std::string GetFilename();
index f582038..6af3c8d 100644 (file)
@@ -407,6 +407,22 @@ struct ClusterInfo
 
   }
 
+  /**
+   * Assignment operator
+   */
+  ClusterInfo& operator=( const ClusterInfo& rhs )
+  {
+    if( this != &rhs )
+    {
+      mCluster = rhs.mCluster;
+      mIndex = rhs.mIndex;
+      mPosition = rhs.mPosition;
+      mSize = rhs.mSize;
+    }
+    return *this;
+  }
+
+
   Cluster mCluster;                   ///< Cluster instance
   int mIndex;                         ///< Cluster index
   Vector3 mPosition;                  ///< Cluster original position
index 4802817..68453b2 100644 (file)
  * limitations under the License.
  *
  */
+#include <algorithm>
 #include <dali/dali.h>
 
+/** Controls the output of application logging. */
+//#define DEBUG_PRINT_GRID_DIAGNOSTICS
+
 namespace Dali
 {
 namespace Demo
 {
-namespace
-{
-const bool DEBUG_PRINT_GRID_DIAGNOSTICS = false;
-
-inline unsigned min( unsigned a, unsigned b )
-{
-  return a < b ? a : b;
-}
-
-inline unsigned max( unsigned a, unsigned b )
-{
-  return a > b ? a : b;
-}
-
-}
-
 /**
  * @brief A 2D grid of booleans, settable and gettable via integer (x,y) coordinates.
  * */
@@ -49,17 +37,16 @@ public:
    */
   GridFlags( unsigned width, unsigned height ) :  mCells( width * height ), mWidth( width ), mHeight( height ), mHighestUsedRow( 0 )
   {
-    if( DEBUG_PRINT_GRID_DIAGNOSTICS )
-    {
+#ifdef DEBUG_PRINT_GRID_DIAGNOSTICS
       fprintf(stderr, "Grid created with dimensions: (%u, %u).\n", mWidth, mHeight );
-    }
+#endif
   }
 
   void Set( const unsigned x, const unsigned y )
   {
     const unsigned index = CellIndex( x, y );
     mCells[index] += 1u; ///< += To allow a debug check of the number of times a cell is set.
-    mHighestUsedRow = max( mHighestUsedRow, y );
+    mHighestUsedRow = std::max( mHighestUsedRow, y );
   }
 
   bool Get( unsigned x, unsigned y ) const
@@ -86,10 +73,9 @@ public:
   {
     const unsigned regionWidth = (region.x + 0.5f);
     const unsigned regionHeight = (region.y + 0.5f);
-    if( DEBUG_PRINT_GRID_DIAGNOSTICS )
-    {
+#ifdef DEBUG_PRINT_GRID_DIAGNOSTICS
       fprintf( stderr, "Allocation requested for region (%u, %u). Result: ", regionWidth, regionHeight );
-    }
+#endif
     unsigned bestRegionWidth = 0;
     unsigned bestRegionHeight = 0;
     unsigned bestCellX = 0;
@@ -104,8 +90,8 @@ public:
         {
           // Look for clear grid cells under the desired region:
 
-          const unsigned clampedRegionHeight = min( regionHeight, mHeight - y);
-          const unsigned clampedRegionWidth = min( regionWidth, mWidth - x);
+          const unsigned clampedRegionHeight = std::min( regionHeight, mHeight - y);
+          const unsigned clampedRegionWidth = std::min( regionWidth, mWidth - x);
           const unsigned regionLimitY = y + clampedRegionHeight;
           const unsigned regionLimitX = x + clampedRegionWidth;
 
@@ -156,18 +142,16 @@ whole_region_not_found:
 
     if( bestRegionWidth == 0 || bestRegionHeight == 0 )
     {
-      if( DEBUG_PRINT_GRID_DIAGNOSTICS )
-      {
+#ifdef DEBUG_PRINT_GRID_DIAGNOSTICS
         fputs( "false.\n", stderr );
-      }
+#endif
       return false;
     }
 
     // Allocate the found region:
-    if( DEBUG_PRINT_GRID_DIAGNOSTICS )
-    {
+#ifdef DEBUG_PRINT_GRID_DIAGNOSTICS
       fprintf( stderr, " - bestCellX = %u, bestCellY = %u, bestRegionWidth = %u, bestRegionHeight = %u - ", bestCellX, bestCellY, bestRegionWidth, bestRegionHeight );
-    }
+#endif
     for( unsigned y = bestCellY; y < bestCellY + bestRegionHeight; ++y )
     {
       for( unsigned x = bestCellX; x < bestCellX + bestRegionWidth; ++x )
@@ -179,10 +163,9 @@ whole_region_not_found:
     outCellX = bestCellX;
     outCellY = bestCellY;
     outRegion = Vector2( bestRegionWidth, bestRegionHeight );
-    if( DEBUG_PRINT_GRID_DIAGNOSTICS )
-    {
+#ifdef DEBUG_PRINT_GRID_DIAGNOSTICS
       fputs( "true.\n", stderr );
-    }
+#endif
     return true;
   }
 
index 7cf2cb3..1cb8aa6 100644 (file)
@@ -58,7 +58,7 @@ namespace
 {
 
 /** Controls the output of application logging. */
-const bool DEBUG_PRINT_DIAGNOSTICS = false;
+//#define DEBUG_PRINT_DIAGNOSTICS;
 
 const char* BACKGROUND_IMAGE( DALI_IMAGE_DIR "background-4.jpg" );
 const char* TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" );
@@ -175,10 +175,9 @@ const unsigned NUM_IMAGE_PATHS = sizeof(IMAGE_PATHS) / sizeof(IMAGE_PATHS[0]) -
  */
 Image CreateImage(const std::string& filename, unsigned int width, unsigned int height, ImageAttributes::ScalingMode scalingMode )
 {
-  if( DEBUG_PRINT_DIAGNOSTICS )
-  {
+#ifdef DEBUG_PRINT_DIAGNOSTICS
     fprintf( stderr, "CreateImage(%s, %u, %u, scalingMode=%u)\n", filename.c_str(), width, height, unsigned( scalingMode ) );
-  }
+#endif
   ImageAttributes attributes;
 
   attributes.SetSize( width, height );
@@ -402,10 +401,9 @@ public:
       bool allocated = grid.AllocateRegion( config->dimensions, cellX, cellY, imageGridDims );
       if( !allocated )
       {
-        if( DEBUG_PRINT_DIAGNOSTICS )
-        {
+#ifdef DEBUG_PRINT_DIAGNOSTICS
           fprintf( stderr, "Failed to allocate image in grid with dims (%f, %f) and path: %s.\n", config->dimensions.x, config->dimensions.y, config->path );
-        }
+#endif
         continue;
       }
 
index af94125..ac01fce 100644 (file)
@@ -141,6 +141,8 @@ RadialSweepViewImpl::RadialSweepViewImpl( float duration, float diameter, Degree
   mInitialActorAngle(0),
   mFinalActorAngle(0),
   mEasingFunction(HoldZeroFastEaseInOutHoldOne),
+  mStartAngleIndex(Property::INVALID_INDEX),
+  mRotationAngleIndex(Property::INVALID_INDEX),
   mRotateActorsWithStencil(false),
   mRotateActors(false)
 {