forked from qt-creator/qt-creator
Clang: Handle a busy database in the PCH plugin
This can be always happen for write statements. It fixes the wrong behavior of the transaction that it tried to rollback if begin fails. If begin fails the transaction never started so there is nothing to rollback. Change-Id: I8a03162257fa22a0bb66ccb844f90c6afbc7db64 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "precompiledheaderstorageinterface.h"
|
||||
|
||||
#include <sqlitetransaction.h>
|
||||
#include <sqliteexception.h>
|
||||
|
||||
#include <utils/smallstringview.h>
|
||||
|
||||
@@ -50,13 +51,29 @@ public:
|
||||
Utils::SmallStringView pchPath,
|
||||
long long pchBuildTime) override
|
||||
{
|
||||
m_insertProjectPartStatement.write(projectPartName);
|
||||
m_insertPrecompiledHeaderStatement .write(projectPartName, pchPath, pchBuildTime);
|
||||
try {
|
||||
Sqlite::ImmediateTransaction transaction{m_database};
|
||||
|
||||
m_insertProjectPartStatement.write(projectPartName);
|
||||
m_insertPrecompiledHeaderStatement .write(projectPartName, pchPath, pchBuildTime);
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Sqlite::StatementIsBusy) {
|
||||
insertPrecompiledHeader(projectPartName, pchPath, pchBuildTime);
|
||||
}
|
||||
}
|
||||
|
||||
void deletePrecompiledHeader(Utils::SmallStringView projectPartName) override
|
||||
{
|
||||
m_deletePrecompiledHeaderStatement.write(projectPartName);
|
||||
try {
|
||||
Sqlite::ImmediateTransaction transaction{m_database};
|
||||
|
||||
m_deletePrecompiledHeaderStatement.write(projectPartName);
|
||||
|
||||
transaction.commit();
|
||||
} catch (const Sqlite::StatementIsBusy) {
|
||||
deletePrecompiledHeader(projectPartName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user