This repository was archived by the owner on Mar 23, 2026. It is now read-only.
fix: 同名节点导致的时间线错乱#888
Merged
IsHPDuwu merged 2 commits intoAug 27, 2025
Merged
Conversation
ChimeYao-bot
left a comment
Collaborator
There was a problem hiding this comment.
我看了你最新提交(menu.py,新增 te_check_parts_name 并连接到 te_name_edit.textChanged)。思路没问题:避免同名节点,但还有几点需要修正,避免运行错误或误判:
核心问题
- 信号/槽签名:
textChanged会传字符串参数,但方法没有接收,会报TypeError。建议改成:
def te_check_parts_name(self, _=None):-
名称拆分/判重不稳:
- 只按第一个
' - '拿到名称(split(' - ', 1)),不要依赖长度。 - 比较前做
.strip().lower(),避免大小写或空格差异误判。
- 只按第一个
-
选中项切换未更新:
currentItemChanged也要触发检查,保证按钮状态实时更新。
建议实现(直接替换连接和方法)
te_name_edit.currentTextChanged.connect(self.te_check_parts_name)
part_list.currentItemChanged.connect(self.te_check_parts_name)
def te_check_parts_name(self, _=None):
"""检查当前输入的节点名是否重复"""
te_add_part_button = self.findChild(ToolButton, 'add_part_button')
te_edit_part_button = self.findChild(ToolButton, 'edit_part_button')
te_name_edit = self.findChild(EditableComboBox, 'name_part_combo')
part_list = self.findChild(ListWidget, 'part_list')
if te_add_part_button is None and te_edit_part_button is None:
return
name = (te_name_edit.currentText() if te_name_edit else "").strip()
norm_name = name.lower()
if not norm_name:
if te_add_part_button: te_add_part_button.setEnabled(False)
if te_edit_part_button: te_edit_part_button.setEnabled(False)
return
current_item = part_list.currentItem() if part_list else None
for i in range(part_list.count() if part_list else 0):
item = part_list.item(i)
if not item: continue
part_name = item.text().split(' - ', 1)[0].strip()
if part_name.lower() == norm_name:
if current_item is item:
if te_add_part_button: te_add_part_button.setEnabled(False)
if te_edit_part_button: te_edit_part_button.setEnabled(True)
else:
if te_add_part_button: te_add_part_button.setEnabled(False)
if te_edit_part_button: te_edit_part_button.setEnabled(False)
return
if te_add_part_button: te_add_part_button.setEnabled(True)
if te_edit_part_button: te_edit_part_button.setEnabled(True)测试要点
- 输入空名 → Add/Edit 禁用
- 输入已有节点名 → Add 禁用,Edit 仅在选中自身时可用
- 名称大小写或空格差异 → 视为同名
- 切换选中项 → 按钮状态自动更新
- 多个
' - '的文本仍能正确解析
总结:
- 修正槽签名 + 拆分/比较逻辑 + currentItemChanged 触发,运行更稳健
- 合并前手工验证上述测试用例即可
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.