diff --git a/src/project.cpp b/src/project.cpp index bcc49ac..08bdfd7 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -65,7 +65,6 @@ ProjectList::ProjectList(std::string month){ void ProjectList::add_project(Project proj){ projects.push_back(proj); set_active_project(num_projects); - active_project->set_active_task(active_project->active_task_id); num_projects++; } @@ -91,13 +90,13 @@ void ProjectList::save(std::string file_name){ std::cout << "Saving: num_projects=" << num_projects << std::endl; of.write((char*) &active_project_id, sizeof(int)); for (int i=0; iactive_project->name << "/" << proj_list->active_project->active_task->name << std::endl; - std::cout << "New time: "<< proj_list->active_project->active_task->work_time << std::endl; return; }else{ // add time to task in same project @@ -551,13 +547,13 @@ void command_report(std::string date_str, ProjectList* proj_list){ } } }else{ - ProjectList *list = new ProjectList(month); - list->load(date_str); - if (list->num_projects > 0){ + ProjectList list(month); + list.load(date_str); + if (list.num_projects > 0){ std::cout << "Report for " << user_name << ", month: " << date_str << std::endl << std::endl; - for (int i=0; inum_projects; i++){ + for (int i=0; iprojects[i]); + Project *proj = &(list.projects[i]); float wtime_proj = proj->get_total_work_time() / 3600.0; if(wtime_proj >= 0.01){ std::cout << "Project: " << proj->name << std::endl;