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

View File

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