Fix DataSet for exception case
authorSeungYeup Kim <sy2004.kim@samsung.com>
Thu, 11 Apr 2013 02:53:09 +0000 (11:53 +0900)
committerSeungYeup Kim <sy2004.kim@samsung.com>
Thu, 11 Apr 2013 04:31:24 +0000 (13:31 +0900)
Change-Id: I0c0c08bd0303b0872cbd19e850596b01dbb95010

src/io/FIo_DataRowImpl.cpp
src/io/FIo_DataSetEnumeratorImpl.cpp
src/io/FIo_DataSetImpl.cpp
src/io/inc/FIo_DataRowImpl.h [changed mode: 0644->0755]
src/io/inc/FIo_DataSetEnumeratorImpl.h
src/io/inc/FIo_DataSetImpl.h

index 19b0e99..c964b32 100755 (executable)
@@ -83,11 +83,16 @@ _DataRowImpl::_DataRowImpl(void)
        : __pDataRow(null)
        , __pColumnTypeList(null)
        , __columnCount(0)
+       , __dataSetDeleted(false)
 {
 }
 
 _DataRowImpl::~_DataRowImpl(void)
 {
+       if (!__dataSetDeleted)
+       {
+               __pRowImplList->Remove(*this);
+       }
 }
 
 result
@@ -101,6 +106,10 @@ _DataRowImpl::SetBlobAt(int columnIndex, Tizen::Base::ByteBuffer* pValue)
                                   "Wrong column index.");
        SysTryReturnResult(NID_IO, pValue != null, E_INVALID_ARG, "pValue is null");
 
+       //return E_SUCCESS without doing anything if the parent dataset class is destroyed.
+       if (__dataSetDeleted)
+               return r;
+
        pColumnType = static_cast<Integer*>(__pColumnTypeList->GetAt(columnIndex));
        nColumnType = pColumnType->ToInt();
        SysTryReturnResult(NID_IO, nColumnType == DB_COLUMNTYPE_BLOB || nColumnType == DB_COLUMNTYPE_NULL,
@@ -135,6 +144,10 @@ _DataRowImpl::SetDateTimeAt(int columnIndex, const Tizen::Base::DateTime& value)
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
                                   "Wrong column index.");
 
+       //return E_SUCCESS without doing anything if the parent dataset class is destroyed.
+       if (__dataSetDeleted)
+               return r;
+
        pColumnType = static_cast<Integer*>(__pColumnTypeList->GetAt(columnIndex));
        nColumnType = pColumnType->ToInt();
        SysTryReturnResult(NID_IO, nColumnType == DB_COLUMNTYPE_TEXT || nColumnType == DB_COLUMNTYPE_NULL,
@@ -173,6 +186,10 @@ _DataRowImpl::SetDoubleAt(int columnIndex, double value)
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
                                   "Wrong column index.");
 
+       //return E_SUCCESS without doing anything if the parent dataset class is destroyed.
+       if (__dataSetDeleted)
+               return r;
+
        pColumnType = static_cast<Integer*>(__pColumnTypeList->GetAt(columnIndex));
        nColumnType = pColumnType->ToInt();
        SysTryReturnResult(NID_IO, nColumnType == DB_COLUMNTYPE_DOUBLE || nColumnType == DB_COLUMNTYPE_NULL,
@@ -208,6 +225,10 @@ _DataRowImpl::SetIntAt(int columnIndex, int value)
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
                                   "Wrong column index.");
 
+       //return E_SUCCESS without doing anything if the parent dataset class is destroyed.
+       if (__dataSetDeleted)
+               return r;
+
        pColumnType = static_cast<Integer*>(__pColumnTypeList->GetAt(columnIndex));
        nColumnType = pColumnType->ToInt();
        SysTryReturnResult(NID_IO, nColumnType == DB_COLUMNTYPE_INT || nColumnType == DB_COLUMNTYPE_NULL,
@@ -242,6 +263,10 @@ _DataRowImpl::SetInt64At(int columnIndex, long long value)
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
                                   "Wrong column index.");
 
+       //return E_SUCCESS without doing anything if the parent dataset class is destroyed.
+       if (__dataSetDeleted)
+               return r;
+
        pColumnType = static_cast<Integer*>(__pColumnTypeList->GetAt(columnIndex));
        nColumnType = pColumnType->ToInt();
        SysTryReturnResult(NID_IO, nColumnType == DB_COLUMNTYPE_INT64 || nColumnType == DB_COLUMNTYPE_NULL,
@@ -275,6 +300,10 @@ _DataRowImpl::SetStringAt(int columnIndex, const Tizen::Base::String& value)
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
                                   "Wrong column index.");
 
