diff --git a/src/gui/panels/step11_map_panel.py b/src/gui/panels/step11_map_panel.py index 6d454b6..346acb2 100644 --- a/src/gui/panels/step11_map_panel.py +++ b/src/gui/panels/step11_map_panel.py @@ -14,7 +14,7 @@ from typing import List, Optional _HERE = os.path.dirname(os.path.abspath(__file__)) if _HERE not in sys.path: sys.path.insert(0, _HERE) -from _step_path_resolver import resolve_subdir +from _step_path_resolver import resolve_subdir, get_step_output_path from PyQt5.QtCore import Qt, QThread, pyqtSignal from PyQt5.QtWidgets import ( diff --git a/src/gui/water_quality_gui_v2.py b/src/gui/water_quality_gui_v2.py index 8d7f80e..51ae36e 100644 --- a/src/gui/water_quality_gui_v2.py +++ b/src/gui/water_quality_gui_v2.py @@ -471,9 +471,37 @@ class WaterQualityGUI(QMainWindow): tab_index = get_tab_index(item_data) if tab_index < 0: return - # 先触发懒加载再切 Tab,避免 removeTab/insertTab 与导航事件重叠 - self._panel_factory.get_panel(item_data) - self._tab_widget.setCurrentIndex(tab_index) + try: + # 先触发懒加载再切 Tab,避免 removeTab/insertTab 与导航事件重叠 + self._panel_factory.get_panel(item_data) + self._tab_widget.setCurrentIndex(tab_index) + except Exception as e: + import traceback + traceback.print_exc() + from PyQt5.QtWidgets import QMessageBox + QMessageBox.critical(self, "面板加载失败", + f"加载页面时发生严重错误:\n{e}\n\n详见终端日志。") + + # ====== 新增:状态回滚(解决幽灵跳转/假死) ====== + # 既然右侧未能成功切换,必须强制将左侧导航栏的选中项退回到与右侧一致 + self._step_list.blockSignals(True) + try: + current_tab_idx = self._tab_widget.currentIndex() + from src.gui.core.panel_registry import get_tab_index + # 遍历左侧列表,找到属于当前显示的 tab_index 的那个 step + for i in range(self._step_list.count()): + item_node = self._step_list.item(i) + if item_node: + node_data = item_node.data(Qt.UserRole) + if node_data and node_data != "stage_header" and get_tab_index(node_data) == current_tab_idx: + self._step_list.setCurrentRow(i) + break + except Exception: + pass # 回滚期间如果发生异常,默默忽略,防止二次崩溃 + finally: + self._step_list.blockSignals(False) + + return # 动态更新上一步/下一步按钮可用状态 self._prev_btn.setEnabled(self._find_prev_step_row(index) is not None)