forked from qt-creator/qt-creator
Clang: Fix exception catching
Change-Id: I5914ee4056e821359109786190b7006ef992b60e Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -49,23 +49,25 @@ public:
|
||||
{}
|
||||
|
||||
int fetchDirectoryId(Utils::SmallStringView directoryPath)
|
||||
try {
|
||||
Sqlite::DeferredTransaction transaction{m_statementFactory.database};
|
||||
{
|
||||
try {
|
||||
Sqlite::DeferredTransaction transaction{m_statementFactory.database};
|
||||
|
||||
Utils::optional<int> optionalDirectoryId = readDirectoryId(directoryPath);
|
||||
Utils::optional<int> optionalDirectoryId = readDirectoryId(directoryPath);
|
||||
|
||||
int directoryId = -1;
|
||||
int directoryId = -1;
|
||||
|
||||
if (optionalDirectoryId)
|
||||
directoryId = optionalDirectoryId.value();
|
||||
else
|
||||
directoryId = writeDirectoryId(directoryPath);
|
||||
if (optionalDirectoryId)
|
||||
directoryId = optionalDirectoryId.value();
|
||||
else
|
||||
directoryId = writeDirectoryId(directoryPath);
|
||||
|
||||
transaction.commit();
|
||||
transaction.commit();
|
||||
|
||||
return directoryId;
|
||||
} catch (Sqlite::StatementIsBusy &) {
|
||||
return fetchDirectoryId(directoryPath);
|
||||
return directoryId;
|
||||
} catch (Sqlite::StatementIsBusy &) {
|
||||
return fetchDirectoryId(directoryPath);
|
||||
}
|
||||
}
|
||||
|
||||
Utils::optional<int> readDirectoryId(Utils::SmallStringView directoryPath)
|
||||
@@ -114,23 +116,25 @@ public:
|
||||
}
|
||||
|
||||
int fetchSourceId(int directoryId, Utils::SmallStringView sourceName)
|
||||
try {
|
||||
Sqlite::DeferredTransaction transaction{m_statementFactory.database};
|
||||
{
|
||||
try {
|
||||
Sqlite::DeferredTransaction transaction{m_statementFactory.database};
|
||||
|
||||
Utils::optional<int> optionalSourceId = readSourceId(directoryId, sourceName);
|
||||
Utils::optional<int> optionalSourceId = readSourceId(directoryId, sourceName);
|
||||
|
||||
int sourceId = -1;
|
||||
int sourceId = -1;
|
||||
|
||||
if (optionalSourceId)
|
||||
sourceId = optionalSourceId.value();
|
||||
else
|
||||
sourceId = writeSourceId(directoryId, sourceName);
|
||||
if (optionalSourceId)
|
||||
sourceId = optionalSourceId.value();
|
||||
else
|
||||
sourceId = writeSourceId(directoryId, sourceName);
|
||||
|
||||
transaction.commit();
|
||||
transaction.commit();
|
||||
|
||||
return sourceId;
|
||||
} catch (Sqlite::StatementIsBusy &) {
|
||||
return fetchSourceId(directoryId, sourceName);
|
||||
return sourceId;
|
||||
} catch (Sqlite::StatementIsBusy &) {
|
||||
return fetchSourceId(directoryId, sourceName);
|
||||
}
|
||||
}
|
||||
|
||||
int writeSourceId(int directoryId, Utils::SmallStringView sourceName)
|
||||
|
||||
@@ -95,39 +95,43 @@ QStringList processArguments(QCoreApplication &application)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//QLoggingCategory::setFilterRules(QStringLiteral("*.debug=false"));
|
||||
try {
|
||||
//QLoggingCategory::setFilterRules(QStringLiteral("*.debug=false"));
|
||||
|
||||
QCoreApplication::setOrganizationName(QStringLiteral("QtProject"));
|
||||
QCoreApplication::setOrganizationDomain(QStringLiteral("qt-project.org"));
|
||||
QCoreApplication::setApplicationName(QStringLiteral("ClangPchManagerBackend"));
|
||||
QCoreApplication::setApplicationVersion(QStringLiteral("0.1.0"));
|
||||
QCoreApplication::setOrganizationName(QStringLiteral("QtProject"));
|
||||
QCoreApplication::setOrganizationDomain(QStringLiteral("qt-project.org"));
|
||||
QCoreApplication::setApplicationName(QStringLiteral("ClangPchManagerBackend"));
|
||||
QCoreApplication::setApplicationVersion(QStringLiteral("0.1.0"));
|
||||
|
||||
QCoreApplication application(argc, argv);
|
||||
QCoreApplication application(argc, argv);
|
||||
|
||||
const QStringList arguments = processArguments(application);
|
||||
const QString connectionName = arguments[0];
|
||||
const QString databasePath = arguments[1];
|
||||
const QStringList arguments = processArguments(application);
|
||||
const QString connectionName = arguments[0];
|
||||
const QString databasePath = arguments[1];
|
||||
|
||||
Sqlite::Database database{Utils::PathString{databasePath}};
|
||||
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
|
||||
ClangBackEnd::FilePathCaching filePathCache{database};
|
||||
ClangPathWatcher<QFileSystemWatcher, QTimer> includeWatcher(filePathCache);
|
||||
ApplicationEnvironment environment;
|
||||
PchGenerator<QProcess> pchGenerator(environment);
|
||||
PchCreator pchCreator(environment, filePathCache);
|
||||
pchCreator.setGenerator(&pchGenerator);
|
||||
ProjectParts projectParts;
|
||||
PchManagerServer clangPchManagerServer(includeWatcher,
|
||||
pchCreator,
|
||||
projectParts);
|
||||
includeWatcher.setNotifier(&clangPchManagerServer);
|
||||
pchGenerator.setNotifier(&clangPchManagerServer);
|
||||
Sqlite::Database database{Utils::PathString{databasePath}};
|
||||
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
|
||||
ClangBackEnd::FilePathCaching filePathCache{database};
|
||||
ClangPathWatcher<QFileSystemWatcher, QTimer> includeWatcher(filePathCache);
|
||||
ApplicationEnvironment environment;
|
||||
PchGenerator<QProcess> pchGenerator(environment);
|
||||
PchCreator pchCreator(environment, filePathCache);
|
||||
pchCreator.setGenerator(&pchGenerator);
|
||||
ProjectParts projectParts;
|
||||
PchManagerServer clangPchManagerServer(includeWatcher,
|
||||
pchCreator,
|
||||
projectParts);
|
||||
includeWatcher.setNotifier(&clangPchManagerServer);
|
||||
pchGenerator.setNotifier(&clangPchManagerServer);
|
||||
|
||||
ConnectionServer<PchManagerServer, PchManagerClientProxy> connectionServer;
|
||||
connectionServer.setServer(&clangPchManagerServer);
|
||||
connectionServer.start(connectionName);
|
||||
ConnectionServer<PchManagerServer, PchManagerClientProxy> connectionServer;
|
||||
connectionServer.setServer(&clangPchManagerServer);
|
||||
connectionServer.start(connectionName);
|
||||
|
||||
return application.exec();
|
||||
return application.exec();
|
||||
} catch (const Sqlite::Exception &exception) {
|
||||
exception.printWarning();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -59,33 +59,35 @@ QStringList processArguments(QCoreApplication &application)
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
try {
|
||||
//QLoggingCategory::setFilterRules(QStringLiteral("*.debug=false"));
|
||||
{
|
||||
try {
|
||||
//QLoggingCategory::setFilterRules(QStringLiteral("*.debug=false"));
|
||||
|
||||
QCoreApplication::setOrganizationName(QStringLiteral("QtProject"));
|
||||
QCoreApplication::setOrganizationDomain(QStringLiteral("qt-project.org"));
|
||||
QCoreApplication::setApplicationName(QStringLiteral("ClangRefactoringBackend"));
|
||||
QCoreApplication::setApplicationVersion(QStringLiteral("0.1.0"));
|
||||
QCoreApplication::setOrganizationName(QStringLiteral("QtProject"));
|
||||
QCoreApplication::setOrganizationDomain(QStringLiteral("qt-project.org"));
|
||||
QCoreApplication::setApplicationName(QStringLiteral("ClangRefactoringBackend"));
|
||||
QCoreApplication::setApplicationVersion(QStringLiteral("0.1.0"));
|
||||
|
||||
QCoreApplication application(argc, argv);
|
||||
QCoreApplication application(argc, argv);
|
||||
|
||||
const QStringList arguments = processArguments(application);
|
||||
const QString connectionName = arguments[0];
|
||||
const QString databasePath = arguments[1];
|
||||
const QStringList arguments = processArguments(application);
|
||||
const QString connectionName = arguments[0];
|
||||
const QString databasePath = arguments[1];
|
||||
|
||||
Sqlite::Database database{Utils::PathString{databasePath}};
|
||||
RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
|
||||
FilePathCaching filePathCache{database};
|
||||
SymbolIndexing symbolIndexing{database, filePathCache};
|
||||
RefactoringServer clangCodeModelServer{symbolIndexing, filePathCache};
|
||||
ConnectionServer<RefactoringServer, RefactoringClientProxy> connectionServer;
|
||||
connectionServer.setServer(&clangCodeModelServer);
|
||||
connectionServer.start(connectionName);
|
||||
Sqlite::Database database{Utils::PathString{databasePath}};
|
||||
RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
|
||||
FilePathCaching filePathCache{database};
|
||||
SymbolIndexing symbolIndexing{database, filePathCache};
|
||||
RefactoringServer clangCodeModelServer{symbolIndexing, filePathCache};
|
||||
ConnectionServer<RefactoringServer, RefactoringClientProxy> connectionServer;
|
||||
connectionServer.setServer(&clangCodeModelServer);
|
||||
connectionServer.start(connectionName);
|
||||
|
||||
|
||||
return application.exec();
|
||||
} catch (const Sqlite::Exception &exception) {
|
||||
exception.printWarning();
|
||||
return application.exec();
|
||||
} catch (const Sqlite::Exception &exception) {
|
||||
exception.printWarning();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user