Forgot some try/catch os user GetAccount*/GetCategory*

This commit is contained in:
Grégory Soutadé 2012-04-27 20:24:22 +02:00
parent 993e6b1759
commit 8c4ee64111
2 changed files with 43 additions and 27 deletions

View File

@ -119,7 +119,7 @@ void XMLImportEngine::LoadAccount(const QXmlAttributes& attrs)
_accounts[ac.id] = _user->GetAccountIdFromAccountNumber(ac.number);
return;
}
catch (User::AccountNotFound)
catch (User::AccountNotFound e)
{
}
}
@ -130,7 +130,7 @@ void XMLImportEngine::LoadAccount(const QXmlAttributes& attrs)
_accounts[ac.id] = _user->GetAccountId(ac.name);
return;
}
catch (User::AccountNotFound)
catch (User::AccountNotFound e)
{
}
}
@ -187,13 +187,15 @@ void XMLImportEngine::LoadCategory(const QXmlAttributes& attrs)
UNESCAPE_CHARS(cat.name);
int catId = _user->GetCategoryId(name);
if (catId)
try
{
int catId = _user->GetCategoryId(name);
_categories[id] = catId;
return;
}
catch(User::CategoryNotFound e)
{}
_categories[id] = --unknownCategory;
_unresolvedCategories.push_back(cat);

View File

@ -450,6 +450,8 @@ void PreferencesPanel::InitLanguage(User* user)
int i, select=0;
QListWidgetItem* item;
if (_inModification) return;
_inModification = true;
_language->clear();
@ -824,14 +826,18 @@ void PreferencesPanel::OnAccountModified(int row, int col)
if (col == ACCOUNT_NAME)
{
new_id = user->GetAccountId(new_account.name);
if (new_id != 0 && new_id != new_account.id)
{
QMessageBox::critical(0, _("Error"), _("Account ")+new_account.name+_(" already exists"));
_accountsGrid->setItem(row, ACCOUNT_NAME, new QTableWidgetItem(user->_accounts[row].name));
_inModification = false;
return ;
}
try {
new_id = user->GetAccountId(new_account.name);
if (new_id != new_account.id)
{
QMessageBox::critical(0, _("Error"), _("Account ")+new_account.name+_(" already exists"));
_accountsGrid->setItem(row, ACCOUNT_NAME, new QTableWidgetItem(user->_accounts[row].name));
_inModification = false;
return ;
}
}
catch(User::AccountNotFound e)
{}
}
_kiss->UpdateAccount(new_account);
@ -845,12 +851,14 @@ void PreferencesPanel::OnAccountModified(int row, int col)
return ;
}
if (user->GetAccountId(new_account.name) != 0)
{
try {
user->GetAccountId(new_account.name);
QMessageBox::critical(0, _("Error"), _("Account ")+new_account.name+_(" already exists"));
_inModification = false;
return ;
}
catch (User::AccountNotFound e)
{}
new_account._default = false;
new_account.shared = false;
@ -976,14 +984,18 @@ void PreferencesPanel::OnCategoryModified(int row, int col)
new_cat.font = old_cat.font;
new_cat.parent = old_cat.parent;
new_id = user->GetCategoryId(new_cat.name);
if (new_id != 0 && new_id != new_cat.id)
{
QMessageBox::critical(0, _("Error"), _("Category ")+new_cat.name+_(" already exists"));
_categoriesGrid->setItem(row, CATEGORY_NAME, new QTableWidgetItem(_(user->_categories[row].name.toStdString().c_str())));
_inModification = false;
return ;
}
try {
new_id = user->GetCategoryId(new_cat.name);
if (new_id != new_cat.id)
{
QMessageBox::critical(0, _("Error"), _("Category ")+new_cat.name+_(" already exists"));
_categoriesGrid->setItem(row, CATEGORY_NAME, new QTableWidgetItem(_(user->_categories[row].name.toStdString().c_str())));
_inModification = false;
return ;
}
}
catch(User::CategoryNotFound e)
{}
_kiss->UpdateCategory(new_cat);
}
@ -996,12 +1008,14 @@ void PreferencesPanel::OnCategoryModified(int row, int col)
return ;
}
if (user->GetCategoryId(new_cat.name) != 0)
{
try {
user->GetCategoryId(new_cat.name);
QMessageBox::critical(0, _("Error"), _("Category ")+new_cat.name+_(" already exists"));
_inModification = false;
return ;
}
catch(User::CategoryNotFound e)
{}
new_cat.fix_cost = false;
@ -1069,11 +1083,11 @@ void PreferencesPanel::OnOperationOrderChange(int index)
void PreferencesPanel::OnLanguageChange(int index)
{
if (_inModification) return;
int language = SupportedLanguages::languages[index].language;
QString name_lang = SupportedLanguages::languages[index].name;
if (_inModification) return;
if (_wxUI->SetLanguage(name_lang) || language == SupportedLanguages::English)
{
_wxUI->NeedReload();