Commit 45404d85 authored by Antonio Larrosa Jimenez's avatar Antonio Larrosa Jimenez Committed by Antonio Larrosa Jimenez
Browse files

Use std::unique_ptr to get the DbConfig... temporary object deleted automatically

As suggested by @dvratil
parent fa094b56
Pipeline #29536 passed with stage
in 46 minutes and 20 seconds
......@@ -53,11 +53,11 @@ QString DbConfig::defaultAvailableDatabaseBackend(QSettings &settings)
{
QString driverName = QStringLiteral(AKONADI_DATABASE_BACKEND);
DbConfig *dbConfigFallbackTest = nullptr;
std::unique_ptr<DbConfig> dbConfigFallbackTest;
if (driverName == QLatin1String("QMYSQL")) {
dbConfigFallbackTest = new DbConfigMysql;
dbConfigFallbackTest.reset(new DbConfigMysql);
} else if (driverName == QLatin1String("QPSQL")) {
dbConfigFallbackTest = new DbConfigPostgresql;
dbConfigFallbackTest.reset(new DbConfigPostgresql);
}
if (dbConfigFallbackTest && !dbConfigFallbackTest->isAvailable(settings)
......@@ -65,7 +65,6 @@ QString DbConfig::defaultAvailableDatabaseBackend(QSettings &settings)
qCWarning(AKONADISERVER_LOG) << driverName << " requirements not available. Falling back to using QSQLITE3.";
driverName = QStringLiteral("QSQLITE3");
}
delete dbConfigFallbackTest;
return driverName;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment