From 29448e11dcba8c57f6c497b02cbd700ab16a6c0a Mon Sep 17 00:00:00 2001 From: rahul dutt Date: Wed, 14 Aug 2013 04:11:01 +0530 Subject: [PATCH] Fixed issue N_SE-48552 and prevent defects Change-Id: Ie3d053a2b35b8c444a6d44c8b6500fe3b1b2c555 --- src/IntArticleReaderForm.cpp | 2 +- src/IntBookmarkListForm.cpp | 11 +++++-- src/IntEditBookmarkListForm.cpp | 2 -- src/IntHistoryListForm.cpp | 8 +++++ src/IntHistoryPresentationModel.cpp | 16 +++++----- src/IntMainForm.cpp | 63 ++++++++++++++++++++++++++----------- 6 files changed, 70 insertions(+), 32 deletions(-) diff --git a/src/IntArticleReaderForm.cpp b/src/IntArticleReaderForm.cpp index 74c1b05..3af0e9b 100644 --- a/src/IntArticleReaderForm.cpp +++ b/src/IntArticleReaderForm.cpp @@ -707,7 +707,7 @@ ArticleReaderForm::OnTextValueChanged (const Tizen::Ui::Control &source) __pFindWordCountLabel->SetText(L"0/0"); __pFindWordCountLabel->Invalidate(true); } - if (__pFindWordEditField->GetText().GetLength() > 0) + if (__pFindWordEditField &&__pFindWordEditField->GetText().GetLength() > 0) { StartWordSearch(); } diff --git a/src/IntBookmarkListForm.cpp b/src/IntBookmarkListForm.cpp index bdb34bf..3f5b29a 100644 --- a/src/IntBookmarkListForm.cpp +++ b/src/IntBookmarkListForm.cpp @@ -1035,7 +1035,6 @@ BookmarkListForm::OnSearchBarModeChanged(Tizen::Ui::Controls::SearchBar& source, r = __pSearchBar->SetContentAreaSize(Dimension(__pSearchListView->GetWidth(), __pSearchListView->GetHeight())); __pSearchBar->SetText(L""); } - AppLog("OnSearchBarModeChanged SetContentAreaSize heihgt %d, %d",__pSearchListView->GetHeight() , GetClientAreaBounds().height - __pSearchBar->GetHeight()); __pListview->UpdateList(); __pSearchListView->UpdateList(); } @@ -1167,8 +1166,14 @@ void BookmarkListForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus) { AppLog("BookmarkListForm::OnOrientationChanged start"); - __pListview->SetBackgroundColor(GetBackgroundColor()); - __pSearchListView->SetBackgroundColor(GetBackgroundColor()); + if (__pListview) + { + __pListview->SetBackgroundColor(GetBackgroundColor()); + } + if (__pSearchListView) + { + __pSearchListView->SetBackgroundColor(GetBackgroundColor()); + } if (__pListview) { if(__pSearchBar->GetShowState()) diff --git a/src/IntEditBookmarkListForm.cpp b/src/IntEditBookmarkListForm.cpp index 11f7389..be5b8f4 100644 --- a/src/IntEditBookmarkListForm.cpp +++ b/src/IntEditBookmarkListForm.cpp @@ -842,8 +842,6 @@ EditBookmarkListForm::OnSceneActivatedN(const SceneId& previousSceneId, const Sc } pBookmarkId->Append(pBookMark->GetBookmarkId()); - AppLog("BookmarkId: %ls", pBookmarkId->GetPointer()); - if(__pSelectedList->Contains(*pBookmarkId)) { __pListview->SetItemChecked(index,true); diff --git a/src/IntHistoryListForm.cpp b/src/IntHistoryListForm.cpp index 5ef2de1..ab1b91d 100644 --- a/src/IntHistoryListForm.cpp +++ b/src/IntHistoryListForm.cpp @@ -524,34 +524,40 @@ HistoryListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth) if(__pGroupData == null) { delete pItem; + delete pImage; return null; } if (pItem == null) { + delete pImage; return null; } pGroupItemClass = dynamic_cast< GroupItemClass* >(__pGroupData->GetAt(groupIndex)); if (pGroupItemClass == null) { delete pItem; + delete pImage; return null; } if (pGroupItemClass->GetHistoryData() == null) { delete pItem; + delete pImage; return null; } pHistory = dynamic_cast< History* >(pGroupItemClass->GetHistoryData()->GetAt(itemIndex)); if (pHistory == null) { delete pItem; + delete pImage; return null; } r = pItem->Construct(Dimension(itemWidth, 128 - 44 + __fontSize), LIST_ANNEX_STYLE_NORMAL); if (IsFailed(r)) { delete pItem; + delete pImage; return null; } @@ -587,6 +593,7 @@ HistoryListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth) if (IsFailed(r)) { delete pItem; + delete pImage; AppLogException("CreateItem failed with %s", GetErrorMessage(r)); return null; } @@ -636,6 +643,7 @@ HistoryListForm::CreateItem(int groupIndex, int itemIndex, int itemWidth) CATCH: delete pItem; + delete pImage; return null; } diff --git a/src/IntHistoryPresentationModel.cpp b/src/IntHistoryPresentationModel.cpp index 34ed74a..03f8f21 100644 --- a/src/IntHistoryPresentationModel.cpp +++ b/src/IntHistoryPresentationModel.cpp @@ -140,15 +140,14 @@ HistoryPresentationModel::SaveHistory(History& history) GetHistoryCountWithTimeRange(todayStart, todayEnd, todaysCount); GetHistoryWithTimeRange(todayStart, todayEnd, 0, todaysCount, *pTodaysList); - for(int count = 0; count < todaysCount; count++) + for (int count = 0; count < todaysCount; count++) { History *pHistoryItem = dynamic_cast(pTodaysList->GetAt(count)); - //AppLog("HistoryPresentationModel::saveHistory pHistoryItem id is %ls",pHistoryItem->GetHistoryId().GetPointer()); - AppLog("SaveHistory pHistoryItem url is %ls",pHistoryItem->GetHistoryUrl().GetPointer()); - AppLog("SaveHistory history url is %ls",history.GetHistoryUrl().GetPointer()); - if(pHistoryItem != null && pHistoryItem->GetHistoryUrl().CompareTo(history.GetHistoryUrl()) == 0) + if (pHistoryItem != null && pHistoryItem->GetHistoryUrl().CompareTo(history.GetHistoryUrl()) == 0) { + AppLog("SaveHistory pHistoryItem url is %ls",pHistoryItem->GetHistoryUrl().GetPointer()); + AppLog("SaveHistory history url is %ls",history.GetHistoryUrl().GetPointer()); history.SetHistoryId(pHistoryItem->GetHistoryId()); AppLog("HistoryPresentationModel::saveHistory pHistoryItem history is %ls",pHistoryItem->GetHistoryId().GetPointer()); break; @@ -336,8 +335,11 @@ void HistoryPresentationModel::UpdateHistoryFavIcon(History& history, Tizen::Gra Tizen::Base::ByteBuffer* pFavBuffer = pImage->EncodeToBufferN(favIconImage, IMG_FORMAT_PNG); // added because conversion may fail - if(GetLastResult() != E_SUCCESS) + if (GetLastResult() != E_SUCCESS) + { + delete pImage; return; + } delete pFavBuffer; history.SetFavIconBitmap(favIconImage); @@ -751,7 +753,7 @@ HistoryPresentationModel::GetHistoryCountWithTimeRange(Tizen::Base::DateTime& st for (int counter = 0 ; counter < count; counter++) { History *pHistory = dynamic_cast(__pDataList->GetAt(counter)); - AppLog("vinayhistorytimecomparison %d, %d",pHistory->GetVisitedTime().CompareTo(startTime),pHistory->GetVisitedTime().CompareTo(endTime)); + if(pHistory != null && pHistory->GetVisitedTime().CompareTo(startTime) > 0 && pHistory->GetVisitedTime().CompareTo(endTime) < 0) { historyCount++; diff --git a/src/IntMainForm.cpp b/src/IntMainForm.cpp index fb6d838..911ae38 100644 --- a/src/IntMainForm.cpp +++ b/src/IntMainForm.cpp @@ -2509,8 +2509,6 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) str.Append(nameElement); str.Append("').length"); String* pCount = __pWebViewer->EvaluateJavascriptN(str); - AppLog("pCount %ls",pCount->GetPointer()); - String script; if(idElement.GetLength() != 0) @@ -2523,8 +2521,6 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) script.Append(*pString); script.Append("\");"); } - - else if (nameElement.GetLength() != 0 && pCount->Equals("1",false) == true) { script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } "; @@ -2548,6 +2544,7 @@ MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId) AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer()); String* pStr = __pWebViewer->EvaluateJavascriptN(script); delete pStr; + delete pCount; } delete pItem; } @@ -4263,8 +4260,12 @@ MainForm::StartWordSearch() __pFindWordPrev->SetEnabled(false); String *pCountStr = null; - result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false); - AppLog("Search Result %s",GetErrorMessage(r)); + if (__pWebViewer) + { + result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false); + AppLog("Search Result %s",GetErrorMessage(r)); + } + /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;"); if (pCountStr != null) { @@ -4284,19 +4285,36 @@ void MainForm::OnTextFound(int totalCount, int currentOrdinal) if(totalCount == -1 || totalCount == 0) { - __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight()); - __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight()); -// return; + if (__pFindWordCountLabel) + { + __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight()); + } + if (__pFindWordEditField) + { + __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight()); + } } else if(totalCount > 100) { - __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight()); - __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight()); + if (__pFindWordCountLabel) + { + __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight()); + } + if (__pFindWordEditField) + { + __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight()); + } } else { - __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight()); - __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight()); + if (__pFindWordCountLabel) + { + __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight()); + } + if (__pFindWordEditField) + { + __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight()); + } } __maxOccurrances = totalCount; @@ -4343,16 +4361,20 @@ void MainForm::OnTextFound(int totalCount, int currentOrdinal) __pFindWordCountLabel->Invalidate(false); __pFindWordCountLabel->Invalidate(false); } - else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true) + else if (__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true) { __pFindWordCountLabelRightToLeft->SetText(countStr); __pFindWordCountLabelRightToLeft->Invalidate(false); __pFindWordCountLabelRightToLeft->Invalidate(false); } - //FindNextWord(true); - //Update the controls - __pFindWordNext->Invalidate(false); - __pFindWordPrev->Invalidate(false); + if (__pFindWordNext) + { + __pFindWordNext->Invalidate(false); + } + if (__pFindWordPrev) + { + __pFindWordPrev->Invalidate(false); + } } @@ -4490,6 +4512,9 @@ MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source) Point p(0,0); Point q(0,0); __pWebViewer->GetBlockRange(p,q); + if (p == Point(0,0) && q == Point(0,0)) + return; + __pImageMenu->SetAnchorPosition(p); __pImageMenu->Show(); Invalidate(true); @@ -4530,7 +4555,7 @@ MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPositi void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) { AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y); - if(TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1) + if(TouchEventManager::GetInstance() && TouchEventManager::GetInstance()->GetTouchInfoListN() && TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1) { AppLog("Returning because of more than one touch point."); return; -- 2.7.4