+       //return E_SUCCESS without doing anything if the parent dataset class is destroyed.
+       if (__dataSetDeleted)
+               return r;
+
        pColumnType = static_cast<Integer*>(__pColumnTypeList->GetAt(columnIndex));
        nColumnType = pColumnType->ToInt();
        SysTryReturnResult(NID_IO, nColumnType == DB_COLUMNTYPE_TEXT || nColumnType == DB_COLUMNTYPE_NULL,
index 40320e5..76a250a 100755 (executable)
@@ -52,20 +52,20 @@ namespace Tizen { namespace Io
 {
 
 _DataSetEnumeratorImpl::_DataSetEnumeratorImpl(void)
-       : __pDataSet(null),
-       __pColumnList(null),
-       __pCurrentRow(null),
-       __columnCount(0),
-       __rowCount(0),
-       __currentRowIndex(-1),
-       __dataSetDeleted(0)
+       : __pDataSet(null)
+       , __pColumnList(null)
+       , __pCurrentRow(null)
+       , __columnCount(0)
+       , __rowCount(0)
+       , __currentRowIndex(-1)
+       , __dataSetDeleted(false)
 {
 
 }
 
 _DataSetEnumeratorImpl::~_DataSetEnumeratorImpl(void)
 {
-       if (__dataSetDeleted == 0)
+       if (!__dataSetDeleted)
        {
                __pEnumImplList->Remove(*this);
        }
@@ -76,7 +76,7 @@ _DataSetEnumeratorImpl::MoveNext(void)
 {
        SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
                                "The Object is not constructed.");
-       SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE,
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, E_INVALID_STATE,
                                "The dataset is already been deleted.");
 
        if (__currentRowIndex +1  == __rowCount)
@@ -96,7 +96,7 @@ _DataSetEnumeratorImpl::MovePrevious(void)
 {
        SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
                                "The Object is not constructed.");
-       SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE,
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, E_INVALID_STATE,
                                "The dataset is already been deleted.");
 
        if (__currentRowIndex == 0)
@@ -116,7 +116,7 @@ _DataSetEnumeratorImpl::MoveFirst(void)
 {
        SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
                                "The Object is not constructed.");
-       SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE,
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, E_INVALID_STATE,
                                "The dataset is already been deleted.");
 
        __currentRowIndex = 0;
@@ -133,7 +133,7 @@ _DataSetEnumeratorImpl::MoveLast(void)
 {
        SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
                                "The Object is not constructed.");
-       SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE,
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, E_INVALID_STATE,
                                "The dataset is already been deleted.");
 
        __currentRowIndex = __rowCount -1;
@@ -150,7 +150,7 @@ _DataSetEnumeratorImpl::Reset(void)
 {
        SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
                                "The Object is not constructed.");
-       SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE,
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, E_INVALID_STATE,
                                "The dataset is already been deleted.");
 
        __currentRowIndex = -1;
@@ -166,7 +166,7 @@ _DataSetEnumeratorImpl::GetIntAt(int columnIndex, int& value) const
 
        SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
                                "The Object is not constructed.");
-       SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE,
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, 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.");
@@ -198,7 +198,7 @@ _DataSetEnumeratorImpl::GetInt64At(int columnIndex, long long& value) const
 
        SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
                                "The Object is not constructed.");
-       SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE,
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, 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.");
@@ -230,7 +230,7 @@ _DataSetEnumeratorImpl::GetDoubleAt(int columnIndex, double& value) const
 
        SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
                                "The Object is not constructed.");
-       SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE,
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, 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.");
@@ -262,7 +262,7 @@ _DataSetEnumeratorImpl::GetStringAt(int columnIndex, String& value) const
 
        SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
                                "The Object is not constructed.");
-       SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE,
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, 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.");
@@ -294,7 +294,7 @@ _DataSetEnumeratorImpl::GetBlobAt(int columnIndex, ByteBuffer& value) const
 
        SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
                                "The Object is not constructed.");
-       SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE,
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, 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.");
@@ -330,7 +330,7 @@ _DataSetEnumeratorImpl::GetBlobAt(int columnIndex, void* buffer, int size) const
 
        SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
                                "The Object is not constructed.");
-       SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE,
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, 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.");
@@ -371,7 +371,7 @@ _DataSetEnumeratorImpl::GetDateTimeAt(int columnIndex, DateTime& value) const
 
        SysTryReturnResult(NID_IO, __pDataSet != null, E_INVALID_STATE,
                                "The Object is not constructed.");
