From 4990eed417ef40fc4efac9697d85a902a1d87807 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Sat, 26 Jan 2019 14:03:39 +0100 Subject: [PATCH] SqlDatabase: Remove existing database before adding new Fixes duplicate connection warning. --- src/lib/tools/sqldatabase.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/tools/sqldatabase.cpp b/src/lib/tools/sqldatabase.cpp index 1542b3de7..79f626298 100644 --- a/src/lib/tools/sqldatabase.cpp +++ b/src/lib/tools/sqldatabase.cpp @@ -120,8 +120,9 @@ QSqlDatabase SqlDatabase::database() } if (!s_databases.hasLocalData()) { - const QString threadStr = QString::number((quintptr) QThread::currentThread()); - QSqlDatabase db = QSqlDatabase::addDatabase(QSL("QSQLITE"), QSL("Falkon/") + threadStr); + const QString threadStr = QStringLiteral("Falkon/%1").arg((quintptr) QThread::currentThread()); + QSqlDatabase::removeDatabase(threadStr); + QSqlDatabase db = QSqlDatabase::addDatabase(QSL("QSQLITE"), threadStr); db.setDatabaseName(m_databaseName); db.setConnectOptions(m_connectOptions); db.open();