mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-10 07:13:32 +01:00
save
This commit is contained in:
parent
424ec2b9af
commit
da25498e51
@ -5,6 +5,7 @@
|
|||||||
#include "3rd-party/boolinq/boolinq.h"
|
#include "3rd-party/boolinq/boolinq.h"
|
||||||
#include "database/mariadbdriver.h"
|
#include "database/mariadbdriver.h"
|
||||||
#include "database/sqlitedriver.h"
|
#include "database/sqlitedriver.h"
|
||||||
|
#include "exceptions/applicationexception.h"
|
||||||
#include "gui/messagebox.h"
|
#include "gui/messagebox.h"
|
||||||
#include "miscellaneous/application.h"
|
#include "miscellaneous/application.h"
|
||||||
#include "miscellaneous/iofactory.h"
|
#include "miscellaneous/iofactory.h"
|
||||||
@ -43,6 +44,29 @@ void DatabaseFactory::determineDriver() {
|
|||||||
if (m_dbDriver == nullptr) {
|
if (m_dbDriver == nullptr) {
|
||||||
qFatal("DB driver for '%s' was not found.", qPrintable(db_driver));
|
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 {
|
DatabaseDriver* DatabaseFactory::driver() const {
|
||||||
|
Loading…
Reference in New Issue
Block a user