mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-09 06:43:08 +01:00
save
This commit is contained in:
parent
424ec2b9af
commit
da25498e51
@ -5,6 +5,7 @@
|
||||
#include "3rd-party/boolinq/boolinq.h"
|
||||
#include "database/mariadbdriver.h"
|
||||
#include "database/sqlitedriver.h"
|
||||
#include "exceptions/applicationexception.h"
|
||||
#include "gui/messagebox.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "miscellaneous/iofactory.h"
|
||||
@ -43,6 +44,29 @@ void DatabaseFactory::determineDriver() {
|
||||
if (m_dbDriver == nullptr) {
|
||||
qFatal("DB driver for '%s' was not found.", qPrintable(db_driver));
|
||||
}
|
||||
|
||||
if (m_dbDriver->driverType() != DatabaseDriver::DriverType::SQLite) {
|
||||
// Try to setup connection and fallback to SQLite.
|
||||
try {
|
||||
m_dbDriver->connection(metaObject()->className());
|
||||
}
|
||||
catch (const ApplicationException& ex) {
|
||||
qCriticalNN << LOGSEC_DB
|
||||
<< "Failed to reach connection to DB source, will fallback to SQLite:"
|
||||
<< QUOTE_W_SPACE_DOT(ex.message());
|
||||
|
||||
qApp->showGuiMessage(tr("Cannot connect to database"),
|
||||
tr("Connection to your database was not established with error '%1'. "
|
||||
"Falling back to SQLite.").arg(ex.message()),
|
||||
QSystemTrayIcon::MessageIcon::Critical,
|
||||
nullptr,
|
||||
true);
|
||||
|
||||
m_dbDriver = boolinq::from(m_allDbDrivers).first([](DatabaseDriver* driv) {
|
||||
return driv->driverType() == DatabaseDriver::DriverType::SQLite;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DatabaseDriver* DatabaseFactory::driver() const {
|
||||
|
Loading…
Reference in New Issue
Block a user