mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-25 05:38:46 -05:00
Open database outside of multi-settings loop to avoid reconnection warnings
This commit is contained in:
parent
0b03ad4c09
commit
ff7c2743b4
@ -160,8 +160,6 @@
|
||||
#include <QFontDialog>
|
||||
#include <QSerialPortInfo>
|
||||
#include <QScopedPointer>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlError>
|
||||
#include <QDebug>
|
||||
|
||||
#include "pimpl_impl.hpp"
|
||||
@ -949,14 +947,6 @@ Configuration::impl::impl (Configuration * self, QNetworkAccessManager * network
|
||||
ui_->setupUi (this);
|
||||
|
||||
{
|
||||
// Find a suitable data file location
|
||||
if (!writeable_data_dir_.mkpath ("."))
|
||||
{
|
||||
MessageBox::critical_message (this, tr ("Failed to create data directory"),
|
||||
tr ("path: \"%1\"").arg (writeable_data_dir_.absolutePath ()));
|
||||
throw std::runtime_error {"Failed to create data directory"};
|
||||
}
|
||||
|
||||
// Make sure the default save directory exists
|
||||
QString save_dir {"save"};
|
||||
default_save_directory_ = writeable_data_dir_;
|
||||
@ -1002,18 +992,6 @@ Configuration::impl::impl (Configuration * self, QNetworkAccessManager * network
|
||||
// this must be done after the default paths above are set
|
||||
read_settings ();
|
||||
|
||||
// set up SQLite database
|
||||
if (!QSqlDatabase::drivers ().contains ("QSQLITE"))
|
||||
{
|
||||
throw std::runtime_error {"Failed to find SQLite Qt driver"};
|
||||
}
|
||||
auto db = QSqlDatabase::addDatabase ("QSQLITE");
|
||||
db.setDatabaseName (writeable_data_dir_.absoluteFilePath ("db.sqlite"));
|
||||
if (!db.open ())
|
||||
{
|
||||
throw std::runtime_error {("Database Error: " + db.lastError ().text ()).toStdString ()};
|
||||
}
|
||||
|
||||
// conditionally load LotW users data
|
||||
ui_->LotW_CSV_fetch_push_button->setEnabled (false);
|
||||
connect (&lotw_users_, &LotWUsers::load_finished, [this] () {
|
||||
|
23
main.cpp
23
main.cpp
@ -20,6 +20,8 @@
|
||||
#include <QSplashScreen>
|
||||
#include <QCommandLineParser>
|
||||
#include <QCommandLineOption>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlError>
|
||||
|
||||
#include "revision_utils.hpp"
|
||||
#include "MetaDataRegistry.hpp"
|
||||
@ -233,6 +235,27 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
// create writeable data directory if not already there
|
||||
auto writeable_data_dir = QDir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)};
|
||||
if (!writeable_data_dir.mkpath ("."))
|
||||
{
|
||||
MessageBox::critical_message (nullptr, a.translate ("main", "Failed to create data directory"),
|
||||
a.translate ("main", "path: \"%1\"").arg (writeable_data_dir.absolutePath ()));
|
||||
throw std::runtime_error {"Failed to create data directory"};
|
||||
}
|
||||
|
||||
// set up SQLite database
|
||||
if (!QSqlDatabase::drivers ().contains ("QSQLITE"))
|
||||
{
|
||||
throw std::runtime_error {"Failed to find SQLite Qt driver"};
|
||||
}
|
||||
auto db = QSqlDatabase::addDatabase ("QSQLITE");
|
||||
db.setDatabaseName (writeable_data_dir.absoluteFilePath ("db.sqlite"));
|
||||
if (!db.open ())
|
||||
{
|
||||
throw std::runtime_error {("Database Error: " + db.lastError ().text ()).toStdString ()};
|
||||
}
|
||||
|
||||
int result;
|
||||
do
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user