Initialize thread_db within the loop

main
Simon Quigley 6 days ago
parent 9c7c91dac9
commit 9e6a0b0453

@ -36,10 +36,11 @@ static int get_delay(int attempt) {
QSqlDatabase get_thread_connection() {
QString connection_name;
QSqlDatabase thread_db;
bool passed = false;
int attempt = 0;
while (!passed) {
QSqlDatabase thread_db;
std::lock_guard<std::mutex> lock(connection_mutex_);
thread_local unsigned int thread_unique_id = thread_id_counter.fetch_add(1);
connection_name = QString("CIConn_%1").arg(thread_unique_id);
@ -70,11 +71,9 @@ QSqlDatabase get_thread_connection() {
}
if (!thread_db.open()) throw std::runtime_error("Failed to open new database connection for thread: " + thread_db.lastError().text().toStdString());
passed = true;
}
return thread_db;
}
}
bool ci_query_exec(QSqlQuery* query, const QString query_string) {
bool passed = false;

Loading…
Cancel
Save