Fix bug: Check index in ctrl+t, ctrl+r and suppr callback to avoid doing something on non existant operation

This commit is contained in:
Grégory Soutadé 2019-07-27 14:01:56 +02:00
parent 2865102a55
commit 196a0cc5ab
2 changed files with 20 additions and 3 deletions

View File

@ -1,3 +1,9 @@
v0.9 (27/07/2019)
** User **
** Dev **
** Bugs **
Check index in ctrl+t, ctrl+r and suppr callback to avoid doing something on non existant operation
v0.8 (29/01/2019) v0.8 (29/01/2019)
** User ** ** User **
Add multi month operation support : Normal operation with description "... (XX/YY)" will be forwarded to next month Add multi month operation support : Normal operation with description "... (XX/YY)" will be forwarded to next month

View File

@ -1670,7 +1670,7 @@ void GridAccount::OnCtrlT(void)
{ {
Operation op, op2; Operation op, op2;
QModelIndexList selected = selectedIndexes(); QModelIndexList selected = selectedIndexes();
int account, idx; int account, idx, row;
bool groupOperations; bool groupOperations;
User* user = _kiss->GetUser(); User* user = _kiss->GetUser();
std::vector<Operation>::iterator it; std::vector<Operation>::iterator it;
@ -1678,7 +1678,12 @@ void GridAccount::OnCtrlT(void)
if (selected.size() > 1 || !selected.size()) if (selected.size() > 1 || !selected.size())
return; return;
op = _displayedOperations[selected[0].row()] ; row = selected[0].row();
if (row == _fixCosts || row == (int)_displayedOperations.size()-1)
return;
op = _displayedOperations[row] ;
if (op.parent || op.meta || op.transfert) if (op.parent || op.meta || op.transfert)
return; return;
@ -1724,6 +1729,9 @@ void GridAccount::OnCtrlR(void)
{ {
row = selected[i].row(); row = selected[i].row();
if (row == _fixCosts || row == (int)_displayedOperations.size()-1)
continue;
it = std::find(rows.begin(), rows.end(), row); it = std::find(rows.begin(), rows.end(), row);
if (it != rows.end()) if (it != rows.end())
@ -1746,6 +1754,9 @@ void GridAccount::OnSuppr(void)
{ {
row = selected[i].row(); row = selected[i].row();
if (row == _fixCosts || row == (int)_displayedOperations.size()-1)
continue;
it = std::find(rows.begin(), rows.end(), row); it = std::find(rows.begin(), rows.end(), row);
if (it != rows.end()) if (it != rows.end())