harden(app): setData 重置遮罩 + loadFailed context=detailPanel(防野指针) + LoadingOverlay Q_ASSERT(parent) + 删未用 include(评审 I-1/I-2/M-3/4/5)

This commit is contained in:
gaozheng 2026-06-11 21:06:35 +08:00
parent dc9506c260
commit 8b3bc50f58
3 changed files with 6 additions and 2 deletions

View File

@ -527,7 +527,10 @@ void buildWorkbench(QMainWindow& window, geopro::data::LocalSampleRepository& re
if (phase == geopro::controller::DatasetDetailController::LoadPhase::Grid)
detailPanel->setGridLoading(dsId, true);
});
QObject::connect(&detailCtrl, &geopro::controller::DatasetDetailController::loadFailed, &window,
// context 用 detailPanel与 loadStarted 一致detailPanel 析构即自动断连,避免野指针。
// window 比 detailPanel 活得久lambda 捕 &window 取状态栏安全。loadFailed 无 phase
// Chart 失败时 gridOverlay 本已隐藏setGridLoading(false) 幂等无害Grid 失败时正确清遮罩。
QObject::connect(&detailCtrl, &geopro::controller::DatasetDetailController::loadFailed, detailPanel,
[&window, detailPanel](const QString& dsId, const QString& msg) {
detailPanel->setGridLoading(dsId, false);
window.statusBar()->showMessage(

View File

@ -51,6 +51,7 @@ void DatasetDetailPage::setData(const geopro::controller::DatasetDetailControlle
gridRequested_ = false; // 新数据集 → 网格数据需重新按需加载
rawView_->setData(d);
gridView_->setData(d);
setGridLoading(false); // 重开/换 ds重置遮罩状态避免上次的「加载中」残留
}
void DatasetDetailPage::setGridData(

View File

@ -1,12 +1,12 @@
#include "panels/LoadingOverlay.hpp"
#include <QEvent>
#include <QLabel>
#include <QResizeEvent>
#include <QVBoxLayout>
namespace geopro::app {
LoadingOverlay::LoadingOverlay(QWidget* parent) : QWidget(parent), label_(new QLabel(this)) {
Q_ASSERT(parent); // 契约:必须有父(遮罩几何跟随父,无父无法工作)
setAttribute(Qt::WA_StyledBackground, true);
setStyleSheet(QStringLiteral("background: rgba(255,255,255,160);"));
label_->setText(QStringLiteral("加载中…"));