From 63abc50c81bead7389541d2e6d0f1e8604612c45 Mon Sep 17 00:00:00 2001 From: Patrick Lipka Date: Wed, 15 Dec 2021 17:28:44 +0100 Subject: [PATCH] check if active tasks exists if no name is being provided before manipulating time --- src/ui.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ui.cpp b/src/ui.cpp index 7902663..1272c6a 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -455,6 +455,10 @@ void command_at(std::string input, int wtime, ProjectList *proj_list){ if(place_of_slash == std::string::npos){ if(proj_name.length()==0){ // add time to active task + if(proj_list->active_project->active_task == NULL){ + std::cout << "Task " << proj_list->active_project->name << "/" << proj_name << " does not exist." << std::endl; + return ; + } proj_list->active_project->active_task->add_time(wtime); std::cout << wtime << "s added to task " << proj_list->active_project->name << "/" << proj_list->active_project->active_task->name << std::endl; command_save(proj_list); @@ -496,6 +500,10 @@ void command_rt(std::string input, int wtime, ProjectList *proj_list){ if(place_of_slash == std::string::npos){ if(proj_name.length()==0){ // add time to active task + if(proj_list->active_project->active_task == NULL){ + std::cout << "Task " << proj_list->active_project->name << "/" << proj_name << " does not exist." << std::endl; + return ; + } proj_list->active_project->active_task->add_time(-wtime); std::cout << wtime << "s removed from task " << proj_list->active_project->name << "/" << proj_list->active_project->active_task->name << std::endl; return;