From c8fabfa2ebe84df536c293f7a0e4608a517b538e Mon Sep 17 00:00:00 2001 From: henrypp Date: Sat, 8 Feb 2025 14:59:32 +0500 Subject: [PATCH] correct log viewer file path --- src/log.c | 11 +++++++++++ src/main.c | 18 +++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/log.c b/src/log.c index c62a0110..593d507b 100644 --- a/src/log.c +++ b/src/log.c @@ -115,10 +115,21 @@ PR_STRING _app_getlogpath () _Ret_maybenull_ PR_STRING _app_getlogviewer () { + R_STRINGREF sr; PR_STRING path; path = _r_config_getstringexpand (L"LogViewer", LOG_VIEWER_DEFAULT); + if (!path || !_r_fs_exists (&path->sr)) + { + if (path) + _r_obj_dereference (path); + + _r_obj_initializestringref (&sr, LOG_VIEWER_DEFAULT); + + _r_str_environmentexpandstring (NULL, &sr, &path); + } + return path; } diff --git a/src/main.c b/src/main.c index 5e80bbc0..84ca58fc 100644 --- a/src/main.c +++ b/src/main.c @@ -732,26 +732,26 @@ INT_PTR CALLBACK SettingsProc ( case IDD_SETTINGS_LOGGING: { - PR_STRING string; + PR_STRING path; _r_ctrl_checkbutton (hwnd, IDC_ENABLELOG_CHK, _r_config_getboolean (L"IsLogEnabled", FALSE)); - string = _app_getlogpath (); + path = _app_getlogpath (); - if (string) + if (path) { - _r_ctrl_setstring (hwnd, IDC_LOGPATH, string->buffer); + _r_ctrl_setstring (hwnd, IDC_LOGPATH, path->buffer); - _r_obj_dereference (string); + _r_obj_dereference (path); } - string = _app_getlogviewer (); + path = _r_config_getstringexpand (L"LogViewer", LOG_VIEWER_DEFAULT); - if (string) + if (path) { - _r_ctrl_setstring (hwnd, IDC_LOGVIEWER, string->buffer); + _r_ctrl_setstring (hwnd, IDC_LOGVIEWER, path->buffer); - _r_obj_dereference (string); + _r_obj_dereference (path); } _r_ctrl_setacceleration (hwnd, IDC_LOGSIZELIMIT, 64); // set step to 64kb