Fix the build error and runtime coredump in Windows backend
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / layouting / flex-layout-impl.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 1df4f5f..0090ec8
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -218,23 +218,23 @@ void FlexLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeas
 
   if( widthMeasureSpec.GetMode() == MeasureSpec::Mode::EXACTLY )
   {
-    width = widthMeasureSpec.GetSize().AsFloat();
+    width = widthMeasureSpec.GetSize().AsDecimal();
     YGNodeStyleSetWidth( mRoot, width );
   }
   else if( widthMeasureSpec.GetMode() == MeasureSpec::Mode::AT_MOST )
   {
-    width = widthMeasureSpec.GetSize().AsFloat();
+    width = widthMeasureSpec.GetSize().AsDecimal();
     YGNodeStyleSetMaxWidth( mRoot, width );
   }
 
   if ( heightMeasureSpec.GetMode() == MeasureSpec::Mode::EXACTLY )
   {
-    height = heightMeasureSpec.GetSize().AsFloat();
+    height = heightMeasureSpec.GetSize().AsDecimal();
     YGNodeStyleSetHeight( mRoot, height );
   }
   else if ( heightMeasureSpec.GetMode() == MeasureSpec::Mode::AT_MOST )
   {
-    height = heightMeasureSpec.GetSize().AsFloat();
+    height = heightMeasureSpec.GetSize().AsDecimal();
     YGNodeStyleSetMaxHeight( mRoot, height );
   }
 
@@ -263,7 +263,7 @@ void FlexLayout::OnLayout( bool changed, LayoutLength left, LayoutLength top, La
   DALI_LOG_INFO( gLogFilter, Debug::Concise, oss.str().c_str() );
 #endif
 
-  YGNodeCalculateLayout( mRoot, width.AsFloat(), height.AsFloat(), isLayoutRtl ? YGDirectionRTL : YGDirectionLTR );
+  YGNodeCalculateLayout( mRoot, width.AsDecimal(), height.AsDecimal(), isLayoutRtl ? YGDirectionRTL : YGDirectionLTR );
 
   auto count = GetChildCount();
   for( unsigned int childIndex = 0; childIndex < count; childIndex++)
@@ -272,7 +272,7 @@ void FlexLayout::OnLayout( bool changed, LayoutLength left, LayoutLength top, La
     if( childLayout != nullptr )
     {
       YGNodeRef node = YGNodeGetChild(mRoot, childIndex);
-      LayoutLength childLeft = LayoutLength( YGNodeLayoutGetLeft( node ) ) + left;
+      LayoutLength childLeft = LayoutLength( YGNodeLayoutGetLeft( node ) )+ left;
       LayoutLength childTop = LayoutLength( YGNodeLayoutGetTop( node ) ) + top;
       LayoutLength childWidth = LayoutLength( YGNodeLayoutGetWidth( node ) );
       LayoutLength childHeight = LayoutLength( YGNodeLayoutGetHeight( node ) );
@@ -290,7 +290,7 @@ YGSize FlexLayout::OnChildMeasure( YGNodeRef node,
   auto childOwner = childLayout->GetOwner();
   auto desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
   auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
-  auto parentWidthMeasureSpec = MeasureSpec( 0 );
+  MeasureSpec parentWidthMeasureSpec( 0 );
   if ( innerWidth != YGUndefined )
   {
     parentWidthMeasureSpec = MeasureSpec( innerWidth, static_cast<MeasureSpec::Mode>(widthMode) );
@@ -335,10 +335,11 @@ YGSize FlexLayout::OnChildMeasure( YGNodeRef node,
   LayoutLength measuredWidth = childLayout->GetMeasuredWidth() - padding.end - padding.start;
   LayoutLength measuredHeight = childLayout->GetMeasuredHeight() - padding.bottom - padding.top;
 
-  return YGSize{
-    .width = measuredWidth.AsFloat(),
-    .height = measuredHeight.AsFloat(),
-  };
+  // Create struct instance first and manually set params to support all compiler versions
+  YGSize ygSize;
+  ygSize.width = measuredWidth.AsDecimal();
+  ygSize.height = measuredHeight.AsDecimal();
+  return ygSize;
 }
 
 void FlexLayout::SetChildrenStyle()