Fix Statement destructor since addition of the move constructor

This commit is contained in:
Sébastien Rombauts 2019-03-05 07:15:06 +01:00
parent f2b1017710
commit 50425142fe

View File

@ -473,23 +473,25 @@ Statement::Ptr::Ptr(Ptr&& aPtr) :
*/
Statement::Ptr::~Ptr()
{
assert(NULL != mpRefCount);
assert(0 != *mpRefCount);
// Decrement and check the reference counter of the sqlite3_stmt
--(*mpRefCount);
if (0 == *mpRefCount)
if (NULL != mpRefCount)
{
// If count reaches zero, finalize the sqlite3_stmt, as no Statement nor Column objet use it anymore.
// No need to check the return code, as it is the same as the last statement evaluation.
sqlite3_finalize(mpStmt);
assert(0 != *mpRefCount);
// and delete the reference counter
delete mpRefCount;
mpRefCount = NULL;
mpStmt = NULL;
// Decrement and check the reference counter of the sqlite3_stmt
--(*mpRefCount);
if (0 == *mpRefCount)
{
// If count reaches zero, finalize the sqlite3_stmt, as no Statement nor Column objet use it anymore.
// No need to check the return code, as it is the same as the last statement evaluation.
sqlite3_finalize(mpStmt);
// and delete the reference counter
delete mpRefCount;
mpRefCount = NULL;
mpStmt = NULL;
}
// else, the finalization will be done later, by the last object
}
// else, the finalization will be done later, by the last object
}