Coding idiom (std::nothrow) fix
authorAyush <ayush.sriv@samsung.com>
Thu, 12 Sep 2013 13:39:58 +0000 (19:09 +0530)
committerAyush <ayush.sriv@samsung.com>
Fri, 13 Sep 2013 09:44:54 +0000 (15:14 +0530)
Change-Id: I37e0c3bf17777ab49ec914750919c09092f7caec
Signed-off-by: Ayush <ayush.sriv@samsung.com>
src/ui/controls/FUiCtrlPanel.cpp
src/ui/controls/FUiCtrlPopup.cpp
src/ui/controls/FUiCtrlScrollPanel.cpp
src/ui/controls/FUiCtrl_EditDate.cpp
src/ui/controls/FUiCtrl_EditTime.cpp
src/ui/controls/FUiCtrl_ExpandableListImpl.cpp
src/ui/controls/FUiCtrl_InputPad.cpp
src/ui/controls/FUiCtrl_Progress.cpp

index e22c2c9..b40890f 100644 (file)
@@ -101,7 +101,7 @@ Panel::Construct(const String& resourceId)
        ClearLastResult();
 
        // Parse UiBuilder XML file
-       unique_ptr<_UiBuilder> pBuilder(new _UiBuilder());
+       unique_ptr<_UiBuilder> pBuilder(new (std::nothrow) _UiBuilder());
        SysTryReturnResult(NID_UI_CTRL, pBuilder, E_OUT_OF_MEMORY, "Memory allocation failed.");
        result r = pBuilder->Construct(resourceId, this);
        SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
index 2ebe64f..824169e 100644 (file)
@@ -105,7 +105,7 @@ Popup::Construct(const Tizen::Base::String& resourceId)
        ClearLastResult();
 
        // Parse UiBuilder XML file
