Commit fb73e82e authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

sqlite: Transaction: Ensure no exception is thrown from the destructor

parent 8e1a90b2
......@@ -70,13 +70,20 @@ bool Transaction::transactionInProgress()
Transaction::~Transaction()
{
if ( CurrentTransaction != nullptr )
try
{
Statement s( m_dbConn->getConn(), "ROLLBACK" );
s.execute();
while ( s.row() != nullptr )
;
CurrentTransaction = nullptr;
if ( CurrentTransaction != nullptr )
{
Statement s( m_dbConn->getConn(), "ROLLBACK" );
s.execute();
while ( s.row() != nullptr )
;
CurrentTransaction = nullptr;
}
}
catch(...)
{
// Don't call std::terminate if ROLLBACK throws an exception
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment