From: SeungYeup Kim Date: Wed, 10 Apr 2013 05:25:50 +0000 (+0900) Subject: Fix Dataset for exception case X-Git-Tag: accepted/tizen_2.1/20130425.034849~93^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8862ac7aaf9a174c421b83a5f999b5b9d0fd1198;p=platform%2Fframework%2Fnative%2Fappfw.git Fix Dataset for exception case Change-Id: I4ec0fc51db6d9fe22c3d345843f0eb8f11e54e7c --- diff --git a/src/io/FIo_DataSetEnumeratorImpl.cpp b/src/io/FIo_DataSetEnumeratorImpl.cpp index c631d7f..40320e5 100755 --- a/src/io/FIo_DataSetEnumeratorImpl.cpp +++ b/src/io/FIo_DataSetEnumeratorImpl.cpp @@ -57,21 +57,27 @@ _DataSetEnumeratorImpl::_DataSetEnumeratorImpl(void) __pCurrentRow(null), __columnCount(0), __rowCount(0), - __currentRowIndex(-1) + __currentRowIndex(-1), + __dataSetDeleted(0) { } _DataSetEnumeratorImpl::~_DataSetEnumeratorImpl(void) { - + if (__dataSetDeleted == 0) + { + __pEnumImplList->Remove(*this); + } } result _DataSetEnumeratorImpl::MoveNext(void) { SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE, - "The Object is not constructed or the dataset is already been deleted."); + "The Object is not constructed."); + SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE, + "The dataset is already been deleted."); if (__currentRowIndex +1 == __rowCount) return E_OUT_OF_RANGE; @@ -89,7 +95,9 @@ result _DataSetEnumeratorImpl::MovePrevious(void) { SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE, - "The Object is not constructed or the dataset is already been deleted."); + "The Object is not constructed."); + SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE, + "The dataset is already been deleted."); if (__currentRowIndex == 0) return E_OUT_OF_RANGE; @@ -107,7 +115,9 @@ result _DataSetEnumeratorImpl::MoveFirst(void) { SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE, - "The Object is not constructed or the dataset is already been deleted."); + "The Object is not constructed."); + SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE, + "The dataset is already been deleted."); __currentRowIndex = 0; __pCurrentRow = static_cast(__pDataSet->GetAt(__currentRowIndex)); @@ -122,7 +132,9 @@ result _DataSetEnumeratorImpl::MoveLast(void) { SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE, - "The Object is not constructed or the dataset is already been deleted."); + "The Object is not constructed."); + SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE, + "The dataset is already been deleted."); __currentRowIndex = __rowCount -1; __pCurrentRow = static_cast(__pDataSet->GetAt(__currentRowIndex)); @@ -137,7 +149,9 @@ result _DataSetEnumeratorImpl::Reset(void) { SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE, - "The Object is not constructed or the dataset is already been deleted."); + "The Object is not constructed."); + SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE, + "The dataset is already been deleted."); __currentRowIndex = -1; __pCurrentRow = null; @@ -151,7 +165,9 @@ _DataSetEnumeratorImpl::GetIntAt(int columnIndex, int& value) const result r = E_SUCCESS; SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE, - "The Object is not constructed or the dataset is already been deleted."); + "The Object is not constructed."); + SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE, + "The dataset is already been deleted."); SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG, "Given column index is out of range."); SysTryReturnResult(NID_IO, __pCurrentRow != null, E_INVALID_STATE, @@ -181,7 +197,9 @@ _DataSetEnumeratorImpl::GetInt64At(int columnIndex, long long& value) const result r = E_SUCCESS; SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE, - "The Object is not constructed or the dataset is already been deleted."); + "The Object is not constructed."); + SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE, + "The dataset is already been deleted."); SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG, "Given column index is out of range."); SysTryReturnResult(NID_IO, __pCurrentRow != null, E_INVALID_STATE, @@ -211,7 +229,9 @@ _DataSetEnumeratorImpl::GetDoubleAt(int columnIndex, double& value) const result r = E_SUCCESS; SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE, - "The Object is not constructed or the dataset is already been deleted."); + "The Object is not constructed."); + SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE, + "The dataset is already been deleted."); SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG, "Given column index is out of range."); SysTryReturnResult(NID_IO, __pCurrentRow != null, E_INVALID_STATE, @@ -241,7 +261,9 @@ _DataSetEnumeratorImpl::GetStringAt(int columnIndex, String& value) const result r = E_SUCCESS; SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE, - "The Object is not constructed or the dataset is already been deleted."); + "The Object is not constructed."); + SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE, + "The dataset is already been deleted."); SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG, "Given column index is out of range."); SysTryReturnResult(NID_IO, __pCurrentRow != null, E_INVALID_STATE, @@ -271,7 +293,9 @@ _DataSetEnumeratorImpl::GetBlobAt(int columnIndex, ByteBuffer& value) const ByteBuffer* pBuffer = null; SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE, - "The Object is not constructed or the dataset is already been deleted."); + "The Object is not constructed."); + SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE, + "The dataset is already been deleted."); SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG, "Given column index is out of range."); SysTryReturnResult(NID_IO, __pCurrentRow != null, E_INVALID_STATE, @@ -305,7 +329,9 @@ _DataSetEnumeratorImpl::GetBlobAt(int columnIndex, void* buffer, int size) const ByteBuffer* pBuffer = null; SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE, - "The Object is not constructed or the dataset is already been deleted."); + "The Object is not constructed."); + SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE, + "The dataset is already been deleted."); SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG, "Given column index is out of range."); SysTryReturnResult(NID_IO, __pCurrentRow != null, E_INVALID_STATE, @@ -344,7 +370,9 @@ _DataSetEnumeratorImpl::GetDateTimeAt(int columnIndex, DateTime& value) const String* pStr = null; SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE, - "The instance is not constructed or the dataset is already been deleted."); + "The Object is not constructed."); + SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE, + "The dataset is already been deleted."); SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG, "Given column index is out of range."); SysTryReturnResult(NID_IO, __pCurrentRow != null, E_INVALID_STATE, @@ -372,8 +400,10 @@ CATCH: int _DataSetEnumeratorImpl::GetColumnCount(void) const { - SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE, - "The Object is not constructed or the dataset is already been deleted."); + SysTryReturn(NID_IO, __pDataSet != null, -1, E_INVALID_STATE, + "[E_INVALID_STATE] The Object is not constructed."); + SysTryReturn(NID_IO, __dataSetDeleted != 1, -1, E_INVALID_STATE, + "[E_INVALID_STATE] The dataset is already been deleted."); return __columnCount; } @@ -384,8 +414,9 @@ _DataSetEnumeratorImpl::GetColumnType(int columnIndex) const DbColumnType type = DB_COLUMNTYPE_UNDEFINED; SysTryReturn(NID_IO, __pDataSet != null, DB_COLUMNTYPE_UNDEFINED, E_INVALID_STATE, - "[E_INVALID_STATE] The instance is not constructed or the dataset is already been deleted."); - + "[E_INVALID_STATE] The instance is not constructed."); + SysTryReturn(NID_IO, __dataSetDeleted != 1, DB_COLUMNTYPE_UNDEFINED, E_INVALID_STATE, + "[E_INVALID_STATE] The dataset is already been deleted."); SysTryReturn(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, DB_COLUMNTYPE_UNDEFINED, E_INVALID_ARG, "[E_INVALID_ARG] Given column index is out of range."); @@ -422,8 +453,9 @@ String _DataSetEnumeratorImpl::GetColumnName(int columnIndex) const { SysTryReturn(NID_IO, __pDataSet != null, null, E_INVALID_STATE, - "[E_INVALID_STATE] The instance is not constructed or the dataset is already been deleted."); - + "[E_INVALID_STATE] The instance is not constructed."); + SysTryReturn(NID_IO, __dataSetDeleted != 1, null, E_INVALID_STATE, + "[E_INVALID_STATE] The dataset is already been deleted."); SysTryReturn(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, null, E_INVALID_ARG, "[E_INVALID_ARG] Given column index is out of range."); @@ -445,11 +477,11 @@ _DataSetEnumeratorImpl::GetColumnSize(int columnIndex) const int bytes = 0; SysTryReturn(NID_IO, __pDataSet != null, -1, E_INVALID_STATE, - "[E_INVALID_STATE] The instance is not constructed or the dataset is already been deleted."); - + "[E_INVALID_STATE] The instance is not constructed."); + SysTryReturn(NID_IO, __dataSetDeleted != 1, -1, E_INVALID_STATE, + "[E_INVALID_STATE] The dataset is already been deleted."); SysTryReturn(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, -1, E_INVALID_ARG, "[E_INVALID_ARG] Given column index is out of range."); - SysTryReturn(NID_IO, __pCurrentRow != null, -1, E_INVALID_STATE, "[E_INVALID_STATE] The method has tried to fetch the column data of a result set that is not activated."); diff --git a/src/io/FIo_DataSetImpl.cpp b/src/io/FIo_DataSetImpl.cpp index 9670bd3..1e64390 100755 --- a/src/io/FIo_DataSetImpl.cpp +++ b/src/io/FIo_DataSetImpl.cpp @@ -46,6 +46,9 @@ _DataSetImpl::_DataSetImpl(void) _DataSetImpl::~_DataSetImpl(void) { + for (int i = 0; i< __enumImplList.GetCount() ; i++) + (static_cast<_DataSetEnumeratorImpl*>(__enumImplList.GetAt(i)))->__dataSetDeleted = 1; + delete __pDataSet; delete __pColumnList; delete __pColumnTypeList; @@ -109,6 +112,8 @@ _DataSetImpl::CreateDataRowN(void) DataSetEnumerator* _DataSetImpl::GetDataSetEnumeratorN(void) { + result r; + unique_ptr pDataSetEnum(_DataSetEnumeratorImpl::CreateDataSetEnumeratorInstanceN()); _DataSetEnumeratorImpl::GetInstance(*pDataSetEnum)->__pDataSet = __pDataSet; @@ -118,6 +123,11 @@ _DataSetImpl::GetDataSetEnumeratorN(void) //SysLog(NID_IO, "row count is %d, column count is %d", __rowCount, __columnCount); + r = __enumImplList.Add(_DataSetEnumeratorImpl::GetInstance(*pDataSetEnum)); + SysTryReturn(NID_IO, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Add to LinkedList Falied"); + + _DataSetEnumeratorImpl::GetInstance(*pDataSetEnum)->__pEnumImplList = &__enumImplList; + return pDataSetEnum.release(); } diff --git a/src/io/inc/FIo_DataSetEnumeratorImpl.h b/src/io/inc/FIo_DataSetEnumeratorImpl.h old mode 100644 new mode 100755 index 9586c4a..85f1264 --- a/src/io/inc/FIo_DataSetEnumeratorImpl.h +++ b/src/io/inc/FIo_DataSetEnumeratorImpl.h @@ -162,11 +162,11 @@ private: Tizen::Base::Collection::ArrayList* __pCurrentRow; int __columnCount; - int __rowCount; - int __currentRowIndex; + int __dataSetDeleted; + Tizen::Base::Collection::LinkedList* __pEnumImplList; friend class _DataSetImpl; }; // _DataSetEnumeratorImpl diff --git a/src/io/inc/FIo_DataSetImpl.h b/src/io/inc/FIo_DataSetImpl.h index 2c4fd48..541cafd 100755 --- a/src/io/inc/FIo_DataSetImpl.h +++ b/src/io/inc/FIo_DataSetImpl.h @@ -73,6 +73,8 @@ private: int __columnCount; int __rowCount; + + Tizen::Base::Collection::LinkedList __enumImplList; }; // _DataSetImpl }} // Tizen::Io