From e7f9d810ae3d7989d261e7c755d73b22dcf6e961 Mon Sep 17 00:00:00 2001 From: dc-pc Date: Fri, 9 Oct 2026 10:43:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(dbg):=20=E4=BF=AE=E5=A4=8D=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E6=8F=92=E4=BB=B6=E4=B8=AD=E7=9A=84=E6=97=A0=E9=99=90?= =?UTF-8?q?=E5=BE=AA=E7=8E=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用有界搜索替换前进循环,避免短缓冲区导致的UI冻结 - 采用rfind方法查找最后的转义序列而不是循环查找 - 防止索引计算错误导致的GIL占用和界面无响应问题 - 优化了尾部窗口中ANSI转义码的处理逻辑 --- COMTool/plugins/dbg.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/COMTool/plugins/dbg.py b/COMTool/plugins/dbg.py index a3d972a3..45f65385 100644 --- a/COMTool/plugins/dbg.py +++ b/COMTool/plugins/dbg.py @@ -809,12 +809,12 @@ def _texSplitByColor(self, text:bytes): text = text[:-2] remain = b'\x1b[' else: # ****\x1b[****, ****\x1b[****;****m - idx = -2 - idx_remain = -1 - while 1: - idx = text.find(b"\x1b[", len(text) - 10 + idx + 2) # \x1b[00;00m] - if idx < 0: - break + # find the last "\x1b[" within the tail window; using a bounded + # search instead of an advancing loop, since for short buffers + # (len <= 8) the old loop start could clamp and never advance, + # causing an infinite loop that kept the GIL and froze the UI + idx = text.rfind(b"\x1b[", max(0, len(text) - 10)) + if idx >= 0: remain = text[idx:] idx_remain = idx if len(remain) > 0: