aboutsummaryrefslogtreecommitdiff
path: root/ttt.jai
diff options
context:
space:
mode:
Diffstat (limited to 'ttt.jai')
-rw-r--r--ttt.jai21
1 files changed, 10 insertions, 11 deletions
diff --git a/ttt.jai b/ttt.jai
index 36271f2..3682bfd 100644
--- a/ttt.jai
+++ b/ttt.jai
@@ -37,7 +37,7 @@ VERSION :: "2.0"; // Use only 3 chars (to fit layouts).
YEAR :: "2024";
NUM_WEEK_DAYS :: 7;
-APP_FOLDER_NAME :: ".task_time_tracker_test"; // TODO Using different folder to avoid erasing my work data.
+APP_FOLDER_NAME :: ".task_time_tracker";
DB_FILE_NAME :: "database.bin";
AR_FILE_NAME :: "archive.csv";
DB_FILE_SIGN_STR :: "TTT:B:02";
@@ -436,9 +436,10 @@ update_times :: (db: *Database) {
// Keep track of this update.
db.modified_on = stop_time;
- if db.active_idx < 0 return;
+ active_task := get_active_task(db);
+
+ if active_task == null return;
- active_task := *db.tasks[db.active_idx];
start_week_day: s8;
while (start_time < stop_time) {
@@ -657,12 +658,15 @@ import_from_csv :: (db: *Database, path: string) -> bool #must {
return result, true;
}
- csv, success := read_entire_file(path);
+ data, success := read_entire_file(path);
if success == false {
log_error("Failed to read file '%'.", path);
return false;
}
- defer free(csv.data);
+ defer free(data);
+
+ // Work on a string struct copy, otherwise the free(data) will fail.
+ csv := data;
// Skip header line.
consume_next_line(*csv);
@@ -1403,12 +1407,7 @@ main :: () {
redraw_all = key != TUI.Keys.None;
update_times(*database);
-
- /* TODO
- Remove `selected_task` and `active_task` and helper functions.
- Every time we add or remove tasks to the database, it may be reallocated, thus making the selected_task and active_task pointers invalid. Check if this is messing up the app.
- Maybe use a macro returns the selected/active task based on the indices.
- */
+
selected_task := get_selected_task(db);
active_task := get_active_task(db);
selected_task_row: int;