mirror of
https://github.com/chris2511/xca.git
synced 2026-09-14 11:06:19 +05:00
Fix opening a database on startup.
Commit e32fce8581
(main.cpp: mainwin must exist for read_cmdline() in GUI mode)
created the Mainwindow before parsing the commandline,
but the MainWindow constructor opened a default database if set.
With this change, the MinWindow constructor does not open a default
database. Now the default database is explicitly opened after parsing
the command line, if no other database is already open.
Rename init_database() to setup_open_database()
It is re-entrant.
This commit is contained in:
parent
71fb8edc7e
commit
5d4b52ac87
@ -368,6 +368,10 @@ int main(int argc, char *argv[])
|
||||
read_cmdline(argc, argv);
|
||||
mainwin->importMulti(cmdline_items, 1);
|
||||
cmdline_items = NULL;
|
||||
if (!Database.isOpen())
|
||||
mainwin->init_database(QString());
|
||||
else
|
||||
mainwin->setup_open_database();
|
||||
mainwin->show();
|
||||
gui->exec();
|
||||
} else {
|
||||
|
||||
@ -133,11 +133,6 @@ MainWindow::MainWindow() : QMainWindow()
|
||||
check_oom(dhgenBar);
|
||||
dhgenBar->setMinimum(0);
|
||||
dhgenBar->setMaximum(0);
|
||||
|
||||
enum open_result result = Database.isOpen() ? init_database() :
|
||||
init_database(QString());
|
||||
if (result == pw_exit)
|
||||
throw pw_exit;
|
||||
}
|
||||
|
||||
void MainWindow::dropEvent(QDropEvent *event)
|
||||
@ -557,7 +552,7 @@ enum open_result MainWindow::init_database(const QString &name,
|
||||
close_database();
|
||||
try {
|
||||
Database.open(name, pass);
|
||||
return init_database();
|
||||
return setup_open_database();
|
||||
} catch (errorEx &err) {
|
||||
XCA_ERROR(err);
|
||||
return open_abort;
|
||||
@ -567,7 +562,7 @@ enum open_result MainWindow::init_database(const QString &name,
|
||||
return pw_ok;
|
||||
}
|
||||
|
||||
enum open_result MainWindow::init_database()
|
||||
enum open_result MainWindow::setup_open_database()
|
||||
{
|
||||
if (!Database.isOpen())
|
||||
return open_abort;
|
||||
|
||||
@ -109,7 +109,7 @@ class MainWindow: public QMainWindow, public Ui::MainWindow
|
||||
public slots:
|
||||
enum open_result init_database(const QString &dbName,
|
||||
const Passwd &pass = Passwd());
|
||||
enum open_result init_database();
|
||||
enum open_result setup_open_database();
|
||||
void new_database();
|
||||
void load_database();
|
||||
void close_database();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user