-       SysTryReturnResult(NID_IO, __dataSetDeleted != 1, E_INVALID_STATE,
+       SysTryReturnResult(NID_IO, __dataSetDeleted != true, 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.");
@@ -402,7 +402,7 @@ _DataSetEnumeratorImpl::GetColumnCount(void) const
 {
        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,
+       SysTryReturn(NID_IO, __dataSetDeleted != true, -1, E_INVALID_STATE,
                                "[E_INVALID_STATE] The dataset is already been deleted.");
 
        return __columnCount;
@@ -415,7 +415,7 @@ _DataSetEnumeratorImpl::GetColumnType(int columnIndex) const
 
        SysTryReturn(NID_IO, __pDataSet != null, DB_COLUMNTYPE_UNDEFINED, E_INVALID_STATE,
                                "[E_INVALID_STATE] The instance is not constructed.");
-       SysTryReturn(NID_IO, __dataSetDeleted != 1, DB_COLUMNTYPE_UNDEFINED, E_INVALID_STATE,
+       SysTryReturn(NID_IO, __dataSetDeleted != true, 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.");
@@ -454,7 +454,7 @@ _DataSetEnumeratorImpl::GetColumnName(int columnIndex) const
 {
        SysTryReturn(NID_IO, __pDataSet != null, null, E_INVALID_STATE,
                                "[E_INVALID_STATE] The instance is not constructed.");
-       SysTryReturn(NID_IO, __dataSetDeleted != 1, null, E_INVALID_STATE,
+       SysTryReturn(NID_IO, __dataSetDeleted != true, 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.");
@@ -478,7 +478,7 @@ _DataSetEnumeratorImpl::GetColumnSize(int columnIndex) const
 
        SysTryReturn(NID_IO, __pDataSet != null, -1, E_INVALID_STATE,
                "[E_INVALID_STATE] The instance is not constructed.");
-       SysTryReturn(NID_IO, __dataSetDeleted != 1, -1, E_INVALID_STATE,
+       SysTryReturn(NID_IO, __dataSetDeleted != true, -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.");
index 1e64390..47cf846 100755 (executable)
@@ -47,7 +47,9 @@ _DataSetImpl::_DataSetImpl(void)
 _DataSetImpl::~_DataSetImpl(void)
 {
        for (int i = 0; i< __enumImplList.GetCount() ; i++)
-               (static_cast<_DataSetEnumeratorImpl*>(__enumImplList.GetAt(i)))->__dataSetDeleted = 1;
+               (static_cast<_DataSetEnumeratorImpl*>(__enumImplList.GetAt(i)))->__dataSetDeleted = true;
+       for (int i = 0; i< __rowImplList.GetCount() ; i++)
+               (static_cast<_DataRowImpl*>(__rowImplList.GetAt(i)))->__dataSetDeleted = true;
 
        delete __pDataSet;
        delete __pColumnList;
@@ -102,6 +104,11 @@ _DataSetImpl::CreateDataRowN(void)
 
        _DataRowImpl::GetInstance(*pDataRow)->__pColumnTypeList = __pColumnTypeList;
 
+       r = __rowImplList.Add(_DataRowImpl::GetInstance(*pDataRow));
+       SysTryReturn(NID_IO, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Add to LinkedList Falied");
+
+       _DataRowImpl::GetInstance(*pDataRow)->__pRowImplList = &__rowImplList;
+
        __rowCount = __pDataSet->GetCount();
        //SysLog(NID_IO, "row count is %d", __rowCount);
 
old mode 100644 (file)
new mode 100755 (executable)
index 52701f2..bb2e1f2
@@ -103,6 +103,9 @@ private:
        Tizen::Base::Collection::ArrayList* __pColumnTypeList;
        int __columnCount;
 
+       bool __dataSetDeleted;
+       Tizen::Base::Collection::LinkedList* __pRowImplList;
+
        friend class _DataSetImpl;
 
 }; //_DataRowImpl
index 85f1264..ecfedb6 100755 (executable)
@@ -165,8 +165,9 @@ private:
        int __rowCount;
        int __currentRowIndex;
 
-       int __dataSetDeleted;
+       bool __dataSetDeleted;
        Tizen::Base::Collection::LinkedList* __pEnumImplList;
+
        friend class _DataSetImpl;
 
 }; // _DataSetEnumeratorImpl
index 541cafd..a85c8c6 100755 (executable)
@@ -75,6 +75,7 @@ private:
        int __rowCount;
 
        Tizen::Base::Collection::LinkedList __enumImplList;
+       Tizen::Base::Collection::LinkedList __rowImplList;
 }; // _DataSetImpl
 
 }} // Tizen::Io