- Fix window drag: install eventFilter on live2d_container, central, and _live2d_widget; fix super() call in dynamic class - Fix text input: remove WA_TransparentForMouseEvents from _chat_container - Force QT_QPA_PLATFORM=xcb on Linux (wayland has mouse event issues) - Add HealthTracker module, update AgentBrain with health integration - Update scheduler and memory modules - Add v5_modify documentation Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
v4_modify — PetWindow 跨线程 UI 调用 + Segfault 修复
Phase 2 集成总结
完成的修复
1. PySide6 6.9.2 type() 构造 segfault 修复
文件: ui/pet_window.py
问题: type() 构造的 PetWindow 子类在调用 Qt 虚拟方法(如 showEvent)时触发 PySide6 Shiboken 内部 segfault。
根因: type(self).__bases__[0].show(self) 调用方式在 Shiboken 6.9.2 中对 type()-构造的类无效。
修复方案:
show()/hide()/close()改用QtWidgets.QMainWindow.show(self)直接调用showEvent空实现(跳过super().showEvent())避免虚拟方法覆盖 segfault_deferred_live2d_setup注册到PetWindowClass字典(之前漏了)
2. Live2D 集成(延迟)
文件: ui/live2d_view.py, ui/pet_window.py
状态: 已创建 Live2DWidget(QWebEngineView),但由于 PyQt5 WebEngine 在此环境存在 QApplication 依赖问题,暂时禁用。Live2D 显示为 emoji 占位符 🎵。
3. 可收缩聊天面板
文件: ui/pet_window.py
功能:
- 左侧 200x200 Live2D 区域 + 右侧可收缩 180px 聊天面板
- 右上角
+/×切换按钮,点击展开/收缩聊天面板 - 窗口宽度同步动画:200px(收缩)↔ 380px(展开)
关键代码:
def _toggle_chat_panel(self):
target = 0 if not self._chat_collapsed else self._chat_target_width
self._chat_container.setFixedWidth(target)
self._chat_collapsed = not self._chat_collapsed
self._toggle_btn.setText("×" if self._chat_collapsed else "+")
total_w = 200 + (0 if self._chat_collapsed else self._chat_target_width)
self.resize(total_w, 220)
4. QPropertyAnimation 崩溃修复
问题: QPropertyAnimation 尝试动画不存在的 fixedWidth 属性导致崩溃。
修复: 移除动画,直接用 setFixedWidth() 设置。
已验证
- 启动后 60+ 秒运行稳定
- 窗口显示正常,聊天面板切换正常
- 无 segfault,无 QWidget QApplication 错误
python main.py完整模式正常启动