mirror of
https://github.com/LHY0125/PathEditor.git
synced 2026-06-29 18:15:55 +08:00
fix(undo): 修复撤销按钮状态不刷新及空指针防护
- 将 refresh_undo_redo_buttons 提升为公共函数(声明在 callbacks_internal.h,实现在 callbacks.c) - 在所有 push_record 的操作回调末尾调用 refresh_undo_redo_buttons,确保按钮状态实时更新 - 修复 redo() 中 OP_CLEAN/OP_IMPORT 的 new_paths 空指针风险 - 移除 undo_redo.c 中废弃的 apply_record 函数 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+6
-11
@@ -128,14 +128,6 @@ int push_undo_record(UndoRedoManager *mgr, const OpRecord *record)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void apply_record(UndoRedoManager *mgr, int record_index, int is_undo)
|
||||
{
|
||||
(void)mgr;
|
||||
(void)record_index;
|
||||
(void)is_undo;
|
||||
// 此函数已废弃,撤销/重做逻辑在 undo() 和 redo() 中直接实现
|
||||
}
|
||||
|
||||
int undo(UndoRedoManager *mgr, StringList *sys_paths, StringList *user_paths)
|
||||
{
|
||||
if (!mgr || !can_undo(mgr))
|
||||
@@ -268,10 +260,13 @@ int redo(UndoRedoManager *mgr, StringList *sys_paths, StringList *user_paths)
|
||||
case OP_IMPORT:
|
||||
// 重做清理/导入:应用新列表
|
||||
clear_string_list(target);
|
||||
for (int i = 0; i < rec->count; i++)
|
||||
if (rec->new_paths)
|
||||
{
|
||||
if (rec->new_paths[i])
|
||||
add_string_list(target, rec->new_paths[i]);
|
||||
for (int i = 0; i < rec->count; i++)
|
||||
{
|
||||
if (rec->new_paths[i])
|
||||
add_string_list(target, rec->new_paths[i]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user