From 2ec6ef66d9fdc4f225c5f0e6317bb7ecba040533 Mon Sep 17 00:00:00 2001 From: dam Date: Wed, 28 Aug 2024 13:29:57 +0100 Subject: Update TUI module to fix memory leak; Only sort if tasks are available. --- modules/TUI/key_map.jai | 5 +++++ modules/TUI/module.jai | 2 ++ ttt.jai | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/TUI/key_map.jai b/modules/TUI/key_map.jai index f0754a7..43762f4 100644 --- a/modules/TUI/key_map.jai +++ b/modules/TUI/key_map.jai @@ -2,6 +2,11 @@ key_map: Table(string, Key); +reset_key_map :: () { + table_reset(*key_map); + deinit(*key_map); +} + setup_key_map :: () { if key_map.count > 0 then return; diff --git a/modules/TUI/module.jai b/modules/TUI/module.jai index 124b906..1ed950b 100644 --- a/modules/TUI/module.jai +++ b/modules/TUI/module.jai @@ -383,6 +383,8 @@ reset_terminal :: () -> success := true #must { Commands.RestoreCursorPosition, Commands.ShowCursor ); + + reset_key_map(); return; } diff --git a/ttt.jai b/ttt.jai index cc6ec0d..7446567 100644 --- a/ttt.jai +++ b/ttt.jai @@ -14,7 +14,7 @@ DEBUG :: false; #import "UTF8"; TUI :: #import "TUI"(COLOR_MODE_BITS=4); -VERSION :: "3.1"; // Use only 3 chars (to fit layouts). +VERSION :: "3.2"; // Use only 3 chars (to fit layouts). YEAR :: "2024"; NUM_WEEK_DAYS :: 7; @@ -1746,6 +1746,8 @@ main :: () { // Sort by. case #char "s"; #through; case #char "S"; + if selected_task == null continue; + TUI.using_style(action_style); sort_by := prompt_user_key(selected_task_row, "Sort by (n) name, (1..7) day, or (t) total time."); show_processing(); -- cgit v1.2.3