From ac96255b3c6f7e8166eb64d582f77fbc3f35e772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Thu, 6 Jan 2011 19:03:46 +0100 Subject: [PATCH] Better fix for previous bug --- src/model/Database.cpp | 46 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/model/Database.cpp b/src/model/Database.cpp index 53278ce..3b6b754 100644 --- a/src/model/Database.cpp +++ b/src/model/Database.cpp @@ -662,33 +662,33 @@ bool Database::LoadOperation(User* user, const wxString& id) op.formula = set.GetAsString(wxT("formula")); op.meta = set.GetBool(wxT("meta")); - if (!user->_operations[op.year]) - user->_operations[op.year] = new std::map >(); - - for (it = (*user->_operations[op.year])[op.month].begin(); - it != (*user->_operations[op.year])[op.month].end(); - it++) + if (user->_operations[op.year]) { - if (!op.fix_cost && it->fix_cost) continue; - if (op.fix_cost && !it->fix_cost) + for (it = (*user->_operations[op.year])[op.month].begin(); + it != (*user->_operations[op.year])[op.month].end(); + it++) { - it--; - break; - } - if (it->day > op.day) - { - it--; - break; + if (!op.fix_cost && it->fix_cost) continue; + if (op.fix_cost && !it->fix_cost) + { + it--; + break; + } + if (it->day > op.day) + { + it--; + break; + } } + if (it == (*user->_operations[op.year])[op.month].end()) + (*user->_operations[op.year])[op.month].push_back(op); + else + (*user->_operations[op.year])[op.month].insert(it, op); + // if (op.fix_cost) + // else + // (*user->_operations[op.year])[op.month].push_back(op); + ret = true; } - if (it == (*user->_operations[op.year])[op.month].end()) - (*user->_operations[op.year])[op.month].push_back(op); - else - (*user->_operations[op.year])[op.month].insert(it, op); - // if (op.fix_cost) - // else - // (*user->_operations[op.year])[op.month].push_back(op); - ret = true; } set.Finalize();