Add another try/catch
This commit is contained in:
parent
2bc5c191f0
commit
fb1d5e4340
@ -46,6 +46,7 @@ QSqlDatabase get_thread_connection() {
|
|||||||
|
|
||||||
// Check if the connection already exists for this thread
|
// Check if the connection already exists for this thread
|
||||||
attempt++;
|
attempt++;
|
||||||
|
try {
|
||||||
if (QSqlDatabase::contains(connection_name)) {
|
if (QSqlDatabase::contains(connection_name)) {
|
||||||
QSqlDatabase db = QSqlDatabase::database(connection_name);
|
QSqlDatabase db = QSqlDatabase::database(connection_name);
|
||||||
if (!db.isOpen()) {
|
if (!db.isOpen()) {
|
||||||
@ -63,6 +64,10 @@ QSqlDatabase get_thread_connection() {
|
|||||||
|
|
||||||
thread_db = QSqlDatabase::addDatabase("QSQLITE", connection_name);
|
thread_db = QSqlDatabase::addDatabase("QSQLITE", connection_name);
|
||||||
thread_db.setDatabaseName(shared_database_path);
|
thread_db.setDatabaseName(shared_database_path);
|
||||||
|
} catch (...) {
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(get_delay(attempt)));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!thread_db.open()) throw std::runtime_error("Failed to open new database connection for thread: " + thread_db.lastError().text().toStdString());
|
if (!thread_db.open()) throw std::runtime_error("Failed to open new database connection for thread: " + thread_db.lastError().text().toStdString());
|
||||||
passed = true;
|
passed = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user