mirror of
https://github.com/LHY0125/PathEditor.git
synced 2026-05-10 10:19:47 +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:
@@ -1,6 +1,7 @@
|
||||
#include "controller/callbacks.h"
|
||||
#include "controller/callbacks_internal.h"
|
||||
#include "core/app_context.h"
|
||||
#include "core/undo_redo.h"
|
||||
#include "utils/ui_constants.h"
|
||||
#include <iup.h>
|
||||
|
||||
@@ -45,3 +46,19 @@ Ihandle *get_current_list(Ihandle *dlg)
|
||||
return IupGetDialogChild(dlg, CTRL_LIST_USER);
|
||||
return IupGetDialogChild(dlg, CTRL_LIST_SYS);
|
||||
}
|
||||
|
||||
// 刷新撤销/重做按钮的启用状态
|
||||
void refresh_undo_redo_buttons(Ihandle *dlg)
|
||||
{
|
||||
AppContext *ctx = get_app_context_from_dlg(dlg);
|
||||
if (!ctx || !ctx->undo_redo_mgr)
|
||||
return;
|
||||
|
||||
Ihandle *btn_undo = IupGetDialogChild(dlg, CTRL_BTN_UNDO);
|
||||
Ihandle *btn_redo = IupGetDialogChild(dlg, CTRL_BTN_REDO);
|
||||
|
||||
if (btn_undo)
|
||||
IupSetAttribute(btn_undo, "ACTIVE", can_undo(ctx->undo_redo_mgr) ? "YES" : "NO");
|
||||
if (btn_redo)
|
||||
IupSetAttribute(btn_redo, "ACTIVE", can_redo(ctx->undo_redo_mgr) ? "YES" : "NO");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user