* Remove all Operation's pointers because they are dereferenced when an element of operation's vector is suppressed : so group delete works !!! (whouhou).

This commit is contained in:
2010-10-03 20:31:06 +02:00
parent 6e0b51c9fe
commit 5245ec2623
6 changed files with 170 additions and 148 deletions

View File

@@ -36,7 +36,7 @@ public:
wxString transfert;
wxString formula;
bool meta;
std::vector<Operation*> childs;
std::vector<wxString> childs;
} ;
#endif

View File

@@ -161,42 +161,41 @@ void User::LinkOrUnlinkOperation(Operation& op)
}
}
void User::Group(Operation* op)
void User::Group(const Operation& op)
{
std::vector<Operation>::iterator it;
std::vector<Operation*>::iterator it2;
std::vector<wxString>::iterator it2;
for (it = (*_operations[op->year])[op->month].begin(); it != (*_operations[op->year])[op->month].end(); it++)
for (it = (*_operations[op.year])[op.month].begin(); it != (*_operations[op.year])[op.month].end(); it++)
{
if (it->id == op->parent)
if (it->id == op.parent)
{
for (it2 = it->childs.begin(); it2 != it->childs.end(); it2++)
if ((*it2)->id == op->id)
if (*it2 == op.id)
break;
// Already into childs
if (it2 != it->childs.end()) return;
it->childs.push_back(op);
it->childs.push_back(op.id);
break;
}
}
}
void User::UnGroup(Operation* op)
void User::UnGroup(const Operation& op)
{
std::vector<Operation>::iterator it;
std::vector<Operation*>::iterator it2;
std::vector<wxString>::iterator it2;
for (it = (*_operations[op->year])[op->month].begin(); it != (*_operations[op->year])[op->month].end(); it++)
for (it = (*_operations[op.year])[op.month].begin(); it != (*_operations[op.year])[op.month].end(); it++)
{
if (it->id == op->parent)
if (it->id == op.parent)
{
for (it2 = it->childs.begin(); it2 != it->childs.end(); it2++)
if ((*it2)->id == op->id)
if (*it2 == op.id)
{
it->childs.erase(it2);
return;
}
break;
}
}
}
@@ -210,6 +209,6 @@ void User::ResolveGroups(int year)
{
for (i=0; i<it->second.size(); i++)
if (it->second[i].parent.Length())
Group(&((*_operations[year])[it->first])[i]);
Group(((*_operations[year])[it->first])[i]);
}
}

View File

@@ -54,8 +54,8 @@ public:
int GetOperationsNumber(int month, int year);
wxLanguage GetLanguage();
void LinkOrUnlinkOperation(Operation& op);
void Group(Operation* op);
void UnGroup(Operation* op);
void Group(const Operation& op);
void UnGroup(const Operation& op);
void ResolveGroups(int year);
};