Fix bugs:
* Database creation failed * UsersDialog shown on new user
This commit is contained in:
parent
bfd16a6540
commit
28bb4c49f0
|
@ -1,4 +1,4 @@
|
|||
CREATE TABLE kisscount(db_version VARCHAR(20));
|
||||
CREATE TABLE kisscount(db_version VARCHAR(20));
|
||||
CREATE TABLE user (id INTEGER PRIMARY KEY, name VARCHAR(255), password VARCHAR(255));
|
||||
CREATE TABLE account(id INTEGER PRIMARY KEY, user REFERENCES user(id), name VARCHAR(255), number VARCHAR(255), shared CHAR(1), blocked CHAR(1), default_account CHAR(1), virtual CHAR(1), hidden CHAR(1));
|
||||
CREATE TABLE shared_account(account REFERENCES account(id), user REFERENCES user(id));
|
||||
|
|
|
@ -45,7 +45,7 @@ KissCount::KissCount(int argc, char** argv) : QApplication(argc, argv), _user(0)
|
|||
catch (std::string s)
|
||||
{
|
||||
_wxUI->close();
|
||||
throw ;
|
||||
throw s;
|
||||
}
|
||||
|
||||
_wxUI->ChangeUser();
|
||||
|
|
|
@ -136,24 +136,24 @@ void Database::CreateDatabase()
|
|||
|
||||
while (!init_script.atEnd())
|
||||
{
|
||||
QByteArray line = file.readLine().trimmed();
|
||||
QByteArray line = init_script.readLine().trimmed();
|
||||
QSqlQuery query;
|
||||
|
||||
if (line.isEmpty() || line.startsWith("--")) continue;
|
||||
|
||||
QSqlQuery query (QString(line), _db);
|
||||
// if (!query.isValid())
|
||||
// {
|
||||
// std::cout << QString(line).toStdString() << " is invalid !\n" ;
|
||||
// continue;
|
||||
// }
|
||||
|
||||
if (!query.isValid())
|
||||
{
|
||||
std::cout << QString(line).toStdString() << " is invalid !\n" ;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!query.exec())
|
||||
if (!query.exec(QString(line)))
|
||||
{
|
||||
QMessageBox::critical(0, _("Error"), _("Error creating original database"));
|
||||
init_script.close();
|
||||
file.remove();
|
||||
throw line;
|
||||
std::cout << QString(line).toStdString() << " is invalid !\n" ;
|
||||
throw QString(line);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,10 @@ UsersDialog::UsersDialog(KissCount* kiss, wxUI *parent) : QDialog(0, Qt::Dialog)
|
|||
_users->setFocus();
|
||||
|
||||
if (users_list.size() == 0)
|
||||
{
|
||||
OnNewUser();
|
||||
throw ExceptionNewUser();
|
||||
}
|
||||
else
|
||||
show();
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@ class UsersDialog : public QDialog
|
|||
public:
|
||||
UsersDialog(KissCount* kiss, wxUI *parent);
|
||||
|
||||
class ExceptionNewUser {};
|
||||
|
||||
private slots:
|
||||
void OnEnter();
|
||||
void OnOK();
|
||||
|
|
|
@ -279,8 +279,15 @@ void wxUI::OnButtonChangeUser()
|
|||
|
||||
void wxUI::ChangeUser()
|
||||
{
|
||||
UsersDialog u(_kiss, this);
|
||||
u.exec();
|
||||
try
|
||||
{
|
||||
UsersDialog u(_kiss, this);
|
||||
u.exec();
|
||||
}
|
||||
catch (UsersDialog::ExceptionNewUser e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void wxUI::OnButtonAbout()
|
||||
|
|
Loading…
Reference in New Issue
Block a user