From 402d533bff8bdcc5fecb2c8f18901bc7e7869a8f Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 10 Jul 2025 14:54:36 +0200 Subject: [PATCH] Sketcher: fix for issue 12925 --- .../Gui/EditModeCoinManagerParameters.h | 19 +++++++++++++++++++ .../Gui/EditModeGeometryCoinManager.cpp | 12 ++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/Mod/Sketcher/Gui/EditModeCoinManagerParameters.h b/src/Mod/Sketcher/Gui/EditModeCoinManagerParameters.h index 1b87ca8d4e..dbc65e3e47 100644 --- a/src/Mod/Sketcher/Gui/EditModeCoinManagerParameters.h +++ b/src/Mod/Sketcher/Gui/EditModeCoinManagerParameters.h @@ -499,12 +499,31 @@ struct CoinMapping { return CurvIdToGeoId[layerindex][sublayerindex][curveindex]; } + + bool isValidCurveId(int curveindex, int layerindex, int sublayerindex = 0) const + { + // clang-format off + return static_cast(CurvIdToGeoId.size()) > layerindex && + static_cast(CurvIdToGeoId[layerindex].size()) > sublayerindex && + static_cast(CurvIdToGeoId[layerindex][sublayerindex].size()) > curveindex; + // clang-format on + } + /// given the MF index of a point and the coin layer in which it is drawn returns the GeoId of /// the point int getPointGeoId(int pointindex, int layerindex) { return PointIdToGeoId[layerindex][pointindex]; } + + bool isValidPointId(int pointindex, int layerindex) const + { + // clang-format off + return static_cast(PointIdToGeoId.size()) > layerindex && + static_cast(PointIdToGeoId[layerindex].size()) > pointindex; + // clang-format on + } + /// given the MF index of a point and the coin layer in which it is drawn returns the PosId of /// the point Sketcher::PointPos getPointPosId(int pointindex, int layerindex) diff --git a/src/Mod/Sketcher/Gui/EditModeGeometryCoinManager.cpp b/src/Mod/Sketcher/Gui/EditModeGeometryCoinManager.cpp index 63ae303c5f..433584143c 100644 --- a/src/Mod/Sketcher/Gui/EditModeGeometryCoinManager.cpp +++ b/src/Mod/Sketcher/Gui/EditModeGeometryCoinManager.cpp @@ -203,6 +203,10 @@ void EditModeGeometryCoinManager::updateGeometryColor(const GeoListFacade& geoli // colors of the point set for (int i = 0; i < PtNum; i++) { + if (!coinMapping.isValidPointId(i, l)) { + continue; + } + int GeoId = coinMapping.getPointGeoId(i, l); Sketcher::PointPos PosId = coinMapping.getPointPosId(i, l); bool isExternal = GeoId < -1; @@ -303,6 +307,10 @@ void EditModeGeometryCoinManager::updateGeometryColor(const GeoListFacade& geoli pverts[i].setValue(0, 0, viewOrientationFactor * drawingParameters.zRootPoint); } else { + if (!coinMapping.isValidPointId(i, l)) { + continue; + } + int GeoId = coinMapping.getPointGeoId(i, l); Sketcher::PointPos PosId = coinMapping.getPointPosId(i, l); pverts[i].getValue(x, y, z); @@ -405,6 +413,10 @@ void EditModeGeometryCoinManager::updateGeometryColor(const GeoListFacade& geoli int j = 0; // vertexindex for (int i = 0; i < CurvNum; i++) { + if (!coinMapping.isValidCurveId(i, l, t)) { + continue; + } + int GeoId = coinMapping.getCurveGeoId(i, l, t); // CurvId has several vertices associated to 1 material // edit->CurveSet->numVertices => [i] indicates number of vertex for line i.