From 2d45610aa6e7b1748a1571b4e0cce5cc422947e3 Mon Sep 17 00:00:00 2001 From: DXC Date: Thu, 18 Jun 2026 09:01:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AF=BC=E8=88=AA=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E9=94=81=E9=98=B2=E6=8A=96=20+=20=E8=BF=90=E8=A1=8C=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E4=B8=AD=E9=97=B4=E6=A7=BD=E5=87=BD=E6=95=B0=EF=BC=88?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B9=B1=E8=B7=B3=E4=B8=8E=E6=97=A0=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E5=8F=8C=20Bug=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug1 导航乱跳:_on_step_list_changed 先调 get_panel 触发懒加载再 setCurrentIndex,避免 removeTab/insertTab 索引偏移导致跳页错乱。_on_tab_changed 加 _is_syncing 守卫斩断乒乓效应。Bug2 按钮无响应:新增 _on_run_all_clicked 中间槽函数替代直接连接,内含 print 探针 + try/except 兜底。 --- src/gui/water_quality_gui_v2.py | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/gui/water_quality_gui_v2.py b/src/gui/water_quality_gui_v2.py index 5459c22..f3abda5 100644 --- a/src/gui/water_quality_gui_v2.py +++ b/src/gui/water_quality_gui_v2.py @@ -88,6 +88,8 @@ class WaterQualityGUI(QMainWindow): ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(my_appid) super().__init__() + self._is_syncing = False + icon_path = get_resource_path("data/icons-1/uitubiao.ico") self.setWindowIcon(QIcon(icon_path)) @@ -358,7 +360,7 @@ class WaterQualityGUI(QMainWindow): self._run_all_btn = QPushButton("> 运行完整流程") self._run_all_btn.setStyleSheet(ModernStylesheet.get_button_stylesheet('success')) self._run_all_btn.setMinimumHeight(35) - self._run_all_btn.clicked.connect(self._pipeline_executor.run_full_pipeline) + self._run_all_btn.clicked.connect(self._on_run_all_clicked) btn_layout.addWidget(self._run_all_btn) self._stop_btn = QPushButton("⏹ 停止") @@ -417,11 +419,21 @@ class WaterQualityGUI(QMainWindow): work_dir = data.get('work_dir', '') self.statusBar().showMessage(f"工作目录: {work_dir}") + def _on_run_all_clicked(self): + print("==== 按钮确实被按下了 ====", flush=True) + try: + self._pipeline_executor.run_full_pipeline() + except Exception as e: + print(f"执行器调用崩溃: {e}") + traceback.print_exc() + # ================================================================ # 导航 ↔ Tab 双向同步(纯 UI 路由) # ================================================================ def _on_step_list_changed(self, index): + if self._is_syncing: + return if index < 0: return item = self._step_list.item(index) @@ -432,10 +444,21 @@ class WaterQualityGUI(QMainWindow): return from src.gui.core.panel_registry import get_tab_index tab_index = get_tab_index(item_data) - if tab_index >= 0: + if tab_index < 0: + return + self._is_syncing = True + try: + # ★ 先触发懒加载:get_panel 内部 _ensure_loaded 自带 blockSignals + # 保护 removeTab/insertTab,面板实例化完成后再切 Tab, + # 此时 _ensure_loaded 发现已加载直接返回,不再触发索引偏移 + self._panel_factory.get_panel(item_data) self._tab_widget.setCurrentIndex(tab_index) + finally: + self._is_syncing = False def _on_tab_changed(self, index): + if self._is_syncing: + return if index < 0: return from src.gui.core.panel_registry import get_step_id_by_tab_index @@ -447,7 +470,11 @@ class WaterQualityGUI(QMainWindow): if not item: continue if item.data(Qt.UserRole) == target_step_id: - self._step_list.setCurrentRow(row) + self._is_syncing = True + try: + self._step_list.setCurrentRow(row) + finally: + self._is_syncing = False break # ================================================================