-       unique_ptr<_UiBuilder> pBuilder(new _UiBuilder());
+       unique_ptr<_UiBuilder> pBuilder(new (std::nothrow) _UiBuilder());
        SysTryReturn(NID_UI_CTRL, pBuilder, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
        result r = pBuilder->Construct(resourceId, this);
        SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
index 30e5328..9110790 100644 (file)
@@ -69,7 +69,7 @@ ScrollPanel::Construct(const String& resourceId)
        ClearLastResult();
 
        // Parse UiBuilder XML file
-       unique_ptr<_UiBuilder> pBuilder(new _UiBuilder());
+       unique_ptr<_UiBuilder> pBuilder(new (std::nothrow) _UiBuilder());
        SysTryReturnResult(NID_UI_CTRL, pBuilder != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
 
        result r = pBuilder->Construct(resourceId, this);
index eb20d30..53002b7 100644 (file)
@@ -691,9 +691,15 @@ _EditDate::CreateAccessibilityElement(void)
        FloatRectangle monthBounds = __pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_MONTH);
        FloatRectangle yearBounds = __pEditDatePresenter->GetDateAreaBounds(DATETIME_ID_YEAR);
 
+       _DateTimeUtils dateTimeUtils;
+       int localeDateFormat =  dateTimeUtils.GetLocaleDateFormat();
+
        if (__pAccessibilityEditDateElement == null)
        {
-               __pAccessibilityEditDateElement = new _AccessibilityElement(true);
+               __pAccessibilityEditDateElement = new (std::nothrow) _AccessibilityElement(true);
+               SysTryReturnVoidResult(NID_UI_CTRL, __pAccessibilityEditDateElement != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
                __pAccessibilityEditDateElement->SetBounds(GetClientBoundsF());
                __pAccessibilityEditDateElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
                __pAccessibilityEditDateElement->SetName("EditDateText");
@@ -702,24 +708,30 @@ _EditDate::CreateAccessibilityElement(void)
 
        if (__pAccessibilityYearElement == null && __pAccessibilityMonthElement == null && __pAccessibilityDayElement == null)
        {
-               __pAccessibilityYearElement = new _AccessibilityElement(true);
+               __pAccessibilityYearElement = new (std::nothrow) _AccessibilityElement(true);
+               SysTryReturnVoidResult(NID_UI_CTRL, __pAccessibilityYearElement != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
                __pAccessibilityYearElement->SetBounds(yearBounds);
                __pAccessibilityYearElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_YEAR_LC");
                __pAccessibilityYearElement->SetHintWithStringId("IDS_TPLATFORM_BODY_DOUBLE_TAP_TO_EDIT_T_TTS");
 
-               __pAccessibilityMonthElement = new _AccessibilityElement(true);
+               __pAccessibilityMonthElement = new (std::nothrow) _AccessibilityElement(true);
+               SysTryCatch(NID_UI_CTRL, __pAccessibilityMonthElement != null, , E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
                __pAccessibilityMonthElement->SetBounds(monthBounds);
                __pAccessibilityMonthElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_MONTH_LC");
                __pAccessibilityMonthElement->SetHintWithStringId("IDS_TPLATFORM_BODY_DOUBLE_TAP_TO_EDIT_T_TTS");
 
-               __pAccessibilityDayElement = new _AccessibilityElement(true);
+               __pAccessibilityDayElement = new (std::nothrow) _AccessibilityElement(true);
+               SysTryCatch(NID_UI_CTRL, __pAccessibilityDayElement != null, , E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
                __pAccessibilityDayElement->SetBounds(dayBounds);
                __pAccessibilityDayElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_DAY_LC");
                __pAccessibilityDayElement->SetHintWithStringId("IDS_TPLATFORM_BODY_DOUBLE_TAP_TO_EDIT_T_TTS");
 
-               _DateTimeUtils dateTimeUtils;
-               int localeDateFormat =  dateTimeUtils.GetLocaleDateFormat();
-
                switch (localeDateFormat)
                {
                case DATE_FORMAT_DDMMYYYY:
@@ -747,6 +759,17 @@ _EditDate::CreateAccessibilityElement(void)
                }
                UpdateAccessibilityElement();
        }
+
+       return;
+
+CATCH:
+       delete __pAccessibilityYearElement;
+       __pAccessibilityYearElement = null;
+
+       delete __pAccessibilityMonthElement;
+       __pAccessibilityMonthElement = null;
+
+       return;
 }
 
 void
index d612cdb..30ae6d5 100644 (file)
@@ -515,7 +515,10 @@ _EditTime::CreateAccessibilityElement(void)
        pContainer->AddListener(*this);
        if (__pAccessibilityEditTimeElement == null)
        {
-               __pAccessibilityEditTimeElement = new _AccessibilityElement(true);
+               __pAccessibilityEditTimeElement = new (std::nothrow) _AccessibilityElement(true);
+               SysTryReturnVoidResult(NID_UI_CTRL, __pAccessibilityEditTimeElement != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
                __pAccessibilityEditTimeElement->SetBounds(GetClientBoundsF());
                __pAccessibilityEditTimeElement->SetTrait(ACCESSIBILITY_TRAITS_NONE);
                __pAccessibilityEditTimeElement->SetName(L"EditTimeText");
@@ -524,13 +527,19 @@ _EditTime::CreateAccessibilityElement(void)
 
        if (__pAccessibilityHourElement == null && __pAccessibilityMinuteElement == null)
        {
-               __pAccessibilityHourElement = new _AccessibilityElement(true);
+               __pAccessibilityHourElement = new (std::nothrow) _AccessibilityElement(true);
+               SysTryReturnVoidResult(NID_UI_CTRL, __pAccessibilityHourElement != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
                __pAccessibilityHourElement->SetBounds(hourBounds);
                __pAccessibilityHourElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_HOUR_LC");
                __pAccessibilityHourElement->SetHintWithStringId("IDS_TPLATFORM_BODY_DOUBLE_TAP_TO_EDIT_T_TTS");
                pContainer->AddElement(*__pAccessibilityHourElement);
 
-               __pAccessibilityMinuteElement = new _AccessibilityElement(true);
+               __pAccessibilityMinuteElement = new (std::nothrow) _AccessibilityElement(true);
+               SysTryReturnVoidResult(NID_UI_CTRL, __pAccessibilityMinuteElement != null, E_OUT_OF_MEMORY,
+                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
                __pAccessibilityMinuteElement->SetBounds(minuteBounds);
                __pAccessibilityMinuteElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_MINUTE_LC");
                __pAccessibilityMinuteElement->SetHintWithStringId("IDS_TPLATFORM_BODY_DOUBLE_TAP_TO_EDIT_T_TTS");
@@ -538,7 +547,10 @@ _EditTime::CreateAccessibilityElement(void)
 
                if (!Is24HourNotationEnabled())
                {
-                       __pAccessibilityAmPmElement = new _AccessibilityElement(true);
+                       __pAccessibilityAmPmElement = new (std::nothrow) _AccessibilityElement(true);
+                       SysTryReturnVoidResult(NID_UI_CTRL, __pAccessibilityAmPmElement != null, E_OUT_OF_MEMORY,
+                                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
                        __pAccessibilityAmPmElement->SetBounds(ampmBounds);
                        __pAccessibilityAmPmElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_BUTTON_T_TTS");
                        pContainer->AddElement(*__pAccessibilityAmPmElement);
index bc87959..7a4be50 100644 (file)
@@ -712,7 +712,7 @@ _ExpandableListImpl::InsertItemAt(int mainIndex, const CustomListItem& item, int
 
        item.__pCustomListItemImpl->itemId = itemId;
 
-       Boolean* pIsExpanded = new Boolean(false);
+       Boolean* pIsExpanded = new (std::nothrow) Boolean(false);
        SysTryReturn(NID_UI_CTRL, pIsExpanded, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
 
        __groupExpandStateList.InsertAt(*pIsExpanded, mainIndex);
@@ -1032,7 +1032,7 @@ _ExpandableListImpl::SetItemExpanded(int mainIndex, bool expand)
 {
        SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
 
-       Boolean* pIsExpanded = new Boolean(expand);
+       Boolean* pIsExpanded = new (std::nothrow) Boolean(expand);
        SysTryReturn(NID_UI_CTRL, pIsExpanded, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
 
        __groupExpandStateList.SetAt(*pIsExpanded, mainIndex, true);
index 879d7a7..9f8c396 100644 (file)
@@ -218,7 +218,7 @@ _InputPad::SetAllAccessibilityElement(void)
                        int returnValue = __pInputPadPresenter->GetReturnValue(index);
                        if (returnValue >= 0)
                        {
-                               _AccessibilityElement* pElement = new _AccessibilityElement(true);
+                               _AccessibilityElement* pElement = new (std::nothrow) _AccessibilityElement(true);
                                if (pElement != null)
                                {
                                        if (__pInputPadPresenter->GetInputPadStyle() == INPUTPAD_STYLE_ALPHA)
index 510c083..ba17a44 100644 (file)
@@ -114,7 +114,7 @@ _Progress::InitializeAccessibilityElement(void)
        _AccessibilityContainer* pContainer = GetAccessibilityContainer();
        if (pContainer != null)
        {
-               __pAccessibilityElement = new _AccessibilityElement(true);
+               __pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
                SysTryReturnResult(NID_UI_CTRL, __pAccessibilityElement, E_OUT_OF_MEMORY, "Memory allocation failed.");
                __pAccessibilityElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBounds().width, GetBounds().height));
                __pAccessibilityElement->SetName(L"ProgressingImage");